Chapter 09The Price of AbstractionPaid chapter

Interface Dispatch: Itabs, Indirection, Escape, and Typed Nil

Separate interface data storage, dispatch, devirtualization, and typed-nil semantics.

Launch paywall

This chapter is part of the paid launch. The preview stays visible so readers can evaluate the exact scope before buying.

Included in

Core and Complete. Complete also includes the practical exam and free Go-version updates.

Preview

What this chapter teaches

Common belief

An interface is just a function pointer. Calling through one costs a single indirect call — cheap.

What actually happens

an interface value is two words — a pointer to its method table (the itab) and a pointer to its data. Three costs follow. Creating one usually heap-allocates, because the data word must point at the value (the boxing in the cold open). Calling through one is an indirect call that the compiler cannot inline, which blocks the downstream optimizations inlining unlocks (Chapter 4). And the itab lookup people worry about is actually the cheap part — cached and amortized to a pointer comparison. Plus a correctness trap: an interface is nil only when both words are nil, so a nil pointer stored in an interface is not == nil.

Mechanisms covered
Unresolved dispatch can retain an indirect call; devirtualization can expose a concrete callee.
An interface holding a typed nil pointer is not a nil interface.
benchcompileexperiment
One-time purchase

Unlock Chapter 09 and the rest of the course.

Core unlocks every paid chapter and lab. Complete also includes the practical exam and future Go-version updates.

Core
$49

Full course access with the complete mechanics curriculum.

All paid chapters unlocked
One-time purchase
Perfect if you want the material only
Complete
$79
Best value

Best-value launch option with the exam and free Go-version course updates.

Everything in Core
Black Belt practical exam
Free Go-version updates

No subscription or account required. Access is tied to the email entered at Stripe Checkout and can be restored by email.

Free chapter
Escape Analysis: The Compiler's Fragile Decision
Distinguish escape diagnostics from measured allocations and explain the role of lifetime and call-site visibility.
Free chapter
Maps: Swiss Tables, Growth, and Permanent Memory
Distinguish map table capacity from referenced payloads and inspect clearing and growth on Go 1.25.