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.
How I wrote a self-hosting C compiler in 40 days
91–100 of 128 posts
Re: How I wrote a self-hosting C compiler in 40 days
#92What do you mean, "as a child"?
The parent poster is suggesting advent calendars are used most often by children. This is true around my area
Re: How I wrote a self-hosting C compiler in 40 days
#93Earlier quoted context omitted.
Jack Crenshaw, of "Let's Build A Compiler" fame, has an interesting critique of works like these: http://compilers.iecc.com/crenshaw/tutor8.txt The main point for our discussion is last: > Desire for Generality > We have been concentrating on the use of a recursive-descent parser to parse a deterministic grammar, i.e., a grammar that is not ambiguous and, therefore, can be parsed with one level of lookahead. > In pra…
May of these issues are still relevant to embedded systems with limited resources.
Re: How I wrote a self-hosting C compiler in 40 days
#94Honestly, 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. Getting to some of the final notes: > ... 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. That's why I found the LALRPOP pos…
This is completely contrary to my experience, in which parser generators have not paid for themselves. Writing a parser by hand in C is generally easier and less time-consuming over the long run than struggling along with a parser generator, especially if you have any interest in producing useful syntax error messages or recovering from other kinds of errors in some useful way. I agree that almost none of the importa…
https://github.com/gregtour/parsergenerator
Most of the C code is less than 1.5k LOC for the functional part, and this minimal, self-compiling C compiler has a parser that is nearly 3,000 lines long.
Even if it took 1,000 lines of extra code for the non-LR aspects of C's grammar, I think it would be the same amount of work.
This just leaves you in a better position to write a C++, Go, or Java compiler at the end.
Re: How I wrote a self-hosting C compiler in 40 days
#95Earlier quoted context omitted.
There's quite a few decent alternatives. I often suggest Wirth's Compiler Construction and Oberon sources because they're straightforward lessons plus give experience with Wirth style of simple, safe, efficient languages. Then, they can improve the Oberon System or compilers for personal projects and improvement. That said, I typically recommend compilers get written in an ML or LISP given it's so much easier to do i…
I definitely agree with ML and OCaml, but why do you recommend Lisp for compiler work? I love working withs Lisps, but how do you deal with dynamic typing bugs in compiler work? I prefer OCaml/Haskell/ML for its really strong static type checking for compiler work. Just curious though...
See a relevant discussion here from not long ago:
Re: How I wrote a self-hosting C compiler in 40 days
#96Earlier quoted context omitted.
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
Please could you recommend an alternative?
The dragon books are better used as references to those who are already familiar with all of the high-level concepts in compiler writing.
Re: How I wrote a self-hosting C compiler in 40 days
#97Earlier quoted context omitted.
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
I wouldn't go so far to say that the Dragon Book is outdated and irrelevant. (I'm assuming you're referring to the 2nd edition from 2006.) Unless you're focusing on back-end optimization and code generation techniques (something a new compiler writer typically does NOT do), the bulk of the theory and material you'd cover in a first semester compiler course is fairly static. But if a person is merely looking to bang o…
As for parsing, as I already said elsewhere in this thread, all the techniques from Dragon Book are not practical any more and are not used in the modern compilers. There are far better ways, which are not covered in the book, and they're far simpler, not even deserving a dedicated book at all.
Re: How I wrote a self-hosting C compiler in 40 days
#98Re: How I wrote a self-hosting C compiler in 40 days
#99I 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!
Out of curiosity - why do you consider cpp particularly hard? It's easier than the compiler, actually :)
Re: How I wrote a self-hosting C compiler in 40 days
#100Earlier quoted context omitted.
The parent poster is suggesting advent calendars are used most often by children. This is true around my area
And I think the person you responded to is implying his exit from childhood did not in any way slow down his use of advent calendars for chocolate-eating purposes.