News for hackers. Stuff that matters.
Re:Lessons from Writing a Compiler by astrange on Thursday July 14, 2022 @07:32PM (#32102631)
The article says exactly what I'd say. It spends far too much time explaining the frontend (parsing theory) which isn't the difficult or important part of the compiler, and it somehow makes it sound scary and mathematical.

The rest isn't covered enough and doesn't have enough practical real-world advice.

Re:Lessons from Writing a Compiler by necheffa on Thursday July 14, 2022 @07:44PM (#32102722)
As someone who has had to clean up (with backwards compatibility) after people who YOLO'd custom grammars rather than actually taking the time to respect the mathematics of parsing and design ambiguity out up front...

I cannot disagree with you more.

Re:Lessons from Writing a Compiler by astrange on Thursday July 14, 2022 @07:51PM (#32102785)
I mean, I think you should read a book on parsing theory, just not that one. I like "Parsing Techniques: A Practical Guide" but there might be a newer better one.

But clang and gcc both have handwritten recursive-descent parsers for C/C++. (C++ parsing of course is undecidable, or at least used to be.)

Re:Lessons from Writing a Compiler by samatman on Thursday July 14, 2022 @11:11PM (#32104205)
C++ parsing being undecidable, and C having the Most Vexing Parse, are the classic arguments for developing a grammar using a parser generator, and only when the grammar is mature, write a handrolled implementation using the grammar as a reference.

I happen to think generating useful software from declarative grammar specifications is, hmm. Not limited to what such frameworks have been capable of to date. Although if you've only worked with yacc/bison, and never ANTLR, you may be underestimating the quality of a generated parser with respect to error recovery and messages. The state of the art has advanced, I don't think anyone would claim parity with artisanal handcrafted softwares, but we can get a lot more than "barf: shift-reduce bunchanumbers" these days.

Re:Lessons from Writing a Compiler by zabzonk on Thursday July 14, 2022 @11:30PM (#32104310)
> and C having the Most Vexing Parse

C++ too. Just to be pedantic.

Re:Lessons from Writing a Compiler by dgunay on Friday July 15, 2022 @12:16AM (#32104558)
I can echo this sentiment. Last year I took a course for my master's where we implemented a compiler end to end. The dragon book helped for most of it but when it came time to implement the assembler we were unable to get it completely correct and the book was very scant on any information about how to best manage going from virtual to physical registers, handle storing information on the stack, etc. Granted some of that is platform specific but the difference in material from frontend to backend was stark.
Re:Lessons from Writing a Compiler by mhh__ on Friday July 15, 2022 @02:22AM (#32105202)
Parsing is also about 1% of the effort for a mature frontend.

Books do not cover how to actually structure a compiler and write sensible passes etc.

Re:Lessons from Writing a Compiler by oxff on Friday July 15, 2022 @07:58AM (#32107190)
Frontend is very important if you want your language to have good IDE tooling (which most languages do not have)