Skip to content
DevMeme
3628 of 7435
Explaining Swift Metatypes vs. Sane Conversation
Languages Post #3966, on Nov 24, 2021 in TG

Explaining Swift Metatypes vs. Sane Conversation

Why is this Languages meme funny?

Level 1: Big Words, Blank Stares

Imagine two friends at a diner, and one friend is super excited about a really complicated idea. He starts using big, fancy words to explain it: it’s like he’s talking about the idea of an idea of an idea! The other friend’s face just goes completely blank. He’s thinking, “Huh? What are you even saying right now?” This is what’s happening in the meme. One developer friend is trying to explain something about Swift (a coding language) that’s pretty confusing — basically talking about a “type of a type,” like a blueprint of a blueprint. The other friend feels totally lost, just like anyone would if their buddy suddenly started speaking in technical gobbledygook. It’s funny because we’ve all been in that situation: someone is super into their complicated topic and they’re gesturing wildly (just like the first guy in the meme), and you’re sitting there with your food getting cold, not understanding a word (just like the second guy who eventually says, “What on earth are you talking about?”). In simple terms, the meme is poking fun at how using a bunch of big technical words can completely confuse the person listening. Even if the explanation is correct, it just sounds like nonsense to anyone who isn’t already in on the idea. It’s like a kid using a lot of scientific terms to explain a magic trick — at some point their friend is going to just stare and say, “I have no idea what you mean.” The humor here is really about that confused reaction: one friend went way too deep, and the other friend is left scratching his head.

Level 2: Blueprint of a Blueprint

Let’s break down what all that means in plainer terms. In Swift (Apple’s main programming language for iOS and Mac development), every value and object has a type. For example, an Int is a type for integers, a String is a type for text, and you can create your own types like classes (class Car { ... }) or structures (struct Point { ... }). Static typing means the compiler needs to know what type everything is before the program runs. Now, Swift does something interesting: it lets you treat types themselves as values. Think of a class or struct as a blueprint for making objects. Swift allows you to also work with the blueprint itself as a kind of object. The metatype is basically the type of that blueprint. It’s like having a blueprint of a blueprint. This is what they mean by “the type of any type.”

How do we actually use that? Swift’s syntax for referring to a type as a value is by appending .Type or .Protocol to a type’s name. For a regular concrete type (like a class, struct, or enum you define), you use .Type. For a protocol (which is like an interface or a list of methods that some class/struct can promise to implement), you use .Protocol to get at the protocol itself. That’s because in Swift you normally use a protocol as a requirement for something, not as something you instantiate directly. So MyClass.Type is “the type of the class MyClass itself.” And SomeProtocol.Protocol is “the type of the protocol definition SomeProtocol.” It sounds a bit circular, but it’s actually straightforward in usage. Here’s a concrete example:

  • Suppose we have a simple struct:

    struct Dog { }
    

    The type of a Dog instance is obviously Dog. But what if we want to talk about the Dog type itself at runtime? In Swift we can say:

    let dogType: Dog.Type = Dog.self
    

    Now dogType is a value that represents the Dog type. It’s as if we took the blueprint named Dog and held it in our hand. We assigned it to a variable whose type is Dog.Type (meaning “the type of Dog”). If we print dogType, it might show something like Dog.Type to indicate it’s the type object, not an actual dog.

  • Now for a protocol example:

    protocol Drivable { }
    let protoType: Drivable.Protocol = Drivable.self
    

    Here protoType represents the protocol Drivable itself as a value (using .Protocol). We can’t make a plain Drivable() because it’s just a rule set with no concrete form. But we can hold the idea of “Drivable” in a variable using Drivable.Protocol. This distinction exists because Drivable.Type has a different meaning: Drivable.Type would mean “the type of some concrete thing that conforms to Drivable” (like a placeholder for any actual car or bike type that is Drivable). So Swift needs two different suffixes to avoid confusion: .Type for concrete types and .Protocol for protocols.

All of this is in service of Swift’s strong type safety. By being explicit, the compiler knows exactly what you mean. These features let developers do fancy things like making factories or writing functions that operate on types themselves. For instance, you could have an array of Animal.Type to keep a list of different animal classes, then instantiate one of each. Or you might reflect on protocol definitions. But if you’re newer to Swift or not deep into these patterns, hearing someone talk about “metatype of a protocol vs the concrete type at runtime” can sound like gibberish. It’s an advanced topic in the Swift language quirks department.

In simpler terms:

  • Metatype: just a fancy way to say “type of a type.” It’s the category that a type falls into.
  • .Type: put after a class/struct/enum name to get that type’s own type. Example: Int.Type is the type of the Int type itself.
  • .Protocol: put after a protocol name to get the protocol’s own type (the idea of that protocol). Example: Comparable.Protocol is the type of the protocol Comparable itself, not any particular thing that conforms to Comparable.

