JuliaCon 2025

Understanding Your Struct Toolbox
2025-07-24 , Main Room 4

At first blush, Julia structs may seem to just be a named data container we use for dispatch. However, structs do far more than just contain data. This talk explores tools available to make your structs more feature rich, providing a checklist of potential features to benefit your types. These tools range from simple type equality to tricks with mutable structs beyond mutation. In addition to enumerating these tools, we provide code samples which demonstrate proper implementation.


Writing Julia is often a back-and-forth between designing structs to represent a problem and then implementing methods for these structs to solve the problem. At a glance, a these structs appear to be a fancy container with named fields: a special NamedTuple that is easy to dispatch on.

This talk takes a deeper view of structs as the language we use to describe problems, a utility for understanding our code, and a tool for implementing complex features beyond immutable NamedTuples.

Specifically, we highlight common useful interfaces to implement for structs that enable higher order behavior. These interfaces include understanding struct equality, or identifying what goes into implementing an iterable object. We demonstrate best practices for improved type introspection via custom struct printing, and tools for writing these introspection methods.

Finally, we emphasize the difference between mutable and immutable structs. The syntax of mutable structs suggests only a difference in the mutability of constituent fields. However, we demonstrate features which are only available to mutable structs, even when all fields are marked as immutable.

Sam is a Julia developer who is enthusiastic about converting long-shot ideas into production-grade systems. His work spans from differentiable physics to renewable energy optimization, and he brings experience taking scientific solutions into industrial-scale and cloud-based production.

Currently, Sam is the founder of G2I Computing LLC where he offers expertise developing scientific software. Previously, he has worked as a research software engineer at Metalenz on optical design problems, and as a member of technical staff at LeafLabs producing neuroscience research tools. He holds degrees in electrical engineering from the University of Illinois and MIT.