9 ms·
Want to write a compiler? Just read these two papers (2008)
- downbad_ 7mo agohttps://news.ycombinator.com/item?id=10786842 https://news.ycombinator.com/item?id=10786842
- msla 7mo agofanf2 on Dec 25, 2015 [dead] | parent | prev | next [–] I quite like "understanding and writing compilers" by Richard Bornat - written in the 1970s using BCPL as the implementation language, so rather old-fashioned, but it gives a friendly gentle overview of how to do it, without excessive quantities of parsing theory.
- msla 7mo agohttps://news.ycombinator.com/item?id=10791521 https://news.ycombinator.com/item?id=10791521
- Tor3 7mo agoI like that book too, I bought it many decades ago and learned enough to write a transpiler for converting Fortran source code to Turbo Pascal.
- ac50hz 7mo agoSadly, Richard died in January this year. This book is available to download from one of his academic pages: https://www.eis.mdx.ac.uk/staffpages/r_bornat/#compilerbook https://www.eis.mdx.ac.uk/staffpages/r_bornat/#compilerbook https://www.eis.mdx.ac.uk/staffpages/r_bornat/books/compiling.pdf https://www.eis.mdx.ac.uk/staffpages/r_bornat/books/compilin... https://en.wikipedia.org/wiki/Richard_Bornat https://en.wikipedia.org/wiki/Richard_Bornat
- itsmemattchung 7mo agoIt's been about 4 years since I took a compilers course (from OMSCS, graduate program) and still shutter ... it was, hands down, the most difficult (yet rewarding) classes I've taken.
- msla 7mo agoIt made me drink myself Venetian blind.
- Pay08 7mo agoI would like to agree with this comment, but I certainly didn't find it rewarding. It was pure pain.
- kuboble 7mo ago10 years ago I took few coursera courses to fill the gaps in my computer science education. One of them was a compilers course done by karpathy. It was pure joy and a great learning experience. Also in my experience the joy of doing a course was much stronger correlated with the teacher's qualities rather than the subject itself.
- jgwil2 7mo agoDo you have a link by by chance? A quick search didn't turn anything up.
- kuboble 7mo agoNo, I am checking my emails (it was in 2012), and all the links are broken. however I could dig out the references to it. Apparently it was a course by Prof. Alex Aiken and karpathy was a TA. This repository seems to be a future version of the same course. https://github.com/gboduljak/stanford-compilers-coursework https://github.com/gboduljak/stanford-compilers-coursework Edit: found the videos from the course on the archive https://archive.org/details/academictorrents_e31e54905c7b2669c81fe164de2859be4697013a https://archive.org/details/academictorrents_e31e54905c7b266...
- jgwil2 7mo agoAh yes, I remember this one. Very challenging indeed. Thanks!
- deleted 7mo ago
- krtkush 7mo agoI wonder if it makes sense to do the nand2tetris course for an absolute beginner since it too has compiler creation in it.
- imrozim 7mo ago[dead]
- wartywhoa23 7mo agoI highly recommend nand2tetris to everyone. For me, nothing ever explained the whole domain from logic gates and inner workings of a CPU to compilers better than this course.
- wartywhoa23 7mo agoOn a side note, why is imrozim's comment dead? What in the world is wrong with it? It's perfectly fine IMO.
- bmn__ 7mo agocheck comment history https://news.ycombinator.com/item?id=47582720 https://news.ycombinator.com/item?id=47582720
- atan2 7mo agoI think it's worth mentioning Gustavo Pezzi's lectures at pikuma.com. The one on "Digital Electronics" and the one on "Interpreters & Compilers" really helped me.
- sn9 7mo agonand2tetris only requires programming ability at the level of someone who's taken freshman level CS IIRC. You could take Harvard's CS50 and then tackle it.
- petcat 7mo agoAnd Nystrom's book
- vlaaad 7mo agoYeah, I really enjoyed Crafting Interpreters, wholeheartedly recommend!
- armchairhacker 7mo agoNowadays I’ve heard recommended Crafting Interpreters. (https://craftinginterpreters.com https://craftinginterpreters.com) The Nanopass paper link doesn’t work.
- ramon156 7mo agoAwesome course! finished it while i was doing my final CS year because I had to wait on a bunch of classes (and frankly had no one to talk to before classes). I haven't tried nanopass, but there's other links that work, so I'll give it a go.
- tmountain 7mo agoIncredible book for self guided learning!
- gobdovan 7mo agoCompilers are broad enough that when someone recommends a "compiler book", it's rarely exactly the slice you wanted. So this made me do a runnable cheat sheet for Crafting Interpreters. I keep parsing demonstrative, and the AST is a little more Lisp-y than the book's. Disclaimer: it's meant to convey the essence of what you'll learn, it is NOT by any means a replacement for the book. I'd also describe the book as more of an experience (including some things Nystrom clearly enjoyed, like the visitor pattern) than a compilers manual. If anyone's interested, I can do a separate visitor-pattern cheat sheet too, also in Python. I turned it into a 'public-facing artifact' from private scripts with an AI agent. [0] https://ouatu.ro/blog/crafting-interpreters-cheat-sheet/ https://ouatu.ro/blog/crafting-interpreters-cheat-sheet/
- orthoxerox 7mo agoCrafting Interpreters is great, I wish it had a companion book that covered: - types and typing - optimization passes - object files, executables, libraries and linking Then two of them would be sufficient for writing a compiler.
- gavinray 7mo agoTo your last point, "Linkers and Loaders" has no equal despite being a bit dated
- GCUMstlyHarmls 7mo agoNanopass paper seems to be dead but can be found here at least https://stanleymiracle.github.io/blogs/compiler/docs/extra/nanopass-framework.pdf https://stanleymiracle.github.io/blogs/compiler/docs/extra/n...
- kunley 7mo agoAlso: https://www.cambridge.org/core/journals/journal-of-functional-programming/article/educational-pearl-a-nanopass-framework-for-compiler-education/1E378B9B451270AF6A155FA0C21C04A3 https://www.cambridge.org/core/journals/journal-of-functiona...
- NordStreamYacht 7mo agoAlso you could go to Andy Keep's site: https://nanopass.org/ https://nanopass.org/
- consomida 7mo ago[dead]
- imrozim 7mo ago[dead]
- rdevilla 7mo ago[flagged]
- KnuthIsGod 7mo agoSome of us enjoy intellectual challenges.... The Bornat book looks great. The fact that it is in BCPL is ultra cool.
- rdevilla 7mo agoLiking intellectual challenges on Hacker News is very 2008. It's 2026, the AI will write a compiler in 5 minutes, no headache required. If you're still playing with Rubik's cubes you're going to get left behind.
- guitarlimeo 7mo ago> you're going to get left behind. What's wrong with that? Why do you fear getting left behind? This is just fearmongering. Mind you these are legitimate interests of people and in most of cases probably not related to professional work. And lol @ "It's 2026, the AI will write a compiler in 5 minutes, no headache required.", no it will not, have you seen Anthropic's post about Claude writing the "C compiler"?
- weavie 7mo agoI think this chap is just joking.
- noosphr 7mo agolol
- voidUpdate 7mo agoI've been handwriting my website since forever. That way I don't have to also load megabytes of JS libraries, and it keeps it nice and lean (ish)
- fzeindl 7mo agoA similarly scoped book series is „AI game programming wisdom“, which contains a multitude of chapters that focus on diverse, individual algorithms that can be practically used in games for a variety of usecases.
- jll29 7mo ago*Donald Knute -> Donald Ervin Knuth is the author of the book "The Art of Computer Programming" (in progress for a couple of decades, currently volume 4c is being written). It is quite advanced, and it will likely not cover compilers anymore (Addison-Wesley had commissioned a compiler book from Knuth when he was a doctoral candidate, now he is retired and has stated his goal for the series has changed). I disagree with the author's point: the "Dragon book"'s ("Compilers: Principles, Techniques, and Tools" by Aho et al.) Chapter 2 is a self-sufficient introduction into compilers from end to end, and it can be read on its own, ignoring the rest of the excellent book. Another fantastic intro to compiler writing is the short little book "Compilers" by Niklaus Wirth, which explains and contains the surprisingly short source code of a complete compiler (the whole book is highly understandable - pristine clarity, really) and all in <100 pages total (99). (I learned enough from these two sources to write a compiler in high school.)
- Hendrikto 7mo ago> "Compilers" by Niklaus Wirth This one? https://people.inf.ethz.ch/wirth/CompilerConstruction/CompilerConstruction1.pdf https://people.inf.ethz.ch/wirth/CompilerConstruction/Compil...
- znpy 7mo agoi found the same file but that's only 44 pages long ? This ( https://github.com/tpn/pdfs/blob/master/Compiler%20Construction%20-%20Niklaus%20Wirth%20-%201996%20(CBEAll).pdf https://github.com/tpn/pdfs/blob/master/Compiler%20Construct... ) seems to be a previous version (2005) and it's 131 pages long
- guenthert 7mo agoYou'll want part 2 as well for a total of 107 pages.
- antiquark 7mo agoThere is still hope for a compiler book. From Knuth's website: > And after Volumes 1--5 are done, God willing, I plan to publish Volume 6 (the theory of context-free languages) and Volume 7 (Compiler techniques), but only if the things I want to say about those topics are still relevant and still haven't been said. https://www-cs-faculty.stanford.edu/~knuth/taocp.html https://www-cs-faculty.stanford.edu/~knuth/taocp.html
- LiamPowell 7mo agoSee also, Andy Keep's dissertation [1] and his talk at Clojure/Conj 2013 [2]. I think that the nanopass architecture is especially well suited for compilers implemented by LLMs as they're excellent at performing small and well defined pieces of work. I'd love to see Anthropic try their C compiler experiment again but with a Nanopass framework to build on. I've recently been looking in to adding Nanopass support to Langkit, which would allow for writing a Nanopass compiler in Ada, Java, Python, or a few other languages [3]. [1]: https://andykeep.com/pubs/dissertation.pdf https://andykeep.com/pubs/dissertation.pdf [2]: https://www.youtube.com/watch?v=Os7FE3J-U5Q https://www.youtube.com/watch?v=Os7FE3J-U5Q [3]: https://github.com/AdaCore/langkit/issues/668 https://github.com/AdaCore/langkit/issues/668
- aag 6mo agoAndy gave a nice talk on the implementation of Chez Scheme, an optimizing compiler, at the Scheme Workshop in Berlin in 2019: https://www.youtube.com/watch?v=N_-enNCZxaU https://www.youtube.com/watch?v=N_-enNCZxaU
- bradley13 7mo agoMaybe I'm missing the point of this article? Writing a simple compiler is not difficult. It's not something for beginners, but towards the end of a serious CS degree program it is absolutely do-able. Parsing, transforming into some lower-level representation, even optimizations - it's all fun really not that difficult. I still have my copy of the "Dragon Book", which is where I originally learned about this stuff. In fact, inventing new programming languages and writing compilers for them used to be so much of a trend that people created YACC (Yet Another Compiler Compiler) to make it easier.
- dlopes7 7mo agoMaybe you are a genius among mere mortals, but for the majority of people even after a CS degree writing a compiler is a bit difficult
- zionpi 7mo ago[dead]
- omcnoe 7mo agoBeen working on a toy compiler for fun recently. I have ignored all the stuff about parsing theory, parser generators, custom DSL's, formal grammers etc. and instead have just been using the wonderful Megaparsec parser combinator library. I can easily follow the parsing logic, it's unambiguous (only one successful parse is possible, even if it might not be what you intended), it's easy to compose and re-use parser functions (was particularly helpful for whitespace sensitive parsing/line-fold handling), and it removes the tedious lexer/parser split you get with traditional parsing approaches.
- mrkeen 7mo agoI'll push back and say that the lexer/parser split is well worth it. And the best thing about the parser combinator approach is that each is just a kind of parser, something like type Lexer = ParsecT e ByteString m [Token] type Parser = ParsecT e [Token] Expr All the usual helper functions like many or sepBy work equally well in the lexing and parsing phases. It really beats getting to the parentheses-interacting-with-ordering-of-division-operations stage and still having to think "have I already trimmed off the whitespace here or not?"
- omcnoe 7mo agoI am writing a whitespace sensitive parser - trimming whitespace matters because whitespace consumption is used to implement the indentation rules/constraints. For example, doing things like passing an indentation sensitive whitespace consumer to a parser inside `many` for consuming all of an indented child block. If I split lexing/parsing I think I'd have to do things like insert indentation tokens into the stream, and end up with the same indentation logic (but instead matching on those indentation tokens) in the parser regardless. I have found that order-of-operations is somewhat trivially solved by `makeExprParser` from `Control.Monad.Combinators.Expr`.
- armchairhacker 7mo agoIt seems to me LL and LR parser generators are overrated, and hand-written recursive descent is best in practice. I understand why academics teach them, but not why some spend so long on different parsing techniques, nor why hobbyists who just want to compile their toy language are directed to them. I work in PL, and from my first compiler to today, have always found recursive descent easiest, most effective (less bugs, better error diagnostics, fast enough), and intuitive. Many popular language compilers use recursive descent: I know at least C# (Roslyn) and Rust, but I believe most except Haskell (GHC) and ocaml. The LR algorithm was simple once I learned it, and yacc-like LR (and antlr-like LL) parser generators were straightforward once I learned how to resolve conflicts. But recursive descent (at least to me) is simpler and more straightforward. LR being more expressive than LL has never mattered. A hand-written recursive descent parser is most expressive: it has unlimited lookahead, and can modify parsed AST nodes (e.g. reordering for precedence, converting if into if-else). The only solution that comes close is tree-sitter, because it implements GLR, provides helpful conflict messages, and provides basic IDE support (e.g. syntax highlighting) almost for free. But it’s a build dependency, while recursive descent parsers can be written in most languages with zero dependencies and minimal boilerplate.
- soegaard 7mo agoAn Incremental Approach to Compiler Construction Abdulaziz Ghuloum http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf Abstract Compilers are perceived to be magical artifacts, carefully crafted by the wizards, and unfathomable by the mere mortals. Books on compilers are better described as wizard-talk: written by and for a clique of all-knowing practitioners. Real-life compilers are too complex to serve as an educational tool. And the gap between real-life compilers and the educational toy compilers is too wide. The novice compiler writer stands puzzled facing an impenetrable barrier, “better write an interpreter instead.” The goal of this paper is to break that barrier. We show that building a compiler can be as easy as building an interpreter. The compiler we construct accepts a large subset of the Scheme programming language and produces assembly code for the Intel-x86 architecture, the dominant architecture of personal computing. The development of the compiler is broken into many small incremental steps. Every step yields a fully working compiler for a progressively expanding subset of Scheme. Every compiler step produces real assembly code that can be assembled then executed directly by the hardware. We assume that the reader is familiar with the basic computer architecture: its components and execution model. Detailed knowledge of the Intel-x86 architecture is not required. The development of the compiler is described in detail in an extended tutorial. Supporting material for the tutorial such as an automated testing facility coupled with a comprehensive test suite are provided with the tutorial. It is our hope that current and future implementors of Scheme find in this paper the motivation for developing high-performance compilers and the means for achieving that goal.
- asibahi 7mo agoInspired by Ghuloum's book is this really nice book by Nora Sandler: Writing a C Compiler https://norasandler.com/book/ https://norasandler.com/book/
- agency 7mo agoAnother recent book inspired by Ghuloum is Essentials of Compilation: An Incremental Approach (which publishes Python and Racket versions) https://github.com/IUCompilerCourse/Essentials-of-Compilation https://github.com/IUCompilerCourse/Essentials-of-Compilatio...
- morphle 7mo agoCompiler writing has progressed a lot. Notably in meta compilers [1] written in a few hundred lines of code and adaptive compilation [3] and just in time compilers. Alan Kay's research group VPRi tackled the problems of complexity (in writing compilers) [4]. [1] Ometa https://tinlizzie.org/VPRIPapers/tr2007003_ometa.pdf https://tinlizzie.org/VPRIPapers/tr2007003_ometa.pdf [2] Other ometa papers https://tinlizzie.org/IA/index.php/Papers_from_Viewpoints_Research_Institute https://tinlizzie.org/IA/index.php/Papers_from_Viewpoints_Re... [3] Adaptive compilation https://youtu.be/CfYnzVxdwZE?t=4575 https://youtu.be/CfYnzVxdwZE?t=4575 the PhD thesis https://www.researchgate.net/publication/309254446_Adaptive_compilation_for_an_object-oriented_and_reconfigurable_architecture https://www.researchgate.net/publication/309254446_Adaptive_... [4] Is it really "Complex"? Or did we just make it "Complicated"? Alan Kay https://youtu.be/ubaX1Smg6pY?t=3605 https://youtu.be/ubaX1Smg6pY?t=3605
- voidUpdate 7mo agoI've been having a look at the Crenshaw series, and it seems pretty good, but one thing that kinda annoys me is the baked-in line wrapping. Is there a way to unwrap the text so its not all in a small area on the left of my screen?
- 77 7mo agohttps://xmonader.github.io/letsbuildacompiler-pretty/ https://xmonader.github.io/letsbuildacompiler-pretty/
- voidUpdate 7mo agoPerfect!
- kristianp 7mo agoHere's an archived version converted to x86: https://web.archive.org/web/20220603004249/http://www.pp4s.co.uk/main/tu-trans-comp-jc-intro.html https://web.archive.org/web/20220603004249/http://www.pp4s.c...
- ape4 7mo agoWould a practical approach be parsing the source into clang's AST format. Then let it make the actual executable.
- ethan_smith 7mo agoYou'd more likely want to emit LLVM IR rather than try to match clang's internal AST. That's essentially what most new language projects do now (Rust, Swift, Zig all use LLVM as their backend). You get optimization passes and codegen for multiple architectures for free, and the IR is well-documented. The tradeoff is you skip learning about the backend, which is arguably the most interesting part.
- ape4 6mo agoRight that's what I meant ... the .ll file. Thanks
- stupefy 7mo agoOne nice piece of advice that I received is that books are like RAMs, you do not have to go through them sequentially, but can do random access to the parts of it you need. With this in mind I find it doable to get one the thick books and only read the part that I need for my task. But, to also be fair, the above random access method does not work when you don't know what you don't know. So I understand why having a light, but good introduction to the topic is important, and I believe that's what the author is pointing out.
- commandlinefan 7mo agoI've seen people suggest that throughout the years, but it's never worked out for me. To get anything meaningful out of a printed book, I've had to read them cover to cover. There used to be worthwhile reference books, but those have moved on to the internet.
- elzbardico 7mo agoI like doing both. Skimming through the interesting parts first, them re-reading from start sequentially.
- wglb 7mo agoA significant fraction of my technical library is used just this way--as a reference, checking out the parts to answer a specific question.
- andoando 7mo agoMost books have so much nonsense details that I cant help but skip most of it. On the other hand technical books can be so overwhelmingly difficult that you need to go outside and do hours of learning to understand one tidbit of it
- baarse 7mo ago[dead]
- blueybingo 7mo agothe article's framing around nanopass is undersold: the real insight isn't the number of passes but that each pass has an explicit input and output language, which forces you to think about what invariants hold at each stage. that discipline alone catches a suprising number of bugs before you even run the compiler. crenshaw is fantastic but this structural thinking is what separates toy compilers from ones you can actaully extend later.
- lateforwork 7mo agoThese days there's an even easier way to learn to write a compiler. Just ask Claude to write a simple compiler. Here's a simple C compiler (under 1500 lines) written by Claude: https://github.com/Rajeev-K/c-compiler https://github.com/Rajeev-K/c-compiler It can compile and run C programs for sorting and searching. The code is very readable and very easy to understand.
- angusturner 7mo agowhy read that, vs an actually well-written compiler though?
- lateforwork 7mo agoBecause an actual compiler would be tens of thousands of lines and most of it is going to be perf optimization. If you want to get the big picture first, read a simple working compiler that has all the key parts, such as a lexer, abstract syntax tree, parser, code generator and so on.
- 103e 6mo agoIs it less work than finding a human authored toy compiler of good quality. How long did it take to generate?
- voidfunc 7mo agoFor those of us that learn better by taking something and tinkering with it this is definitely the better approach. Ive never been a good book learner but I love taking apart and tinkering with something to learn. A small toy compiler is way better than any book and its not like the LLM didnt absorb the book anyways during training.
- lateforwork 7mo agoExactly! Writing a compiler is not rocket science if you know assembly language. You can pick up the gist in an hour or two by looking at a simple toy compiler.
- aldousd666 7mo agoI learned from the Dragon Book, decades ago. I already knew a lot of programming at that point, but I think most people writing compilers do. I'm curious if there really is an audience of people whose first introduction to programming is writing a compiler... I would think not, actually.
- h4ch1 6mo agoWouldn't say a lot of people use it for an introduction to programming, but I've personally seen it appear quite early in the programmers journey. I was first exposed to compilers as a learning subject as a mandatory 2nd year/1st semester course; with the Dragon Book as the main textbook...
- mzs 7mo agoarchive of forth translation of Crenshaw’s howto https://web.archive.org/web/20190712115536/http://home.iae.nl/users/mhx/crenshaw/tiny.html https://web.archive.org/web/20190712115536/http://home.iae.n...
- notnullorvoid 7mo agoI might be in the minority, but I think the best way to learn how to write a compiler is to try writing one without books or tutorials. Keep it very small in scope at first, small enough that you can scrap the entire implementation and rewrite in an afternoon or less.
- anthk 7mo agohttps://t3x.org https://t3x.org has literal books on that, from a simple C compiler to Scheme (you might heard of s9) and T3X0 itself which can run under Unix, Windows, DOS, CP/M and whatnot. PD: Klong's intro to statisticks, even if the compiler looks like a joke, it isn't. It can be damn useful. Far easier than Excel. And it comes with a command to output a PS file with your chart being embedded. https://t3x.org/klong/ https://t3x.org/klong/ Intro to statistics with Klong https://t3x.org/klong/klong-intro.txt.html https://t3x.org/klong/klong-intro.txt.html https://t3x.org/klong/klong-ref.txt.html https://t3x.org/klong/klong-ref.txt.html On S9, well, it has Unix, Curses, sockets and so on support with an easy API. So it's damn easy to write something if you know Scheme/Ncurses and try stuff in seconds. You can complete the "Concrete Abstractions" book with it, and just adapt the graphic functions to create the (frame) one for SICP (and a few more). And as we are doing compilers... with SICP you create from some simulator to some Scheme interpreter in itself.
- kuharich 7mo agoPast comments: http://news.ycombinator.com/item?id=2927784 http://news.ycombinator.com/item?id=2927784, https://news.ycombinator.com/item?id=10786842 https://news.ycombinator.com/item?id=10786842
- dang 7mo agoThanks! Macroexpanded: Want to Write a Compiler? Read These Two Papers (2008) - https://news.ycombinator.com/item?id=10786842 https://news.ycombinator.com/item?id=10786842 - Dec 2015 (70 comments) Want to Write a Compiler? Just Read These Two Papers. - https://news.ycombinator.com/item?id=2927784 https://news.ycombinator.com/item?id=2927784 - Aug 2011 (77 comments) Want to Write a Compiler? Just Read These Two Papers - https://news.ycombinator.com/item?id=231758 https://news.ycombinator.com/item?id=231758 - June 2008 (39 comments)
- WalterBright 7mo agoWhat taught me how to write a compiler was the BYTE magazine 1978-08 .. 09 issues which had a listing for a Tiny Pascal compiler. Reading the listing was magical. What taught me how to write an optimizer was a Stanford summer course taught by Ullman and Hennessy. The code generator was my own concoction, and is apparently quite unlike any other one out there! I have the Dragon Book, but have never actually read it. So sue me.
- SilentM68 7mo agoYou can find some of those magazines linked below: https://archive.org/details/BYTE-MAGAZINE-COMPLETE https://archive.org/details/BYTE-MAGAZINE-COMPLETE
- aurohacker 7mo agoAny tips on reading material for code generation and scheduling for parallel engines?
- cdcarter 7mo agoAll you really need is a copy of "The Unix Programming Environment", where you can implement `hoc` in a couple hours.
- georgehm 7mo agoI have fond memories of implementing an optimizing compiler for the CS241 compiler course offered back then by Prof Michael Franz who was a student of Niklaus Wirth, probably the most exhilarating course during my time at UC Irvine. This was in 2009 so my memory is vague but I recall he provided a virtual machine for a simple architecture called DLX and the compiler was to generate byte code for it. Google search points me to https://github.com/cesarghali/PL241-Compiler/blob/master/DLX.pdf https://github.com/cesarghali/PL241-Compiler/blob/master/DLX... for a description of the architecture and possibly https://bernsteinbear.com/assets/img/linear-scan-ra-context-ssa.pdf https://bernsteinbear.com/assets/img/linear-scan-ra-context-... for the register allocation algorithm
- khat 7mo agoThe biggest issue with technical books is they spend the first 1-2 chapters vaguely describing some area and then follow up with but that's for a later more advanced discussion or we'll cover that in that last 1-2 chapters. Don't vaguely tell me about something you're not gonna go into detail about, because now all I'm thinking about reading the subsequent chapters is all the questions I have about that topic.
- troad 7mo agoThat's how all education works. It's the spiral model of teaching. In one grade you learn a bit of this and a bit of that, then the next year you retread, and flesh all those things out by adding more depth and complexity. Rinse and repeat every grade. What would the alternative look like? Should a foreign language course spend three years on Nouns, just to make sure they're comprehensively covered, before you ever see your first Verb?
- rahen 7mo agoI'm also writing a compiler and CS6120 from Cornell has helped me a lot: https://www.cs.cornell.edu/courses/cs6120/2025fa/self-guided/ https://www.cs.cornell.edu/courses/cs6120/2025fa/self-guided...
- zahlman 7mo ago> The best source for breaking this myth is Jack Crenshaw's series, Let's Build a Compiler! Right, I've heard of that... > , which started in 1988. ... Oh. Huh. (Staring at the red dragon book on my bookshelf, which was my course textbook in the early 00s.)
- blueybingo 7mo ago[dead]
- dgan 7mo agoIf i had a euro for every time I started writing a compiler, and got lost in the parser weeds, i d have ... At least couple of euros
- deterministic 6mo agoWhatever you do don't waste your time on the "Dragon" book. Google "recursive descent parsing" and it will tell you everything you need to know about the front-end of a compiler. Google "My First Language Frontend with LLVM" and it will teach you the other half.
- ahaferburg 6mo agoI liked this series of lectures on Youtube. Compilers - Alex Aiken | Stanford https://www.youtube.com/playlist?list=PLEAYkSg4uSQ3yc_zf_f1GOxl5CZo0LVBb https://www.youtube.com/playlist?list=PLEAYkSg4uSQ3yc_zf_f1G... Mentioned in another comment, but with a different link.
- felishiagreen12 6mo ago[dead]
- teleforce 6mo agoThe latest edition (3rd Edition) of Introduction to Compiler Design by Mogensen has new topics on SSA form, garbage collection, polymorphism and translation of pattern matching [1]. [1] Introduction to Compiler Design: https://link.springer.com/book/10.1007/978-3-031-46460-7 https://link.springer.com/book/10.1007/978-3-031-46460-7
- knuckleheadsmif 6mo agoAll these years I thought The Dragon Book referred to the “Green” Dragon book (which was the text I used in my compiler class in the very early 80s) only to Just realize that when folks refer to “The Dragon Book” that it is the red/purple book by 2 of the same authors from ‘84. I remember that I ignored most of the stuff when I did my compiler from the book I used and did a recursive descent parser which the book really, if I remember correctly, did not cover except maybe for a brief mention. The instructor was also pushing everyone to use lex/yacc and I thought that was not the right way to go if you wanted to actually understand things. Interesting most of the folks that used lex/yacc had trouble completing the assignment whereas I thought it was straightforward.