The meme is funny because the person explaining uses exactly these formal definitions, which can be overwhelming. If you haven’t seen Foo.Type in code before, you’d probably react with “Wait, Foo dot what now?” It’s a real feature, but it’s not something you need every day unless you’re doing some meta-programming or working with Swift’s reflection APIs. So a teammate dropping this knowledge out of nowhere could definitely bewilder the unprepared listener!

Level 3: Type Inception

From a senior developer’s perspective, this meme is hilariously on-point about Swift’s type system quirks. The first panel’s text sounds like it was lifted straight from Apple’s documentation – a dry definition of metatypes that would make any Swift newbie’s head spin. It’s the classic scenario of explaining an advanced concept and completely losing your audience. We’ve all been there: you excitedly share some arcane language feature or type system design insight, only to realize your teammate’s eyes have glazed over. Here Jesse (the explainer) is diving into the type-of-a-type explanation with gusto, talking about “the type of any type, including class types, structure types…protocol types.” That’s a mouthful of jargon to spew over pancakes at a diner! Walter’s immediate reaction is a plain “What?” – and who can blame him? Jesse is basically performing Type Inception: a type within a type concept, which can sound like dream-within-a-dream logic if you’re not familiar with it.

So why is this funny to experienced devs? Because Swift metatypes are confusing at first, and the meme exaggerates the knowledge gap. The humor comes from the contrast: one engineer acting like a professor of type theory, and the other channeling the universal baffled teammate who just wanted a simple answer. Swift’s .Type and .Protocol syntax is a perfect example of a language quirk that trips people up. Imagine you’re pair-programming on an iOS app and someone says:

“The metatype of a class, structure, or enumeration type is the name of that type followed by .Type. And the metatype of a protocol type – not the concrete type that conforms to the protocol at runtime – is the name of that protocol followed by .Protocol.”

Cue your coworker slowly putting down their coffee with a HUH? expression. In a real project meeting, dropping terms like protocol metatype might cause exactly this reaction. Even seasoned developers might need a moment to parse that sentence. Apple’s language design favors explicitness, but it can lead to these wonky sentences.

What’s being satirized here is the overzealous explainer who plunges into technical distinctions that only make sense if you’re deep in the Swift rabbit hole. Jesse is effectively quoting something you’d find in Swift’s reference guide, while Walt (a stand-in for a normal dev) is completely lost. It highlights a common communication hiccup in tech: one person’s clear explanation is another person’s word salad. The meme strikes a chord because it’s relatable humor: static typing and type theory can feel like someone inventing terms on the fly if you haven’t encountered them before. And specifically, Swift’s .Protocol vs .Type thing is notorious – it’s an extra wrinkle just for protocol types that many forget until it bites them. The developer confusion on Walt’s face in panel 5, with the caption “Jesse, what the fuck are you talking about?”, is basically every team lead or mentor when a simple question (“How do I do X in Swift?”) gets an answer that sounds like a doctoral thesis. It’s poking fun at how we engineers sometimes explain things in a needlessly complicated way, totally losing our teammate in the process.

On the flip side, those who have been down this road can’t help but chuckle. The meme implicitly nods to times we’ve seen code like this in Swift and had to wrap our heads around it:

class Car { }
let meta: Car.Type = Car.self    // The metatype of Car (a Type of type Car)
print(meta)  // prints "Car.Type"

protocol Drivable { }
let protoMeta: Drivable.Protocol = Drivable.self  // The metatype of the protocol Drivable
print(protoMeta)  // prints "Drivable.Protocol"

Seeing .self, .Type, and especially .Protocol can induce a double-take if you’re not expecting it. Senior Swift developers know this construct, but they also know it’s a topic best introduced gently. Otherwise, you’ll get that meme-worthy “Please explain like I’m five” reaction. Ultimately, the humor resonates because it captures an industry pattern: advanced static typing concepts explained in all their glory – and the stunned silence that often follows.

Level 4: Turtles All the Way Down

At the deepest level, this meme touches on type theory and Swift’s unique take on types of types. In programming language theory, there’s a concept that even types themselves have types. Think of it like an infinite mirror: in some systems it could be "a type of a type of a type..." – an almost turtles-all-the-way-down situation. Most practical languages don’t go infinitely meta; they stop at one or two levels to keep our sanity. Swift is a statically typed language that rigorously defines what it means to talk about a type as a value. The term metatype in Swift is essentially the type of a type, a concept that comes from deeper ideas in type systems (like kinds in some functional languages or metaclasses in dynamic languages). Swift’s designers decided that if classes, structs, and enums are first-class citizens, then the blueprints for those entities should be first-class too – hence each type has a .Type representation. This is grounded in a long tradition of language design: for example, Smalltalk and Objective-C have metaclasses, and languages like Python treat classes as objects of type type. Swift formalizes this with static clarity: the language knows at compile time if you’re referring to a type itself versus an instance.

