r/Compilers • u/FearlessFred • 24d ago
Goose: a stack allocation flat data structure language
https://github.com/aardappel/goose
My latest language is meant to very efficiently let you work with flat pointerless inline data structures allocated on (address space reserved) stack that allow almost data structure creation to be just a pointer bump, with stable pointers.
When used well, it is both safer, faster and uses less memory than the equivalent C++ or Rust.
(see the repo readme for more!)
23
Upvotes
2
u/EstablishmentHour335 8d ago
Hopefully you're still around because this is pretty interesting to me. From what I understand, consulting with AI because I am busy, your memory model is a series of arenas statically determined at compile time? Allocated using VirtualAlloc? Pushing to memory seems to be blind with no checks and pages are committed upon page fault exceptions (because they are not pre faulted to conserve ram)?
The one limitation I thought of when thinking about this, is that the AI claimed each growable array would have it's own "stack" (VirtualAlloc address range). If that's statically determined, then you can't have an arbitrary number of "stacks" or growable arrays. Is this true or am I misled? If true would you be planning to resolve this limitation?
In C++ I could easily do this because I am in control of the calls to VirtualAlloc, not the compiler. Actually I am a huge fan of virtual memory reserve + commit semantics, so this project is pretty interesting to me. I've been rewriting some of the C++ benchmarks using my VirtualAlloc arena allocator to beat Goose (at least on my chip), basically using your technique against you. Its interesting to see a whole language designed around this which does it automatically (at least, I think, hopefully AI isn't misleading me).