Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In 2023, does anyone who writes a compiler inherently have to know assembly?

Or even less recently...whoever wrote the first Rust, Zig, or insert <new compiled language> here?

Because don't you ultimately have to know how to make your own syntax translate into efficient assembly code?

Or is there someway these days for programming language designers/creators to avoid it entirely?



Compiler writers can target high-level languages too; it's not uncommon to see e.g., a Blub-to-C compiler which leaves the asm parts to a different toolchain. (Lots of languages without the goal of producing native code target even higher-level languages, for example JS.)

Another popular way to _sort of_ avoid assembly is to target the LLVM IR (intermediate representation), in which case LLVM takes care of optimization and producing processor-specific machine code for a bunch of CPU types. But LLVM IR is basically a fancy assembly language.


Llvm abstracts the "backend" which generates the actual assembly for each target machine. You only have to write a "frontend" that generates an llvm intermediate representation.

But in general, yes. To generate assembly you need to know assembly.


Is LLVM sufficiently "simpler" to learn and wield than assembly, or does it just make it easier to compile to different systems?


LLVM is definitely more complex than a toy assembly you might learn in an intro computer architecture course, but it's generally somewhat less complex than working with real assembly languages. Although the complexity in LLVM is a very different kind of complexity from assembly languages; LLVM is ultimately a higher-level abstraction than machine code, and the semantics of that abstraction can be complex in its own right.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: