Introduction to Compilers and Language Design (2021)
www3.nd.edu
www3.nd.edu
I see that not even in modern books things like PEG parser or Pratt parsing make the cut. Which is a pity IMHO. As an aside I am yet to find a great book/resource of garbage collectors that I can understand. It is such a fascinating subject!
If you want to dive into compiler/interpreters but do not want to go straight into the computer science of it I wholeheartedly recommend:
https://compilerbook.com and https://interpreterbook.com
And, of course, the incomparable book by Robert Nystrom "Crafting Interpreters""
Practical Compiler Construction (http://t3x.org/reload/index.html)
Write your own Compiler (http://t3x.org/t3x/book.html)
Both written by me.
What I also like is that if you find errata, you have a place to send them, with a reasonable expectation that they will be picked up in a new version.
I don't follow your rationale. With C the developer manages heap memory by basically calling malloc and free.
This means that once you have the memory model set, all you need to do to roll your compiler is to implement the interface.
A language that "don't require it themselves" is a language which provides only high level constructs and dumps all the memory management logic to the compiler/runtime, from object allocation/deallocation to lifetime management.
How is that simpler to pull off by a compiler writer?
Even if you can write a compiler assuming infinite memory that generates programs that also assume it, it would be a disservice to readers to ignore that for brevity. It's an important part of understanding how programs are created.
Another good idea is to write a compiler in the target language.
That's why I'd like to use a language that I already know instead of learning a new one while also learning new material.
What did you have in mind?
What stops you from understanding the idea by reading C? It's a tried-and-true language whose K&R version fits entirely in an easy to read ~180pg book which has real world applications, unlike pseudocode.
C is fine, it's just not ideal for me to learn C which I have no use for and learn a new skill at the same time.
But you do have a need for it, because it’s the lingua franca of conversations about compilers and interpreters… as you’ve just found out with this course.
Like saying you want to work in the Vatican but you have no need for Latin.
There are many materials, compilers, and interpreters that use ocaml and haskell, for example. C isn't the only one. That's why I'd prefer pseudo code instead of C, so that I could use this book without learning a specific language only for it.
Compilers and interpreters, unless they're running on bare metal, which is very niche, talk to the operating system using something called 'system calls' to ask for resources that they can't provide themselves, like virtual memory space and IO. These system calls are documented in C.
For example I wrote a Ruby compiler in Ruby, but I still need to know about the mmap system call, which is documented in C, to allocate my memory.
https://github.com/chrisseaton/rhizome/blob/main/doc/memory....
https://man7.org/linux/man-pages/man2/mmap.2.html
https://github.com/chrisseaton/rhizome/blob/main/lib/rhizome...
Sure, but the compiler will still have to generate machine code for those.
Maybe... MAYBE you don't have to read this book.
Where did I say I have to read it or that the author should learn another language? Nowhere. I said I wish it wasn't using C so that I could read it more easily.
I feel like I have an interest in it, but I'm having a hard time figuring out _why_ I find it so appealing. I know the why doesn't matter as long as I enjoy it, but I'm curious what others think.
From chaos, order emerges, and a well-designed language is the medium through which you draw out that order (of course, libraries, frameworks, DSLs also a part of that story, but the language is the "base", and thus the most impactful in doing so). Languages also have the most potential for a small simplification to produce massive results, as it cascades through the other semantics and into the libraries and ecosystem. Of course, language changes also have the most potential to fuck everything up, but that's why one should always strive to avoid putting it into production, or really ever just using it period, if you want to enjoy the making of the thing.
It's also kind of exciting to bootstrap a machine as well. For example going from bare metal to a C compiler to a Linux kernel to being able to browse the web.
It's also nice to be able to understand a system from the device physics level up to the user interface (and maybe beyond into networked/distributed as well as sociotechnical systems.)
I like it when something goes from being mysterious magic to a familiar tool. (Like compilers.) And it's even more fun when you can use your tools and knowledge to create some new useful or beautiful (or both) thing with them.
I would say the best part about this book is the author made it freely available. But if I had to choose a newish compilers book I’d choose Crafting Interpreters, which is also available for free.
One thing that I don’t like so much is the word “design” in the title, as there’s really not much content in the book on how to design a language; most of it is devoted to implementing an already designed language. I’m not sure anyone who learns from this book would be able to design a language unlike C.
Same thing applies to certain types of website. A CS professor and textbook author that has the time / interest to make their website "well designed" isn't covered in grease. The 90s DIY HTML adds to the credibility.
In reality, mechanics do book keeping, track inventory, take order, organize excel files, and ask customers to sign contracts just like any other business. Thus their front ends look just like any other.
> A CS professor and textbook author that has the time / interest to make their website "well designed" isn't covered in grease.
They could just drop it in a well designed template.
Also the idea that aesthetics and engineering cannot be conjoined is disproved in both Ferraris and 3D graphic programming.
The CVS had a waiting room too until Covid.
Sorry it doesn't use enough frameworks or wizbang scroll-hijacking flyovers or email-harvesting popups, but it conveys everything I want to know quickly and efficiently and distraction-free. In recent memory this is the fastest I've found a "download PDF" button. By far.
That leapt out at me too. Pretty sad it's so rare that it stood out so starkly to both of us.