It has been a while since I gave myself a nice challenge. Yesterday, I just watched Terry Davis explained his TempleOS compiler on Youtube and he inspired me. I love crazy people and this one just happened to be a schizophreniac! I could not have seen a better video.
Here is my goal. I want to build a fully functional compiler within a year. I never took any compiler course while I completed my degree so I decided to get Engineering a Compiler, Second Edition by Cooper and Torczon. I am a book nerd when it comes to learning computer related stuff. This will suits me well.
Here are goals for this:
– Have fun
– Learn new stuff
– Build a compiler for a real language
– Have the compiler build real nontrivial applications
Here are my non-goals:
– Source language completeness
– Optimized results
– Insanity (I’m looking at you Terry)
I now have to choose a source language I want to compile. I could create my own but that would be somewhat uninteresting. I am leaning towards C since it has a good standard, it most likely have some good test cases and test suites and it already have a good amount of working compilers to compare it with. I am still undecided.
I want to see quick working results so I think I am going to use LLVM intermediate representation for the target language but I will check for other alternatives as well. I might have multiple backends and I might get my hands dirty with code generation for x86-64 if I want to have more fun. It will depends on how motivated and how much time I want to invest in this.
I am going to use Python as the language for this project. Python is fun, easy to use, runs everywhere and it has a great community. I already know Python very well. Python might not be the fastest language out there but speed is not one of my goal.
Let me know if you have tips for me!