<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Chapter 4 The Type System on Go: Under the Hood</title><link>https://golang.design/under-the-hood/en/part2lang/ch04type/</link><description>Recent content in Chapter 4 The Type System on Go: Under the Hood</description><generator>Hugo</generator><language>en</language><atom:link href="https://golang.design/under-the-hood/en/part2lang/ch04type/index.xml" rel="self" type="application/rss+xml"/><item><title>4.1 The Runtime Type System</title><link>https://golang.design/under-the-hood/en/part2lang/ch04type/type/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part2lang/ch04type/type/</guid><description>&lt;h1 id="41-the-runtime-type-system"&gt;4.1 The Runtime Type System&lt;/h1&gt;
&lt;p&gt;Go is a statically typed language, and type checking happens at compile time. Yet Go still keeps a substantial amount of &lt;strong&gt;runtime type information&lt;/strong&gt; (RTTI), and it is precisely this that supports interfaces (&lt;a href=".././interface"&gt;4.2&lt;/a&gt;), type assertions, type switches, reflection, and the garbage collector&amp;rsquo;s precise identification of pointers. This section answers a seemingly simple question: of the type machinery that exists at compile time, what survives into the runtime, in what form is it kept, and what capabilities does it underpin. Once you understand the small structure called the &lt;strong&gt;type descriptor&lt;/strong&gt; in this section, the interface (&lt;a href=".././interface"&gt;4.2&lt;/a&gt;), reflection, and precise GC (&lt;a href="https://golang.design/under-the-hood/en/part4memory/ch13gc/"&gt;13&lt;/a&gt;) all gain a common footing.&lt;/p&gt;</description></item><item><title>4.2 Interfaces</title><link>https://golang.design/under-the-hood/en/part2lang/ch04type/interface/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part2lang/ch04type/interface/</guid><description>&lt;h1 id="42-interfaces"&gt;4.2 Interfaces&lt;/h1&gt;
&lt;p&gt;Interfaces are the soul of Go&amp;rsquo;s type system. They decouple behavior from implementation, and they do it in an unusual way: structural, implicit satisfaction, unlike most mainstream languages. This section looks at how interfaces are represented at runtime, how methods are dispatched dynamically, how type assertions are realized, and where this design sits within the broader lineage of polymorphism. Following the approach of the previous sections, the structs given below are &lt;strong&gt;trimmed-down sketches&lt;/strong&gt;: they keep only the fields relevant to the design, with comments explaining why each one exists. For the full definitions, compare against &lt;code&gt;runtime/runtime2.go&lt;/code&gt;, &lt;code&gt;internal/abi/iface.go&lt;/code&gt;, and &lt;code&gt;runtime/iface.go&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>4.3 Type Aliases</title><link>https://golang.design/under-the-hood/en/part2lang/ch04type/alias/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://golang.design/under-the-hood/en/part2lang/ch04type/alias/</guid><description>&lt;h1 id="43-type-aliases"&gt;4.3 Type Aliases&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;type A = B&lt;/code&gt; (a type alias) and &lt;code&gt;type A B&lt;/code&gt; (defining a new type) differ by a single equals sign, yet the
semantics are fundamentally different. The former merely gives a new name to an existing type; the latter
creates a brand-new type with its own independent identity. The distinction looks minor, but it pulls on the
whole set of rules governing type equality, method sets, and assignability (&lt;a href=".././type"&gt;4.1&lt;/a&gt;), and it also
pulls on a question Go has always cared about: when a body of code is no longer maintained by its original
author yet still has to evolve without breaking compatibility, how should a type migrate from one package to
another. This section first makes the semantics of aliases and defined types clear, then explains why aliases
were introduced in Go 1.9, and finally looks at the generic capability they gained in Go 1.24.&lt;/p&gt;</description></item></channel></rss>