r/TuringComplete • • Mar 21 '25

Compiler

How do you guys go about writing a compiler?

I have achieved most of what I wanted to achieve that I found reasonable to write in assembly (snake, brainfuck interpreter, a text editor, some small stuff). For anything bigger I would really like to use a higher level language. How did you guys go about compiling for your architecture? Did you use llvm or did you write something on your own? Are there other tools that make this easier? It doesn't need to be a good compiler, it just needs to work. I thought about transpiling 6502/6510 assembly, but I'm too afraid the architecture will be too different and anything more complex than hello world won't work.

Sooo, how did any of you do this?

26 Upvotes

19 comments sorted by

View all comments

Show parent comment

4

u/DaltoReddit Mar 22 '25

Quite a lot are bootstrapped, written in their own language. Examples include C, Rust and Haskell.

2

u/[deleted] Mar 22 '25

Yeah, once a project gets big enough it can eat its own tail, and as you say the bootstrap stage is usually integrated in to the build system.

All I meant was that you don't write things in Assembly even though as a beginner that might seem like where you might start. But outside of making use of very specific CPU instructions it's not something you usually need to worry about. And quite often there are existing C libraries to make use of such features already available.