Mehdi Akiki

Writing archive

Everything published under Writing, newest first. Each entry is labelled as part of an investigation, an article or reference. Short engineering notes have their own archive.

  • Published on

    Investigation · Part 4 of 10 · Types under the hood

    Shape Without Behavior: Two Structs With the Same Fields

    A Point and a Vector with the same two fields: TypeScript accepts one for the other, Rust refuses, and on this build the bytes and the instructions are identical, to the point that the optimized build keeps one function body under both names. The difference is a rule about names, and the name leaves no trace in the program.
  • Published on

    Investigation · Part 3 of 10 · Types under the hood

    A Type Is a Set: Why Human Has Two Members and Option of Human Has Three

    If a type is a set of allowed values, you can count its members. I counted fourteen Rust types and asked the compiler how many bytes each one needs. The size follows the count, with two exceptions I measured, the exhaustiveness error is arithmetic, and a type with zero members costs zero.