Chapter 09The Price of AbstractionPaid chapter

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

Understand the runtime cost of interface method calls — itab, indirect call, argument escape — when devirtualization removes it, and the interface-representation gotcha.

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, Complete, and Team. Complete also includes the practical exam and free Go-version updates.

Preview

What this chapter teaches

Common belief

Interfaces are just function pointers; the cost is one indirect call.

What actually happens

assigning a value to an interface usually escapes it to the heap, and the indirect call blocks inlining and downstream optimization. The itab lookup is the cheap part. (Plus the typed-nil trap: an interface holding a nil pointer is not == nil.)

Mechanisms covered
Itabs are cached per (interface type, concrete type), so lookup is amortized. The indirect call is the real cost.
The compiler can devirtualize when it can prove the concrete type, eliminating indirection.
An interface is nil only when both its type and value words are nil; a non-nil type with a nil value pointer compares != nil.
benchcompileexperiment
Email-first checkoutUnlock Chapter 09

Unlock Chapter 09 and the rest of the course.

Start with your email, then continue to Lemon Squeezy checkout. Core unlocks the paid chapters, Complete adds the exam and free Go-version updates, and Team gives you 5 seats.

Choose a plan

You'll head to Lemon Squeezy for secure checkout. Global tax is handled there. No subscription. Complete also includes the practical exam and free Go-version updates.

Free chapter
Escape Analysis — The Compiler's Fragile Decision
Understand how the compiler decides between stack and heap allocation, why the decision is fragile, and how to verify it.
Free chapter
Maps — Swiss Tables, Growth, and Permanent Memory
Understand the Go 1.24+ Swiss Table map layout, why maps don't shrink, and how to design for memory reclamation.