the smorgasbord logo

the smorgasbord

Subscribe
Archives
December 11, 2020

Swanson programming language framework

Hello friends!

There are a couple of new posts on my blog about Swanson, a programming language framework I've been noodling around on for a number of years. Over time I've become enamored with a couple of ideas in particular — linear continuations and compile-time execution — that I think can form the simple basis for a large number of "real" PL features.

Compile-time execution is something that Zig is looking at these days, and there's an interesting claim / hypothesis that you can build a surprisingly large number of features on it — including, among others, type-parameterized generics and conditional compilation.

While others are looking at compile-time execution, I haven't seen much attention given to linear continuations. This would combine linear typing with a continuating-passing style intermediate language. We already know that linear types give you a nice way of modeling resource management — for instance, a memory allocation function might return the new memory region as well as a deallocation callback. If the type of the deallocation callback is linear, you are obligated to call it once and exactly once, ensuring both that the memory is eventually freed, and that it can't be double-freed. By extending that linearity to the continuations themselves, we get similar guarantees about particular regions of code being executed exactly once, while still giving the programming control over when they're executed.

Together, I think these two building blocks can bring us to a world where our compilers aren't wizards performing magic on our behalf, but instead clerks who keep track of the books and otherwise get out of our way — while still having the same kinds of safety guarantees and language ergonomics that a good compiler gives you.

Anyway, who knows if this approach, or language, will ever take off. Even if it doesn't, I've had fun playing around with it, and thought it would be fun to share the ideas with others! Take a look at the first few posts and let me know what you think.
  • Introduction
  • Execution model
  • S₀, the "assembly language"
cheers
–doug
Don't miss what's next. Subscribe to the smorgasbord:
This email brought to you by Buttondown, the easiest way to start and grow your newsletter.