Martijn Faassen looks back on six years of Rust and the habits it changed. The compiler’s restrictions pushed him to rethink domain models, data ownership and the costs hidden inside familiar abstractions. Those habits carry beyond Rust.

  • Model the actual variants. Enums, types that hold one of several named alternatives, let each case carry its own data. Exhaustive matching makes the compiler flag missing cases when a new variant arrives.
  • Make abstraction earn its keep. A closed set of variants may need only an enum. Designing an extensible interface adds work that pays off when outside implementations really need to plug in.
  • Use types to think. Like tests and documentation, types expose gaps in an API while you design it. Faassen describes an iterative process of revisiting all three as understanding improves.
  • Make ownership explicit. Separating construction and mutation from later use can reduce hidden connections between components. Local code may become harder to read while the larger data flow becomes clearer.
  • Store related data together. In his mutable XML library, Faassen uses an arena: nodes stored together, linked by indexes. Parent and child links can coexist without reference-counting cycles, while contiguous storage helps the CPU cache.
  • Choose when work happens. Serde and clap use macros to generate serialization and command-line parsing code during compilation. Declarative convenience can survive without runtime inspection of types.

Performance also changes the architecture you consider possible. Faassen points to his Colchis experiment, which keeps large amounts of JSON in memory with indexed access. Lower resource costs opened a design he previously would have overlooked.

He also acknowledges the price: generic types can become overwhelming, and optimization can become a distraction. Learning Rust gave him more choices, along with more responsibility for deciding which costs matter.