I really enjoyed reading this. It's informative, fun, and has a refreshingly honest tone. Too often, stories passed around by computer scientists entail clever solutions and elegant insight striking the protagonist like lightning in the hour of need. Rarely does the programmer express regret, make self-corrections, and confront fear and doubt along the way:<p>>I should have written beautiful code from the beginning, but because I needed to learn by writing a working code, the rewriting was unavoidable.<p>>I should probably change my mind to implement all the features from end to end. I may find it fun as I'm approaching the goal. Sometimes, I have to write more code than I want to write in order to achieve a goal.<p>>In a tough situation like this, I probably should recall the fact that the compiler was just in one file, to see how much progress I've made in a month. It just reads an integer with scanf() and prints it out with printf(). Really, I made so much progress in one month. Yeah, I think I can do this.
> I suspect that he [Dennis Ritchie] invented a syntax, wrote code for it, which turned out to be more complicated than he had expected. And that was eventually standardized by the ANSI committee. It's hard to implement a standardized language because you have to get everything right. It's rather easy to write your own toy language.<p>Love those lines
Interesting, and quite funny to read with a sense of humour that reminds me of the movie PI. The author of the compiler goes from rational to something more... spiritual.<p>"Day 52<p>I was looking for a mysterious bug for three days: ..."<p><a href="http://www.imdb.com/title/tt0138704/" rel="nofollow">http://www.imdb.com/title/tt0138704/</a>
I was a little surprised that the author was able to manage both C11 and the preprocessor in that time. The preprocessor is hard. But there was existing code from a previous version of it, which makes sense. Still, a fantastic achievement! Congrats to the author!
Thought this was going to be an inspiration to me to continue with my pet project of writing my own little programming language. But it starts off on day 8 with him already having written a basic compiler, with no explanation of how he did any of the basics. Still interesting, just not what I thought it was.
Honestly, the most difficult, time consuming, and mundane aspect to this project would have to be the parser, which was apparently written in C by hand. So bravo.<p>Getting to some of the final notes:<p>> ... I'd choose a different design than that if I were to write it again. Particularly, I'd use yacc instead of writing a parser by hand and introduce an intermediate language early on.<p>That's why I found the LALRPOP post by one of the Rust developers interesting. Writing your own parser generator is actually much easier than writing a parser by-hand (depending on the complexity of the language, here not that complex and still difficult), and I think it's more instructive than using a free or open parser-generator or compiler compiler. The downside is that it is less practical, because almost none of the important aspects of language implementation involve the parser.
For anyone interested in compiler writing and looking for a good resource to start, probably one of the best is the "Dragon Book":<p><a href="http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811" rel="nofollow">http://www.amazon.com/Compilers-Principles-Techniques-Tools-...</a><p>I highly recommend it, but it's <i>heavy</i> stuff. There are probably simpler guides out there that just cover the basics.
This is really interesting, and I was glad to see the author go beyond just the stated 40 days and give insight into where they went after it was 'self-hosting.'
Anyone tried using it? How do I use it to generate executable (as per the code it should fork the 'as')?<p>Getting following error:
[ERROR] main.c:144: (null): One of -a, -c, -E or -S must be specified<p>-c, -E and -S are working fine. Couldn't figure out from code what -a does.
Self-hosting is pointless. Go has it--who cares. I wrote a program 1000x faster than the ruby one (at work) with zero bugs in Go, but I still don't want to use it(Go). Java is fine. Do I care if Java is self-hosting? No. I'll do (another) language in Javacc (my first one is still awesome) or ANTLR.