I appreciate how wonderfully simple and dependency free this is. More often than not people just want to write a compiler of sorts without bison or yacc, or LLVM, and just convert expressions into assembler or vm-like instructions that _just run_. This is a great starting point for that, and I wish I had something like it 10 years ago. (Crenshaw's Let's Build a Compiler is an excellent source too if you want to go on…
I’d argue that you should start with doing an interpreter and push it as long as you can. But once you’re ready to generate code, use llvm or something like that because you are going to hit very problematic roadblocks early in your effort that will kill your interest in compilers otherwise. Some examples are: ensuring you can compare expressions for equality, ensuring that changed expressions don’t violate dominance…
TinyCompiler: A compiler in a week-end
111–120 of 120 posts
Re: TinyCompiler: A compiler in a week-end
#112Earlier quoted context omitted.
We agree on a lot of things, but QBE is off the table. Complexity and kloc are loosely correlated. Cranelift and libfirm are of equivalent size while Cranelift is in Rust and has wonderful compiler engineers working on it. https://c9x.me/git/qbe.git/tree/rega.c QBE is a one person performance art project.
This code looks a lot like the Unix V6 kernel code or the source code to Steve Johnson's pcc C compiler. It's indeed too sparsely commented, but it's not as bad as you made it sound.
Re: TinyCompiler: A compiler in a week-end
#113I appreciate how wonderfully simple and dependency free this is. More often than not people just want to write a compiler of sorts without bison or yacc, or LLVM, and just convert expressions into assembler or vm-like instructions that _just run_. This is a great starting point for that, and I wish I had something like it 10 years ago. (Crenshaw's Let's Build a Compiler is an excellent source too if you want to go on…
Not to take away from the author or you, but we had things like this 10 years ago https://github.com/ymyzk/tinyc/tree/master/tinyc
Re: TinyCompiler: A compiler in a week-end
#114https://pikuma.com/courses/create-a-programming-language-com...
Re: TinyCompiler: A compiler in a week-end
#115I'm aware people here frown upon paid content but I am currently taking this course and it's excellent: https://pikuma.com/courses/create-a-programming-language-com...
Re: TinyCompiler: A compiler in a week-end
#116Earlier quoted context omitted.
Not to take away from the author or you, but we had things like this 10 years ago https://github.com/ymyzk/tinyc/tree/master/tinyc
Unless I am mistaken, this uses LLVM?
Re: TinyCompiler: A compiler in a week-end
#117Earlier quoted context omitted.
Not to take away from the author or you, but we had things like this 10 years ago https://github.com/ymyzk/tinyc/tree/master/tinyc
Unless I am mistaken, this uses LLVM?
https://github.com/ymyzk/tinyc/blob/master/tinyc/generator/n...
Re: TinyCompiler: A compiler in a week-end
#118I appreciate how wonderfully simple and dependency free this is. More often than not people just want to write a compiler of sorts without bison or yacc, or LLVM, and just convert expressions into assembler or vm-like instructions that _just run_. This is a great starting point for that, and I wish I had something like it 10 years ago. (Crenshaw's Let's Build a Compiler is an excellent source too if you want to go on…
I’d argue that you should start with doing an interpreter and push it as long as you can. But once you’re ready to generate code, use llvm or something like that because you are going to hit very problematic roadblocks early in your effort that will kill your interest in compilers otherwise. Some examples are: ensuring you can compare expressions for equality, ensuring that changed expressions don’t violate dominance…
Re: TinyCompiler: A compiler in a week-end
#119Earlier quoted context omitted.
I have the greatest respect for Prof. Kernighan, but history hasn't been kind to C's unbounded arrays and strings, however convenient they may be for the programmer. Moreover, just two years after his critique, Turbo Pascal would come out with an environment that is still revered as a pioneering and exceptionally productive IDE. It outsold C compilers by multiple orders of magnitude in the mid-1980s. (And that's igno…
Turbo Pascal wasn't just a good tool, it was a pioneer in how it was marketed and priced. It was relatively affordable, only $49, at a time when tools generally cost in the hundreds. And they ran monthly ads in nearly every computer magazine. If you wanted to hack on things on your PC, and you didn't already work for a company that would buy you to tools, you really had two choices, BASIC and Turbo Pascal.
Re: TinyCompiler: A compiler in a week-end
#120I've been a big fan of the author's tiny renderer. Nice to see a tiny compiler too!
That sounds interesting! He seems to have four tiny renderers pinned on his GitHub page; is https://github.com/ssloy/tinyrenderer the one you're recommending? What do you like about it?