#LangDev
A Short Survey of Compiler Backends
As an amateur compiler developer, one of the decisions I struggle with is deciding choosing the compiler backends. Unlike the 80’s when people had to target various machine architectures directly, now there are many mature options available. This is a short and very incomplete survey of some of the popular and interesting options. ### Contents 1. Machine Code / Assembly 2. Intermediate Representations 3. Other High-level Languages 4. Virtual Machines / Bytecode 5. WebAssembly 6. Meta-tracing Frameworks 7. Unconventional Backends 8. Conclusion ## Machine Code / Assembly A compiler can always directly output machine code or assembly targeted for one or more architectures. A well-known example is the Tiny C Compiler. It’s known for its speed and small size, and it can compile and run C code on the fly. Another such example is Turbo Pascal. You could do this with your compiler too, but you’ll have to figure out the intricacies of the _Instruction set_ of each architecture (ISA) you want to target, as well as, concepts like register allocation. ## Intermediate Representations Most modern compilers actually don’t emit machine code or assembly directly. They lower the source code down to a language-agnostic _Intermediate representation_ (IR) first, and then generate machine code for major architectures (x86-64, ARM64, etc.) from it. The most prominent tool in this space is LLVM. It’s a large, open-source compiler-as-a-library. Compilers for many languages such as Rust, Swift, C/C++ (via Clang), and Julia use LLVM as an IR to emit machine code. An alternative is the GNU C compiler (GCC), via its GIMPLE IR, though no compilers seem to use it directly. GCC can be used as a library to compile code, much like LLVM, via libgccjit. It is used in Emacs to _Just-in-time_ (JIT) compile Elisp. Cranelift is another new option in this space, though it supports only few ISAs. For those who find LLVM or GCC too large or slow to compile, minimalist alternatives exist. QBE is a small backend focused on simplicity, targeting “70% of the performance in 10% of the code”. It’s used by the language Hare that prioritizes fast compile times. Another option is libFIRM, which uses a graph-based SSA representation instead of a linear IR. ## Other High-level Languages Sometimes you are okay with letting other compilers/runtimes take care of the heavy lifting. You can transpile your code to a another established high-level language and leverage that language’s existing compiler/runtime and toolchain. A common target in such cases is C. Since C compilers exist for nearly all platforms, generating C code makes your language highly portable. This is the strategy used by Chicken Scheme and Vala. Or you could compile to C++ instead, like Jank, if that’s your thing. Another ubiquitous target is JavaScript (JS), which is one of the two options (other being WebAssembly) for running code natively in a web browser or one of the JS runtimes (Node, Deno, Bun). Multiple languages such as TypeScript, PureScript, Reason, ClojureScript, Dart and Elm transpile to JS. Nim interestingly, can transpile to C, C++ or JS. A more niche approach is to target a Lisp dialect. Compiling to Chez Scheme, for example, allows you to leverage its macro system, runtime, and compiler. The Idris 2 and Racket use Chez Scheme as their primary backends. ## Virtual Machines / Bytecode This is a common choice for application languages. You compile to a portable bytecode for a _Virtual machine_ (VM). VMs generally come with features like _Garbage collection_ , _JIT compilation_ , and security sandboxing. The Java Virtual Machine (JVM) is probably the most popular one. It’s the target for many languages including Java, Kotlin, Scala, Groovy, and Clojure. Its main competitor is the Common Language Runtime, originally developed by Microsoft, which is targeted by languages such as C#, F#, and Visual Basic.NET. Another notable VM is the BEAM, originally built for Erlang. The BEAM VM isn’t built for raw computation speed but for high concurrency, fault tolerance, and reliability. Recently, new languages such as Elixir and Gleam have been created to target it. Finally, this category also includes MoarVM—the spiritual successor to the Parrot VM—built for the Raku (formerly Perl 6) language, and the LuaJIT VM for Lua, and other languages that transpile to Lua, such as MoonScript and Fennel. ## WebAssembly WebAssembly (Wasm) is a relatively new target. It’s a portable binary instruction format focused on security and efficiency. Wasm is supported by all major browsers, but not limited to them. The _WebAssembly System Interface_ (WASI) standard provides APIs for running Wasm in non-browser and non-JS environments. Wasm is now targeted by many languages such as Rust, C/C++, Go, Kotlin, Scala, Zig, and Haskell. ## Meta-tracing Frameworks _Meta-tracing Frameworks_ are a more complex category. These are not the backend you target in your compiler, instead, you use them to build a custom JIT compiler for your language by specifying an interpreter for it. The most well-known example is PyPy, an implementation of Python, created using the RPython framework. Another such framework is GraalVM/Truffle, a polyglot VM and meta-tracing framework from Oracle. Its main feature is zero-cost interoperability: code from GraalJS, TruffleRuby, and GraalPy can all run on the same VM, and can call each other directly. ## Unconventional Backends Move past the mainstream, and you’ll discover a world of unconventional and esoteric compiler backends. Developers pick them for academic curiosity, artistic expression, or to test the boundaries of viable compilation targets. * Brainfuck: An esoteric language with only eight commands, Brainfuck is _Turing-complete_ and has been a target for compilers as a challenge. People have written compilers for C, Haskell and Lambda calculus. * Lambda calculus: Lambda calculus is a minimal programming languages that expresses computation solely as functions and their applications. It is often used as the target of educational compilers because of its simplicity, and its link to the fundamental nature of computation. Hell, a subset of Haskell, compiles to Simply typed lambda calculus. * SKI combinators: The SKI combinator calculus is even more minimal than lambda calculus. All programs in SKI calculus can be composed of only three combinators: S, K and I. MicroHs compiles a subset of Haskell to SKI calculus. * JSFuck: Did you know that you can write all possible JavaScript programs using only six characters `[]()!+`? Well, now you know. * Postscript: Postscript is also a Turing-complete programming language. Your next compiler could target it! * Regular Expressions? Lego? Cellular automata? ## Conclusion I’m going to write a compiler from C++ to JSFuck. If you have any questions or comments, please leave a comment below. If you liked this post, please share it. Thanks for reading!
abhinavsarkar.net
November 5, 2025 at 11:17 AM
I'm having so much fun with this stupid little language and interpreter I've made.

