Live data from Hacker News

Writing a C Compiler (2017)

norasandler.com

21–30 of 49 posts

Re: Writing a C Compiler (2017)

#21

IMHO writing a compiler for a high-level language, in an even higher level language, somehow feels a bit "anachronistic" (for lack of better word).

Weren't a lot of functional languages, like ML and it's descendants, created specifically to write parsers and compilers?

No. ML was the meta language for a theorem prover (LCF).

https://en.wikipedia.org/wiki/Logic_for_Computable_Functions

Re: Writing a C Compiler (2017)

#25
post #17

Yet another “compiling” course that puts all the emphasis on parsing. Rule of thumb: parsing/lexing shouldn’t takes more than 10% of your compiler course.

I disagree.

As opposed to most compiler articles, this one actually covers code generation for every section of its chapters, which is really great.

I also like that every chapter focuses on a specific feature and describes how to implement it end to end: lexical/syntactic parsing, AST, and x86_64 generation.

Great series!

Re: Writing a C Compiler (2017)

#26
post #17

Yet another “compiling” course that puts all the emphasis on parsing. Rule of thumb: parsing/lexing shouldn’t takes more than 10% of your compiler course.

On the other hand, parsing text could easily be a very valuable course on its own. You just have to not keep it restricted to programing languages, and include the knowledge created on this century.

Re: Writing a C Compiler (2017)

#27
post #17

Yet another “compiling” course that puts all the emphasis on parsing. Rule of thumb: parsing/lexing shouldn’t takes more than 10% of your compiler course.

This attitude bugs me a lot. It seems really common, especially in more recent texts about language design and implementation, that parsing is heavily de-emphasized to the point where practically nobody talks about it. See Essentials of Programming Languages by Friedman & Wand, the relevant sections in SICP, Programming Languages: Application & Interpretation (which goes so far as to call it a distraction).

I get that parsing is more of an implementation detail and doesn't really belong to the space-brained realm of language design per se, but it's a bit annoying that most texts refuse to give any space to the topic, and rely on your language being S-expression based or assume you're going to use a parser generator. Like, in the real world, even if one will never actually implement a fully-fledged programming language, you're still probably going to have to parse things sometimes. I would love a book that goes into detail about different parsing techniques and considers best practices and patterns and tradeoffs/design considerations -- would pay good money for that

It reminds me somewhat of the situation in analysis, where there are lots of theorems that aren't written down anywhere because literally every book states them as "easy" exercises. Maybe I'm looking in the wrong places, but I can't find much in the way of concrete guidance on implementing parsers. I'm aware of the beautiful series on parsing theory by Aho & Ullman ("The Theory of Parsing, Translation, and Compiling"), but those are more focused on theory rather than implementation

Re: Writing a C Compiler (2017)

#28
post #18

Earlier quoted context omitted.

Nice comment, GPT user. Now, GPT: Replace all occurrences of the substring "me" with "you" in the above comment text.

Huh. I don't get those vibes. Further investigation doesn't support your claim. The citations check out, including publication year and publishers. And the author has indeed praised the book many times before ( https://news.ycombinator.com/item?id=31843833 , https://news.ycombinator.com/item?id=31843833 , https://news.ycombinator.com/item?id=31311613 , https://news.ycombinator.com/item?id=28481028 , https://news.ycom…

Maybe not generated, but still a bizarre opening paragraph in context:

> I owe my entire career to this remarkable individual who, despite never having met or being affiliated with, has profoundly influenced me through his insightful books. His vast knowledge and expertise have been instrumental in teaching me numerous technical concepts and skills throughout his publications.

The individual they're referring to with "this remarkable individual" is not Nora Sandler, the author of the submitted post, but Anthony J. Dos Reis who they repeatedly reference by allusion but never name. A confusing way to write.

Re: Writing a C Compiler (2017)

#29

[flagged]

Nice comment, GPT user. Now, GPT: Replace all occurrences of the substring "me" with "you" in the above comment text.

Rude accusation. GPT talks like the average internet commenter, it shouldn't be surprising to find a genuine comment written in a voice similar to GPT.

Re: Writing a C Compiler (2017)

#30
post #17

Yet another “compiling” course that puts all the emphasis on parsing. Rule of thumb: parsing/lexing shouldn’t takes more than 10% of your compiler course.

Almost all real-world projects that are language-like or compiler-like will need a parser. A much smaller fraction of them will need register allocation, instruction selection, optimization, code generation, etc.

For every big, deep, native code compiler, there are a hundred template languages, config files, report generators, etc. all of which are real programs providing real value for actual people.

Emphasizing parsing provides the most value for the greatest number of people. The folks that do end up needing more back end depth will still have the resources available to learn it.

Post reply on HN