My Memory Model Wishlist for Conjure
I’ve been building a programming language for game developers for a while now called Conjure. When designing a programming language, the most consequential decision you make is the memory model. Games1 sit in an awkward spot as they need predictable frame times, they live and die by cache locality, and they often can’t tolerate a garbage collector pausing the world in the middle of a frame.
I want Conjure to be safer than C and (ideally) without paying for that safety with the runtime overhead of a garbage-collected, complexity of automatic reference-counting, and explicit ceremony that makes Rust a pain for iterative development.
I’d also love the ability to use Conjure for real systems work, including embedded targets and kernel-level code. This quickly rules out anything with a heavy runtime or unpredictable allocation behavior.
The goal of this article is to be the first in a series where I think out loud about possible memory models and approaches to the language design. This first one is intended to establish a set of loose requirements and a “wish list” for the language2.
- Fewer allocations is better. The fastest allocation is the one you never make, so I lean hard on arena and pool allocation as the default. A memory model that fights that style is one I’ll resent.
- Cache locality is a critical constraint. Most of the “make it fast” work in game code is really “stop chasing pointers around the heap.” Anything that fattens my pointers or scatters my data starts from behind.
- I don’t want to rent my memory safety. A few percent of every frame, forever, is a price I’d rather not pay, and on a microcontroller there often isn’t a few percent to spare.
- It should stay approachable. Someone coming from C# or Unity shouldn’t need deep expertise in lifetimes to write a level loader, even though I also want the language to scale down to a bootloader.
- Should still allow for great interop with C. Conjure’s ability to natively link against C ABI compliant libraries has been a huge selling point for myself and others I’ve told about the language.
- Developer experience is still a critical consideration. This means maintaining a fast compiler with a responsive language server (and accurate) language server.
- Ideally retain some level of compiler simplicity. I was unsure if I should merge this into the previous point, as complexity is often the enemy of performance, but it can also be the enemy of accuracy. So that’s why it’s listed here as its own bullet point.
I have a number of considerations and experiments I’ve been attempting over the past few months and will attempt to regurgitate my findings throughout this set of articles. We’ll try to keep these wishlist items in mind as we weigh out the possible models we can employ.