I’ve tried several times to write blog posts about Lattice, and each time I’ve gotten lost in the weeds. It’s hard to pick a point to start. So

Lattice now compiles to .NET IL

submited by
Style Pass
2024-04-01 07:30:04

I’ve tried several times to write blog posts about Lattice, and each time I’ve gotten lost in the weeds. It’s hard to pick a point to start. So instead, I’ve resolved to just start writing — quantity over quality, as they say.

Lattice has met a major milestone this week: programs now fully compile to .NET IL! If you’ve never written a programming language before, this may not mean much to you, but there’s something beautiful about seeing a relatively complex program compile down into flat assembly instructions.

I’m very proud of this work. One of the goals of the Lattice project was to design a visual language that could compile down into fast linear code — effectively just the procedural code that you would write if you were coding it by hand. This is very much inspired by Rust’s tradition of “zero-cost abstractions”. With the new compilation pipeline, the node-graph representation is stripped away entirely. Outputs of nodes become local variables and bodies of nodes become plain static methods.

C# is a sloppy thing to generate. There are a lot of syntactical concerns you get bogged down in just trying to get something valid.

Leave a Comment