4 ms·
Alternatively: Understanding C by writing a compiler.
by stcredzero 12y ago
Alternatively: Understanding C by writing a compiler.
- tptacek 12y agoStrong agree. Everyone should do this at least once in their career.
- jwdunne 12y agoWhat resources would you recommend to get started with?
- daj40 12y agoThe "Dragon Book" is pretty solid and a widely accepted resource: http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniqu...
- wglb 12y agoOne of the authors of the Rosalyn compiler has a different opinion: https://news.ycombinator.com/item?id=5149315 https://news.ycombinator.com/item?id=5149315. And he gives some examples of much better books. It used to be good, but it is not any longer thought of that way.
- tptacek 12y agoI think you'll learn more from porting a simple C compiler than you will from any compiler book, at least given a fixed amount of time to do either task in.
- wglb 12y agoThis book, http://www.amazon.com/Compiler-Generator-Automatic-Computation-McKeeman/dp/0131550772 http://www.amazon.com/Compiler-Generator-Automatic-Computati..., which by today's standards is not a very good book, got me started in my compiler career. And I agree with your basic point that building one is the only to gain true understanding.
- nickpsecurity 12y agoIf I was going academic and imperative language, I'd suggest this old paper written by The King of Simple Languages and Compilers: http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
- tptacek 12y agoVery easy: port c4.c to a new language.
- jwdunne 11y agoThis is great. I'll have to brush up on my C too to port. Two birds, one stone :) thank you!
- peterfirefly 11y agohttp://compilers.iecc.com/crenshaw/ http://compilers.iecc.com/crenshaw/ https://news.ycombinator.com/item?id=1727004 https://news.ycombinator.com/item?id=1727004 https://code.google.com/p/letsbuildacompiler/ https://code.google.com/p/letsbuildacompiler/ (It looks like there are several more or less complete C versions.) http://linker.iecc.com/ http://linker.iecc.com/ http://www.iecc.com/linker/ http://www.iecc.com/linker/
- jonsen 12y agoWrite a C compiler in assemby?
- wglb 12y agoOnce done by the author of MicroEMACS when he was bringing up the C compiler on the pdp-11.