#langdev
October 7, 2025 at 4:16 AM
Why save a peice of text multiple times, when you can save it once and point to it instead?

I finally got this working today!! I've had the outline there for ages, but finally added the actual check - which wasn't easy.

github.com/Ratstail91/Toy

#coding #langdev #toylang
GitHub - Ratstail91/Toy: The Toy Programming Language.
The Toy Programming Language. Contribute to Ratstail91/Toy development by creating an account on GitHub.
github.com
February 8, 2025 at 6:49 AM
It must suck to be a rust langdev because on one hand you have like C programmers complaining that the language is too restrictive for real systems code, and on the other you have the type theory crowd saying unwrap and escape hatches are a moral injustice and you're just stuck in the middle
June 15, 2025 at 2:15 PM
its funny how much i wanna do langdev and yet never got far enough to build a proper parser because i consider all current parser paradigms just... bad
March 26, 2025 at 6:51 PM
começando a escrever um pratt parser pra expressoes
#rust #langdev
September 14, 2024 at 2:09 AM
lately im making a little programming language! the goal is to target the simplest* bytecode VM imaginable. (plt and langdev ppl come find meee)

will continually update a little thread of code snippets and goals
November 7, 2024 at 8:32 AM
It took a bit, but 'break' and 'continue' keywords are working & tested!

It's not exactly easy, when you're jumping around in memory - you need to be super thorough when looking for issues, because the VM will simply keep reading garbage, thinking it's code.

#coding #langdev #toylang
GitHub - Ratstail91/Toy: The Toy Programming Language.
The Toy Programming Language. Contribute to Ratstail91/Toy development by creating an account on GitHub.
github.com
December 30, 2024 at 6:06 AM
Assignment within an array is working - even within nested arrays! It's not easy to get fundamental features working, but it's slowly getting closer to my goal.

#toylang #langdev #coding

