Hacker News new | ask | show | jobs
by lucrbvi 38 days ago
I really like QBE but I hope they will make it a true library because I don't want to launch a subprocess to compile a program.
4 comments

This is exactly my gripe unfortunately, it feels like needless fragility. IIRC the author has said they believe it wouldn't be too difficult to patch QBE to work as a library, but from what I've seen the code is somewhat terse and eccentric.
There is a library conversion fork: https://github.com/sgraham/sqbe.

IMO when the intended usage is AOT with an external assembler, which is another subprocess, text-based IO is actually the more natural approach.

There are at least 2 Go libraries written in Go, based on QBE. One is used by this project: https://github.com/xplshn/gbc
Why not? Processes are cheaper than you might think. GCC invokes several as an example.
Because this concept only works for offline compilers, but not for dynamic languages. It's about 100x slower.

I'm just converting the call to an external assembler in my compiler rcc to assemble the bytes directly. No need for strings and external files. The cost of the external call is outrageous.

Tangentially: Is there a Rust alternative similar to this?