qbe-rs
Befunge
Our great sponsors
qbe-rs | Befunge | |
---|---|---|
29 | 5 | |
64 | 18 | |
- | - | |
3.3 | 3.5 | |
7 months ago | 6 months ago | |
Rust | JavaScript | |
GNU General Public License v3.0 or later | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
qbe-rs
-
Odin Programming Language
> I think it uses a different backend than LLVM
harec uses https://c9x.me/compile/
-
Frontend for GCC?
Have you considered QBE?
-
Toy C compiler, worth having an IR stage?
I really liked targetting QBE (https://c9x.me/compile/) as an IR, as it gave me lots of back-end optimisations for free 😊.
-
C or LLVM for a fast backend?
There is: QBE.
-
Made my first LLVM front-end… Now what?
You can try buildling you own backend like llvm. A good example or starting point is probably QBE since it is extremely small but very functional.
- Best book on writing an optimizing compiler (inlining, types, abstract interpretation)?
-
Rust port of B3 from WebKit, LLVM-like backend
How big is the whole backend? I've heard that it is small but I wanted to compare it to QBE which is around 8 KLoC and it is quite interesting too.
-
Few lesser known tricks, quirks and features of C
I think QBE might be what you're looking for?
-
Do you consider LLVM a complicated software? And are there any alternatives and how they compare to LLVM?
As far as I know, there is QBE, which is actually kinda underrated, and Cranelift, mainly designed for JIT compilation
Before that, I had spent a bit of time working with QBE, which is much simpler and really easy to write a frontend for. I switched to libgccjit though, because I got frustrated with a few of the things lacking from QBE (like the ability to easily keep track of where different variables live on the stack). I think for many hobby language projects, QBE would be a good option (my project was off the ground very fast using QBE, and I got pretty far before I ran into limitations I couldn't easily work around).
Befunge
-
The Rust Performance Book
1. C compilers don't do a good job, & thus even CPython, which has historically stuck to rather vanilla C, uses computed goto, as described in https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e...
I resorted to similar techniques in optimizing Befunge: https://github.com/serprex/Befunge (See bejit.c & marsh.c/marsh.h)
2. Rust enums are not variable sized, think of them as tagged C unions, where the Rust compiler can sometimes apply tricks to make Option> the same size as Vec
3. match can specialize for straight forward cases, when in doubt use https://godbolt.org
- Ask HN: Recommendation for general purpose JIT compiler
-
Why asynchronous Rust doesn't work
I've found async to be straight forward anytime I've used it. Promise#then is equivalent to callbacks
async/await often requires very little changes compared to synchronous code, whereas reworking a program into callbacks is much more impactful. & the async/await compilation process tends to produce better performance in addition to this. My first async/await work was a few years ago to increase a data importer's performance by an order of magnitude compared to the blocking code
Here's an example where looping made for a callback that recursively called, using async/await I get to use a plain loop:
before: https://github.com/serprex/Befunge/blob/946ea0024c4d87a1b75d...
after: https://github.com/serprex/Befunge/blob/9677ddddb7a26b7a17dd...
I don't see why people find it so complicated to separate begin-compute & wait-on-compute
I've since rewritten a nodejs game server into rust, https://github.com/serprex/openEtG/tree/master/src/rs/server... handleget/handlews are quite straight forward
- Python interpreter written in rust reaches 10000 commits
-
Compilers Are Hard
You'll also find them used in CPython's ceval.c
I use them in both my C befunge implementations:
https://github.com/serprex/Befunge/blob/c97c8e63a4eb262f3a60...
https://github.com/serprex/Befunge/blob/c97c8e63a4eb262f3a60...
What are some alternatives?
ubpf - Userspace eBPF VM
minivm - A VM That is Dynamic and Fast
mir - A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
wasmtime - A fast and secure runtime for WebAssembly
well - The Future of Assembly Language. https://wellang.github.io/well/
c4 - C in four functions
Rustler - Safe Rust bridge for creating Erlang NIF functions
Som - Parser, code model, navigable browser and VM for the SOM Smalltalk dialect
cproc - C11 compiler (mirror)
rune - An embeddable dynamic programming language for Rust.
openEtG