Hello everyone,
As some of you might know, I recently worked on phpurs and gopurs. Building these backends has been an incredible journey, but it also highlighted some hard boundaries. Specifically, gopurs showed me the limits of Go when it comes to implementing advanced memory management techniques like Perceus and FBIP (Functional But In-Place), inspired by Koka/Lean.
I am currently in a sabbatical phase of my career, without an official position, and I am ready to invest the time to create pure tools that will sustainably serve the ecosystem. I absolutely love PureScript, and I believe it deserves the best tools.
Looking at the current landscape, the planets are perfectly aligned to attempt something experimental but ambitious: a native Rust backend: purust.
Here is why I think the timing is right:
- PureScript is strict: Unlike Haskell, PureScript’s strict evaluation makes it the perfect candidate for Perceus-style static Liveness Analysis.
-
The
backend-optimizeris proven: Having a flattened, uncurried, and optimized AST ready to be consumed removes the heaviest burden of writing a backend. - TASTs are available: Having the type information attached to the CoreFn is the missing piece of the puzzle. Still local (on my computer), but completely unlocked the perfs on the Go compiler.
-
The
Valuearchitecture worked:gopursproved that dynamically managing Boxed vs. Unboxed data structures works well. In Rust, we can take this even further. - AI accelerates the process: Today’s AI tools allow us to iterate, prototype, and test complex compiler ideas much faster than before.
At first glance, Rust might seem like a hostile target. The Borrow Checker, lifetimes, and the heaviness of standard Rc or Arc seem to clash with massive graph sharing and closures. However, the initial roadblocks for phpurs and gopurs also seemed insurmountable at first, yet they were overcome. By generating highly specific unsafe Rust code encapsulating a custom PerceusBox, we can bypass the Borrow Checker entirely and leverage LLVM’s raw power.
I love mathematics, and in math, we know that when abstract shapes seem to fit together, even from a distance, intuition is often the only argument that leads us to incredible new territories. That’s how I feel today, thinking about this potential PureScript-to-Rust compiler.
Engineering often begins with a dream, much like reading Jules Verne before building the submarine.
I am currently working on the foundations of this project. The repository will be made public soon, provided that the initial proofs of concept, facts, and benchmarks prove the architecture is credible.
It is absolutely worth a try. In the worst-case scenario, I will potentially save time for anyone else who might have the same idea, by explaining and documenting the limits of this exercise.
At best, a whole new avenue of joy opens up for PureScript.