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).
Most of the current major C implementations are written in C++.
Writing a C Compiler (2017)
41–49 of 49 posts
Re: Writing a C Compiler (2017)
#42Earlier quoted context omitted.
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.
No, you are being rude. To the average internet commenter. Or maybe to GPT. ;-)
By bringing down either one of them to the level of the other.
Unless you meant "average" in the same sense as this short tale:
A statistician had his head in a fridge and his feet in an oven, and when asked how he felt, he said, "on the average, I feel quite comfortable".
Re: Writing a C Compiler (2017)
#43Earlier quoted context omitted.
For what reason?
It's backwards. Writing a C compiler in C or Asm makes sense, a Python compiler in C also does, but a C compiler in Python is an odd inversion of abstraction.
Re: Writing a C Compiler (2017)
#44Earlier 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…
All the best.
Digitally signed, Your soon-to-be GPT overlords.
Re: Writing a C Compiler (2017)
#45Earlier quoted context omitted.
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)
#46Earlier quoted context omitted.
For what reason?
It's backwards. Writing a C compiler in C or Asm makes sense, a Python compiler in C also does, but a C compiler in Python is an odd inversion of abstraction.
But these days we can access dozens of languages on many platforms. And we can use high-level languages that are good for writing compilers—languages with good string types and algebraic data types—instead of being limited to awfully imperative/procedural ones.
In other words: your perspective sounds way more anachronistic.
Re: Writing a C Compiler (2017)
#47Earlier quoted context omitted.
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 par…
Do you have a ‘best of list’ for the resources when interested in back-end topics.
Re: Writing a C Compiler (2017)
#48Yet 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 par…
Everybody and their dog thinks it necessary to inflict some new sub-par language on us when in about 99.9% of cases they should just either have stuck to s-expressions or some suitable subset of a popular programming or existing config language with a relatively sane syntax (blaze/bazel did that right, cmake did that very very wrong).
When was the last time you looked at some config file and thought, wow I'm so glad they didn't use toml or python or whatever, but instead made up some completely new syntax nothing in the world apart from this tool itself can parse and that I can't programaticaly manipulate?
When was the last time you thought, wow I am so glad that someone invented a new templating language that creates some new injection vulnerabilities, because no one apart from the lisp people ever seem to have worked out that if you want to interpolate into something tree shaped, you should have a tree-based interpolation syntax? Because although sexps and quasiquote solve this very nicely and concisely everyone else still seems to love string-bashing plus some ad-hoc "escaping" system for this. And one reason for this is of course precisely the enormous abundance of idiotic config languages that can't be easily manipulated as anything than opaque strings.
[Edit: if you do create a new config file language, pretty please provide some means to directly query and losslessly manipulate it; for the lossless part you will either need to have first class comments unambiguously attached to a particular syntactic construct and agreed upon deterministic formatting or IDE-style complexity, the first one is probably a better idea]
Re: Writing a C Compiler (2017)
#49Earlier quoted context omitted.
I've seen it claimed that ML was originally written, in lisp, in order to have a better language to write compilers in.
ML was written as the language used by the theorem prover LCF. It was written in Lisp.
The LCF style provers rely on the host language type system. A theorem instance can only be created by the trusted kernel. Lisp doesn't obviously lend itself to that - you could represent the proof, but I'm not clear how you'd prevent forging one.