github.com/Ratstail91/Toy
December 7, 2024 at 4:44 AM
as a langdev tool i'm not super familiar, but i can see how it can be extremely useful for prototyping. the fact that you can import packages across languages (ish, kinda, it depends) is really cool as well
May 14, 2025 at 11:37 AM
Really enjoyed this last year, and Durham in March is a delight, strong recommend if you have any interest that overlaps with asd and langdev! #devpsych
ICYMI. . .more info and call for abstracts now available at molautism.org
September 26, 2023 at 2:38 AM
Wishing you and your loved ones a jolly holiday season, from everyone at the SFU LangDev Lab.

See you in 2025!
December 20, 2024 at 3:23 PM
Fascinating langdev Stack Exchange answer to the question of if it's possible to formalize the "expressivity" of a programming language, using the work of Matthias Felleisen.

langdev.stackexchange.com/a/2016
How can we compare expressive power between two Turing-complete languages?
Is this possible? Is there an accepted (and unambiguous) notion of "expressive power" that could differ between two different Turing-complete languages? It seems like, for example, Python...
langdev.stackexchange.com
January 3, 2025 at 10:50 AM
Functions are successfully called.

No return statement or tests yet, but it's time for a break.

I'm happy now, even if today is a hard day.

#gamedev #langdev #coding #toylang

github.com/Ratstail91/Toy
GitHub - Ratstail91/Toy: The Toy Programming Language.
The Toy Programming Language. Contribute to Ratstail91/Toy development by creating an account on GitHub.
github.com
February 17, 2025 at 3:11 AM
the three genders are langdev, gamedev, and B2B SaaS
February 18, 2025 at 4:18 PM
Do you like games?

Do you like modding?

Do you like games with modding?

I'm building a scripting language to enable easy modding, and I'm gonna build a roguelike with it!

Come check it out, and drop me a follow!

#gamedev #langdev #toylang #roguelike

toylang.com
The Toy Programming Language
toylang.com
February 28, 2025 at 9:35 AM
How difficult would it be to add actual default argument values to functions in C? #langdev
September 2, 2025 at 8:26 PM
also that gamedev is much more on the software engineering side of the field, whereas langdev leans more towards the theoretical side. bridging the gap is complicated, and people with anti-intellectual streaks tend to ignore the gap entirely
February 23, 2025 at 5:26 PM
Yay! I put off the break & continue keywords for a bit, but I didn't really need to. Still, it gave me time to think on it.

I'll need to write a proper disassembler soon.

#coding #langdev #toylang
December 29, 2024 at 11:00 PM
Hah! I love it!

On a slightly related note, I remember discussions on conlang and langdev about gender-neutral lexical and grammatical matters (pronouns, suffixes, etc.), probably 25 years ago. Maybe earlier.

(These were mailing lists for people who make up languages.)

Fun stuff!
April 14, 2025 at 1:05 AM
The long season of langdev https://lobste.rs/s/xecakg ##plt
The long season of langdev
blog.fogus.me
August 20, 2025 at 2:20 AM
In case you missed it: Toy now has unofficial support for NetBSD, thanks to NishiOwO!

While not covered by CI, the newly added code is quite minimal, so it should work with little effort. I might even look into custom runners at some point.

#coding #langdev #toylang

github.com/Ratstail91/Toy
GitHub - Ratstail91/Toy: The Toy Programming Language.
The Toy Programming Language. Contribute to Ratstail91/Toy development by creating an account on GitHub.
github.com
February 8, 2025 at 8:29 PM
this is 400x langdev alice you just wouldn't get it 🙄
February 17, 2025 at 8:17 PM
“The Long Season Of Langdev”, Michael Fogus (blog.fogus.me/langdev/long...).

Via Lobsters: lobste.rs/s/xecakg/lon...

#ProgrammingLanguages #PLDI #LangDev #Programming
The long season of langdev
blog.fogus.me
August 24, 2025 at 6:44 AM
BragelsonLab Time:
catch BLABers Genia Lukin(poster already happened but she'll recap if u ask!), Lilli Righter (poster tmrw!), & (alum)Erin Campbell (talk tmrw!) at #MPaL ! All looking at diff. aspects of langdev in young blind kiddos: input quant/content, morpho/vocab.
#MPI #PsychSciSky #DevPsych
October 25, 2023 at 4:50 PM