Why does Swift bother with separate metatype designators? It comes down to balancing a powerful type system with clarity and safety. Swift’s compiler needs to distinguish between talking about a type itself versus an instance of that type. In type theory terms, Swift keeps types and values in distinct universes but allows a bridge between them via metatypes. This prevents paradoxes and confusion you’d get if types were treated exactly like regular values without restriction. If you’ve heard of languages with dependent types or powerful reflection systems, they grapple with similar “type-of-type” questions. Swift’s solution might look a bit clunky (.Type and .Protocol suffixes), but it’s a pragmatic way to give developers access to meta-level information while keeping the compiler comfortable about what’s what. It’s a design compromise influenced by Swift’s goals of type safety and also by its need to interoperate with Objective-C’s runtime (where classes are objects). The result: a theoretically sound (if verbose) way to refer to types as values, which is catnip for language enthusiasts but often mind-bending for the uninitiated. When someone starts reciting the formal definition – “a metatype type refers to the type of any type…” – they’re invoking these deep principles of type systems. No wonder the listener’s reaction is a dumbfounded “What?” – we’re verging on the metaphysics of code here, and it’s genuinely tricky stuff!

Description

This is a five-panel meme using the 'Jesse what the fuck are you talking about?' format from the TV series Breaking Bad. In the first, third, and fourth panels, the character Jesse Pinkman is shown passionately explaining a concept, with superimposed text defining metatype types in Swift. The text reads: 'A metatype type refers to the type of any type, including class types, structure types, enumeration types, and protocol types. The metatype of a class, structure, or enumeration type is the name of that type followed by .Type. The metatype of a protocol type - not the concrete type that conforms to the protocol at runtime - is the name of that protocol followed by .Protocol.' In the second panel, the character Walter White looks back with a confused expression, saying, 'What?'. The final panel shows Walter's frustration culminating in the line, 'Jesse what the fuck are you talking about?'. The humor stems from using a dense, highly technical, and somewhat obscure programming concept (Swift's metatypes) as the subject of Jesse's monologue. It perfectly captures the feeling of being overwhelmed by jargon or an overly academic explanation, a scenario familiar to senior engineers when a colleague gets lost in the weeds of language-specific minutiae

Comments

15
Anonymous ★ Top Pick This is what happens when you let the intern who just finished a category theory course explain generics. You get the .Type, the whole .Type, and nothing but the .Type
  1. Anonymous ★ Top Pick

    This is what happens when you let the intern who just finished a category theory course explain generics. You get the .Type, the whole .Type, and nothing but the .Type

  2. Anonymous

    I use Swift metatypes as a circuit-breaker: the moment I mention that a protocol’s metatype is .Protocol, not .Type, every meeting trips and the bikeshedding load instantly drops to zero

  3. Anonymous

    The real metatype confusion happens when you realize Swift's .Protocol is basically explaining to the compiler 'No, I mean the existential type itself, not whatever concrete type will eventually show up at runtime' - which is exactly the kind of distinction that makes perfect sense after 15 years of wrestling with type erasure, but sounds like absolute gibberish to anyone who just wanted to know why their app crashed

  4. Anonymous

    When you try explaining Swift's metatype system to your tech lead who's been writing Objective-C since 2008, and they look at you like you just proposed rewriting the entire codebase in Haskell. 'Just use .self' they say, completely missing that you're trying to explain why `Encodable.Protocol` isn't the same as a concrete type conforming to `Encodable`. Sometimes the real type erasure is watching someone's understanding of your explanation disappear in real-time

  5. Anonymous

    Swift’s metatypes are where asking for P.Type means you actually wanted P.Protocol, a type-erased box, and a 400-line code review thread

  6. Anonymous

    Metaclasses: because classes alone couldn't spawn enough indirection to crash the architecture review

  7. Anonymous

    Swift onboarding speedrun: say 'Foo.self is Foo.Type, P.self is P.Protocol; instances are existential boxes' - if they’re still nodding, you just found your Staff iOS dev

  8. Deleted Account 4y

    Metaverse

  9. @Varty_G 4y

    Meth-atype

  10. @CVABIK 4y

    welcome in development for ios, we have Image, UIImage, CGImage, CIImage, also CAPreviewLayer, AVPreviewLayer, AVCaptureVideoPreviewLayer

    1. @sylfn 4y

      use english please

    2. @tedspikes 4y

      Honestly it's not that hard, once you get the hang of it. And AVFoundation can do a lot for you if you don't need to do something that's off the beaten path

  11. @Varty_G 4y

    Say what

  12. @sylfn 4y

    just rules. you can use russian, but there should be english text

    1. @CVABIK 4y

      ok, got it

Use J and K for navigation