C isn't bad. It's shaped our modern world, and one of the most direct ways we can communicate with our hardware - it's effectively the modern day's assembly. We owe a great deal to the many engineers who've had the discipline to write it 1978-style for decades.
C has live wires hanging out of the ceiling, and you have to hand-crank the shower to get nice cold well water.
Instead of moving house or bulldozing our home, what if we could just... not let the live wires hang out of the ceiling? Tuck them away. Cap them properly?
This is the theme of Prism. It's a transpiler that aims to make marginal improvements over time - taking small steps to improve our real-world codebases and projects with realistic, pragmatic changes.
Evolved out of building a build tool for a game engine, comes Prism. A classic scratching-your-own-itch type of deal, but with the right kind of feature creep and slight insanity that reshaped its original goal into: safer & a bit more sane C, today.
The biggest challenge of being a programmer is being human. You're not just juggling what you want to implement, but all the other factors in your life that flush your cache faster than your manager's ability to assign you tickets.
One of the first features was defer - Go-style. Manual cleanup branches are one of those things that really add to the mental overhead of writing pure C, and a big bug source. It requires a fair bit of mental work to track cleanup paths, not to mention the added resistance to adding new features.
Defer was quite the challenge to get started with. It's a critical feature that just can't ever fail, and as a parsing transpiler without an AST, even harder. Prism evolved quite a bit to find the sweet spot of being robust and fast. Initially Prism was a single-pass control flow analysis of your code — today it's two passes: one where we build a static snapshot, and a second where we emit code.
Prism has now grown into having defer, orelse, zero-init, runtime bounds checking, and build system features.
You'd be surprised by what compounding small improvements can do. It's filing away at the anxiety of writing C. It's making C enjoyable - the home you'd always secretly loved.
Many languages that try to be a better C really aren't - they're their own languages, and that's fantastic, but not actually C. I find either the authors had too many strong opinions, or moved too quickly.
With Prism, a core objective is to ship reasonable defaults and let you dial in exactly what you want - or opt out of anything that conflicts with your requirements.
All features of Prism are opt-out. No question.
I see a modern C on the horizon. Something we don't have to fight, nor be anxious about. It's an effort the standards committee just can't do - and we have decades of tooling and code that can't just go away. It's a mature, robust asset with the largest mind share on the planet. We should leverage what we have today, for a better tomorrow.
Prism is still early. A lot of work goes into finding the most obscure and darkest corners of C and testing rigorously. It turns out parsing a language with 50 years of warts is a hard one — but well worth it.
If you find Prism useful, please star it on GitHub, leave feedback, or consider sponsoring the effort. Any feedback is genuinely appreciated.
— Dawn