3 ms·
> Most graduates of Computer Science programs can, perhaps with some trouble, implement a half decent C compiler in a weekend or two. Probably not. Compiler de
by deaddodo 3y ago
> Most graduates of Computer Science programs can, perhaps with some trouble, implement a half decent C compiler in a weekend or two.
Probably not. Compiler design (lexical+syntactical analysis and code generation) isn't covered by most basic CS bachelor's programs.
Theoretically, a CompSci graduate should be able to reference the necessary materials, ingest the theory and make a basic multipass, non-optimizing C compiler. But I would still be skeptical of a good chunk of recent (as in, lack of experience; not year of graduation) graduates; and would assume that it would take >4 days ("two weekends").
- armchairhacker 3y agoI took a compilers class in undergraduate. We read Appel's Modern Compiler Implementation in ML (https://www.cs.princeton.edu/~appel/modern/ml/ https://www.cs.princeton.edu/~appel/modern/ml/) and built a compiler for the Tiger language (basically https://github.com/FlexW/tiger-compiler https://github.com/FlexW/tiger-compiler but in SML). We covered the main chapters but not the advanced topics. If you look at the TOC (https://www.cs.princeton.edu/~appel/modern/toc.html https://www.cs.princeton.edu/~appel/modern/toc.html) you can get an idea of the necessary steps: - Lexing - Parsing - Symbol table generation - Type checking - IR - Some static analyses (e.g. liveness) - Some optimizations (e.g. constant folding) - Assembly generation - Register allocation Me and my 1 group-mate had a working compiler at the end. It took a whole semester, sure I was taking other classes and doing other things, but it certainly took more than 2 weekends worth of work (maybe if you count raw hours, 96 in total...).