https://futureofcoding.org/ logo
#present-company
Title
# present-company
m

Maikel

01/30/2023, 6:15 PM
Has anyone read "compilers principles techniques and tools" and/or "modern compiler design"? Can you recommend one them or another book about the subject? I am getting some experience building compilers currently and the last year or so, but I am still rather new to it and looking for some good reference to help me grow
j

Jimmy Miller

01/30/2023, 7:03 PM
The dragon book is a classic that is often recommended. I personally haven't read it. I hear most people like it as a reference. A book I have read (a good chunk of) that I can highly recommend is crafting interpreters. While on the face it isn't about compilation, the second half of the book you compile to a bytecode vm that you build. My advice is to look for books where most of the book is not spent in parsing. For some reason, there is an obsession in compiler books with parsing. It is usually not that important and is such a small part of the language. One book I just ordered but haven't read yet that looks really nice is Engineering A Compiler. Also happy to chat about compilers anytime. I'm relatively new to them as well, but now working on a JIT compiler in my day job, I'm learning a lot faster.
m

Mariano Guerra

01/30/2023, 7:15 PM
m

Maikel

01/30/2023, 7:19 PM
Thanks, that sounds like a good book (crafting interpreters) and I've ordered it. I've also saw Engineering a Compiler and curious about your findings. For sure interesting to have a chat about compilers in a video call , where are you located? (I am a bit busy because we're moving through a new house this month here in the Netherlands). I only have a big chunk of friday and the saturday and sunday early mornings to work on my project .. so working on a jit compiler at work full-time is very nice I can imagine for sure!
l

Lu Wilson

01/31/2023, 12:07 AM
I found it very confusing but I did enjoy the pictures
s

smt

01/31/2023, 1:48 AM
do you have the code posted online for the compiler you're working on? i'm not an expert though i know a little bit and would be happy to take a look
m

Maikel

01/31/2023, 5:32 AM
I am working on multiple compilers, this is the expression/script to javascript compiler: https://github.com/devhelpr/expression-compiler .. I have used a course on udemy as a base for the the compiler structure (https://www.udemy.com/course/parser-from-scratch/) .. I am also building a simple jsx compiler which I'll share once I have some bugs fixed.
I use my expression-compiler in the visual programming system that I am building .. it is used for compiling little snippets for conditional nodes but also larger pieces of script. It can have input from the outside via a payload and it can be extended with external functions that can be used from within the expressions/scripts.
j

Jack Rusher

01/31/2023, 8:12 AM
I scanned through Crafting Interpreters awhile ago — it looked like a good, approachable introduction. Wirth's Compiler Construction is a beautiful gem of a book, though perhaps a bit dated by now. The Dragon Book is a classic, but I think it works better in a teaching setting than for self-study. SICP intros this topic very well, but contains loads of other stuff that would turn it into a lengthy side quest. Much as Jimmy has recommended that you skip a bunch of parsing stuff, it sounds like your use case doesn't need a bunch of the normal code generation techniques, as what you're building is what we used to call a translator (rather than a compiler, which is a translator from a higher to a lower level language). 🤷🏻‍♂️
m

Maikel

01/31/2023, 9:10 AM
I've also build a webassembly compiler using the same approach although you might argue that this is also a translation process since wasm is a (very) low language as well. Where lies the boundary between calling this process compilation or translation? (Or maybe even "transpiling")
j

Jack Rusher

01/31/2023, 3:30 PM
What people call "transpiling" today is what we would have called "translation" in the past. High level to (w)ASM would definitely be compiling! 🙂
m

Maikel

01/31/2023, 3:31 PM
😅otherwise I had to return the book I just bought
l

Lu Wilson

01/31/2023, 3:51 PM
It's only called compiling if it's from the compilé region of France I believe
m

Mariano Guerra

01/31/2023, 3:53 PM
The sun is a compiler
w

wtaysom

01/31/2023, 11:52 PM
As a lover of parsers, I agree that compiling is a different beast from compiling. Where a parser is a tree growing out of a stream — and at its most interesting a typo dirty stream — compiling is mostly more about transforming a tree. Speaking of beasts, when first, and with little understanding, I was curious about this at school, I was hoping for the Dragon Book and got Pierce's Types and Programming Languages, which served me better in the end. For compiling, I always liked the Nanopass project for its clarity https://nanopass.org/documentation.html. For parsing, monadic ones get a person in a particularly good frame of mind, and Ohm https://ohmjs.org/ is the nicest tool I've come across.
u

Ulysses Popple

02/01/2023, 8:19 AM
I've been really enjoying "build your own programming language" by clinton l jeffery which includes building a compiler.
m

Maikel

02/01/2023, 1:22 PM
Thanks for all the info! Enough to read and discover (and improve)🤯😀
j

Jack Rusher

02/01/2023, 4:29 PM
The Nanopass papers are great. I wish more languages used a layered approach of that kind!
4 Views