I would like to learn compiler construction from ground up, create a simple Lang whether compiled or interpreted. Preferably something I can go through sequentially from start to finish
Seconding this one, it strikes a very good balance between theory/pragmatism/entertainment/broader-context. It's oriented around the steps of actually implementing the thing, but there are lots of great little tidbits that shed light on surrounding subjects.
The usage of Java for this purpose is a bit... contrived, but it's not because the author doesn't know what he's doing, and following along in a different language that's better-suited to the task makes a good exercise for the reader
One of the simplest interpreters that also has a compiler built-in is Forth. It is somewhat heretical to conventional computer science but it can be fully understood top to bottom by normal humans due to it features or lack thereof. :)
A quick search found this repository of JonesForth which is a literate programming version of a Forth system that describes the code as it goes along. There appears to be source for various targets.
It is a very interesting exercise that shows you a kind of bare minimum requirement way to make a language and provides insights for what is missing to build more conventional languages.
Principles of Compiler Design is old but still a great book, one of the best CS books I've read and it got me going with compilers. I'm reading an old copy from the 70's.
I've heard good things about Writing A Compiler In Go, which is a sequel to Writing An Interpreter In Go. I've worked through some of the latter and have enjoyed it so far.
Nice, thanks. Traefik have a working go interpreter https://github.com/traefik/yaegi. Been meaning to go through the source code to borrow a few pointers(pun intended) as well.
The best simple introduction i have found to the whole domain of Programming Languages/Interpreters/Compilers construction using tools is "Chapter 8, Program Development" in the book The Unix Programming Environment by Kernighan & Pike. They develop a language and interpreter for "hoc(higher order calculator)". It is just about 40 pages which you can finish in a week and really understand the various pieces involved and how they fit together. I highly recommend not looking at anything else before finishing this.
Once the above is done, you can take a look at any of the popular Compiler construction books/resources many of which would be recommended here. One less well-known but comprehensive work is Project Oberon: The Design of an Operating System and Compiler by Niklaus Wirth.
10 comments
[ 2.8 ms ] story [ 40.9 ms ] threadThe usage of Java for this purpose is a bit... contrived, but it's not because the author doesn't know what he's doing, and following along in a different language that's better-suited to the task makes a good exercise for the reader
A quick search found this repository of JonesForth which is a literate programming version of a Forth system that describes the code as it goes along. There appears to be source for various targets.
https://github.com/phf/forth
It is a very interesting exercise that shows you a kind of bare minimum requirement way to make a language and provides insights for what is missing to build more conventional languages.
https://compilerbook.com/
Once the above is done, you can take a look at any of the popular Compiler construction books/resources many of which would be recommended here. One less well-known but comprehensive work is Project Oberon: The Design of an Operating System and Compiler by Niklaus Wirth.