I did a short survey of #compiler backends: https://abhinavsarkar.net/notes/2025-compiler-backend-survey/
#compilers #programming #pldev #langdev #blogging
#compilers #programming #pldev #langdev #blogging
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 did a short survey of #compiler backends: https://abhinavsarkar.net/notes/2025-compiler-backend-survey/
#compilers #programming #pldev #langdev #blogging
#compilers #programming #pldev #langdev #blogging
real talk, part of the reason that yuri has a social media account before its compiler is so I can get feedback on the language as a whole. i'm not an expert at graphics programming, at pldev, or really at anything and I want to make something that people will actually want to use.
October 31, 2025 at 5:31 AM
real talk, part of the reason that yuri has a social media account before its compiler is so I can get feedback on the language as a whole. i'm not an expert at graphics programming, at pldev, or really at anything and I want to make something that people will actually want to use.
yuri is finally becoming real !!! super excited to be working on this, it's my first proper foray into pldev and I'm excited to be off to a good start. there will be frequent writeups which I will publish as I make them
imagine GLSL but with Rust-like syntax, a module system, and a compiler that fits in your workflow. that's what we're going for.
October 26, 2025 at 4:07 AM
yuri is finally becoming real !!! super excited to be working on this, it's my first proper foray into pldev and I'm excited to be off to a good start. there will be frequent writeups which I will publish as I make them
I’m tempted to write my programming language with a simplified ohm grammar engine, so that you can extend the language directly.
ohmjs.org/docs/syntax-...
#PLdev #KonaScript
ohmjs.org/docs/syntax-...
#PLdev #KonaScript
Syntax Reference | Ohm
This document describes the syntax of the Ohm language, which is a variant of parsing expression grammars (PEGs). If you have experience with PEGs, the Ohm syntax will mostly look familiar, but there ...
ohmjs.org
August 29, 2025 at 12:27 PM
I’m tempted to write my programming language with a simplified ohm grammar engine, so that you can extend the language directly.
ohmjs.org/docs/syntax-...
#PLdev #KonaScript
ohmjs.org/docs/syntax-...
#PLdev #KonaScript
After several rewrite, and the implementation of a typed AST (instead of having to evaluate any expression at least twice), I added imports (or "remixes") of Miku lang files. I need to think about other languages (i.e. C lib for instance) now #PLDev
August 13, 2025 at 1:07 AM
After several rewrite, and the implementation of a typed AST (instead of having to evaluate any expression at least twice), I added imports (or "remixes") of Miku lang files. I need to think about other languages (i.e. C lib for instance) now #PLDev
Just one more compiler...
I've made a language based on music (because Hatsune Miku) but it's basically Java in a trench coat.
and I've implemented enough to be able to write small programs. #PLDev gist.github.com/minirop/061a...
I've made a language based on music (because Hatsune Miku) but it's basically Java in a trench coat.
and I've implemented enough to be able to write small programs. #PLDev gist.github.com/minirop/061a...
Code in Miku lang, generated C and output
Code in Miku lang, generated C and output. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
August 7, 2025 at 9:53 PM
Just one more compiler...
I've made a language based on music (because Hatsune Miku) but it's basically Java in a trench coat.
and I've implemented enough to be able to write small programs. #PLDev gist.github.com/minirop/061a...
I've made a language based on music (because Hatsune Miku) but it's basically Java in a trench coat.
and I've implemented enough to be able to write small programs. #PLDev gist.github.com/minirop/061a...
I started working on a small programming language that compiles to Lua so that I can work on a Play date game.
I didn’t have to start from scratch! I had written quite a bit las year when working on Kona. #PLdev
I didn’t have to start from scratch! I had written quite a bit las year when working on Kona. #PLdev
August 7, 2025 at 9:18 AM
I started working on a small programming language that compiles to Lua so that I can work on a Play date game.
I didn’t have to start from scratch! I had written quite a bit las year when working on Kona. #PLdev
I didn’t have to start from scratch! I had written quite a bit las year when working on Kona. #PLdev
New Bismuth VM blog post, detailing the life cycle of a hello world program for Bismuth from high level Bronze code to text-based IR, transpiled C, binary IR, and finally bytecode: enikofox.com/posts/hello-...
#BismuthVM #PLDev
#BismuthVM #PLDev
'Hello world' in Bismuth
This is the third in a series of posts about a virtual machine I’m developing as a hobby project called Bismuth. I’ve talked a lot about Bismuth, mostly on social media, but I don’t think I’ve done a ...
enikofox.com
July 31, 2025 at 3:49 PM
New Bismuth VM blog post, detailing the life cycle of a hello world program for Bismuth from high level Bronze code to text-based IR, transpiled C, binary IR, and finally bytecode: enikofox.com/posts/hello-...
#BismuthVM #PLDev
#BismuthVM #PLDev
now that handle pinning is implemented in my VM i can use it to speed up my VM's blit routine
this is Bronze code, which is converted to my VM's intermediate representation, which is then transpiled to C so i can integrate it into my VM :3
and now the core of my VM is finally done! \o/
#PLDev
this is Bronze code, which is converted to my VM's intermediate representation, which is then transpiled to C so i can integrate it into my VM :3
and now the core of my VM is finally done! \o/
#PLDev
July 29, 2025 at 12:00 PM
now that handle pinning is implemented in my VM i can use it to speed up my VM's blit routine
this is Bronze code, which is converted to my VM's intermediate representation, which is then transpiled to C so i can integrate it into my VM :3
and now the core of my VM is finally done! \o/
#PLDev
this is Bronze code, which is converted to my VM's intermediate representation, which is then transpiled to C so i can integrate it into my VM :3
and now the core of my VM is finally done! \o/
#PLDev
VM development update: I have done a bunch of rewriting to make things more secure and also have now paved the way for types larger than 32 bits
#PLDev
#PLDev
July 25, 2025 at 4:57 PM
VM development update: I have done a bunch of rewriting to make things more secure and also have now paved the way for types larger than 32 bits
#PLDev
#PLDev
suppose i should do an update here on my VM. it now has try/catch/finally with a fixed format for exception objects which are automatically freed when leaving the catch block
if i can get handle locking/pinning in so i can have direct safe access to pointers i will consider the core done
#PLDev
if i can get handle locking/pinning in so i can have direct safe access to pointers i will consider the core done
#PLDev
July 23, 2025 at 10:31 AM
suppose i should do an update here on my VM. it now has try/catch/finally with a fixed format for exception objects which are automatically freed when leaving the catch block
if i can get handle locking/pinning in so i can have direct safe access to pointers i will consider the core done
#PLDev
if i can get handle locking/pinning in so i can have direct safe access to pointers i will consider the core done
#PLDev
If you're getting into #PLDev and writing parsers the first thing you should know is that doing everything in a single pass is fucking hard. Parsing an AST and Doing multiple passes over that (resolving symbols, guaranteeing return values, type checking) is like a bazillion times easier
June 27, 2025 at 11:02 AM
If you're getting into #PLDev and writing parsers the first thing you should know is that doing everything in a single pass is fucking hard. Parsing an AST and Doing multiple passes over that (resolving symbols, guaranteeing return values, type checking) is like a bazillion times easier
thinking about my #PLDev project. i was gonna make it like C, but now i'm thinking since i have a reusable IR and VM so multiple languages can easily target it, maybe my first language should hew closely to the actual IR?
so i can write "raw" IR but without the lots of parentheses of s-expressions
so i can write "raw" IR but without the lots of parentheses of s-expressions
June 27, 2025 at 9:05 AM
thinking about my #PLDev project. i was gonna make it like C, but now i'm thinking since i have a reusable IR and VM so multiple languages can easily target it, maybe my first language should hew closely to the actual IR?
so i can write "raw" IR but without the lots of parentheses of s-expressions
so i can write "raw" IR but without the lots of parentheses of s-expressions
making good progress on my parser, and now i'm thinking of committing some crimes >:3
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
#PLDev
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
#PLDev
June 24, 2025 at 7:25 PM
making good progress on my parser, and now i'm thinking of committing some crimes >:3
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
#PLDev
that being having both `and` and `&&`, and `or` and `||`, where the latter coerces to bool and the former does not and acts like lua >_>
#PLDev
okay, got basic expressions going. a little slower going than i'd like since i'm adapting the crafting interpreters code to C# and building an AST of nodes instead of emitting single pass bytecode
#PLDev
#PLDev
June 22, 2025 at 3:55 PM
okay, got basic expressions going. a little slower going than i'd like since i'm adapting the crafting interpreters code to C# and building an AST of nodes instead of emitting single pass bytecode
#PLDev
#PLDev
For my next #compiler project, I want to write the optimization passes myself, but I don't want to deal with generating machine code for multiple platforms. So tell me #programminglanguages #plt #compilers fedi, what is an IR that I can target that has a non-optimizing compiler to machine code […]
Original post on fantastic.earth
fantastic.earth
June 17, 2025 at 2:30 AM
For my next #compiler project, I want to write the optimization passes myself, but I don't want to deal with generating machine code for multiple platforms. So tell me #programminglanguages #plt #compilers fedi, what is an IR that I can target that has a non-optimizing compiler to machine code […]
the dev is a physicist who posts bait about pldev on twitter, i wouldn't keep my hopes up
May 13, 2025 at 1:34 PM
the dev is a physicist who posts bait about pldev on twitter, i wouldn't keep my hopes up
My programming language *Xenon* now has a website!
xenonlanguage.github.io
Check it out!
#programming #website #xenon #language #pldev #hashtag #okillstop
xenonlanguage.github.io
Check it out!
#programming #website #xenon #language #pldev #hashtag #okillstop
Xenon
xenonlanguage.github.io
March 21, 2025 at 7:17 PM
My programming language *Xenon* now has a website!
xenonlanguage.github.io
Check it out!
#programming #website #xenon #language #pldev #hashtag #okillstop
xenonlanguage.github.io
Check it out!
#programming #website #xenon #language #pldev #hashtag #okillstop
Idk if Jai is included in this conservative pldev industrial complex, but it is so weird seeing tech influencers glaze the language made by a guy born in 71 who had "naysayer88" as his twitch handle and was regularly getting glazed by gamergaters for being "based" (mysogynistic)
February 18, 2025 at 10:11 AM
Idk if Jai is included in this conservative pldev industrial complex, but it is so weird seeing tech influencers glaze the language made by a guy born in 71 who had "naysayer88" as his twitch handle and was regularly getting glazed by gamergaters for being "based" (mysogynistic)
Work continues on the self-hosted implementation. A good chunk of the typechecking is done and am currently working on compilation to a linear IR that uses different basic blocks per function but is not on an SSA form. Trying to keep things simple for now.
#PLDev #Badlang
#PLDev #Badlang
February 6, 2025 at 12:58 PM
I decided to give QBE (c9x.me/compile/) a shot for real and as a small codegen backend it's nice. This is a small code that compiles and the generated assembly. #PLDev #compiler
January 27, 2025 at 10:04 PM
I decided to give QBE (c9x.me/compile/) a shot for real and as a small codegen backend it's nice. This is a small code that compiles and the generated assembly. #PLDev #compiler