Devlog February 2025
The second month was a rather productive one. February is usually Carnival month in Brazil so the family and I travel for a few days but this year it happens to be in March, giving me a full uninterrupted schedule.
Topics
I mainly immersed myself in compilers this month, something that was always interesting to me but never had the chance to really go into it. Regretfully my university didn’t offer a course on it so this was my chance to truly understand it. The funny thing is that it felt like university: I was doing exercises, projects, cross-referencing with other topics in mathematics.
I read (in full this time) the “Dragon Book” — Compilers: Principles, Techniques and Tools. It’s as good a book as people say it is as far as the breadth of knowledge it presents to you. However it is unfortunately sparse on actual coding examples and it spends a bit too much time on the front-end part of compiler construction: there’s not as much on instruction selection, linking and other important topics. However it gives a good overview of these things to the point where you can find more knowledge elsewhere.
Most of the code for the Dragon Book is left essentially “as an exercise to the reader”. This is a pet peeve of mine: a lot of books disregard the teaching potential of simply showing you the code. Even if the code code is not in a widely used language or it doesn’t work anymore due to unavailability of said language compilers it’s still much easier for a working programmer to relate the theoretical explanations with actual code.
For their part the authors — Aho, Sethi and Ullman — show a bit of code in the second chapter (“A Simple Compiler”), putting some things together for a simple translator, but it’s evidently a very toy example and doesn’t get built up as the book evolves into the “harder” parts of compiler construction.
Another book that goes code-first into the topic is “The UNIX programming environment”, by Kernighan and Pike. In the chapter “Program Development” the authors do what the Dragon Book did not and show you the code of an actual working mini language. It starts out as a simple calculator and then grows to include variable and function definitions.
That led me to reading more about lex
and yacc
, so I picked up the appropriately named book Lex and Yacc (Levine et. al). It does a pretty good job of giving you an overview and has some practical advices. I did forgo the whole matter of the different implementations (AT&T, GNU, etc). That doesn’t matter for me. However the idea of using just lex
for some small text-searching programs is interesting and something I hadn’t thought of.
To freshen up on C I read Beej’s Guide to C Programming and read and watched quite a few talks about more modern C development. Even though I know C I didn’t keep up with its development so I was still on a C89 mindset. Since then there have been some worthwhile improvements that made the language more ergonomic, it was very much worth re-learning some low-level programming.
Books and Articles
In total I read 4 technical books in February, watched 12 talks, read 9 papers and many more articles.
Repos
I produced some code while digging into compilers, an implementation of the Kernighan and Pike examples chapter by chapter, and an abstract stack machine of my own. There’s a lot more stuff that I cooked up but most are still private or in an unfinished state.
Conclusion
Pretty good month, the working sabbatical keeps delivering: this is some of the most enjoyable programming experiences I’ve had in years. I even managed to squeeze in some consultancy work for a few days.