Writing programming languages is fun #

If you've never thought to write a programming language yourself because you believe that it's too hard, I'll try to change your mind.

Many software engineers that I personally know, approach programming languages as "black boxes". They would use the language, but never look under the hood to see what's happening inside and how it works. Which is understandable: a typical programming language consists of layers of historical baggage that is hard to navigate. I'm not an exception here: even though I looked at the LLVM or Python code multiple times in my career, it was always for solving a particular problem.

In practice, for languages written in C or C++, the code will be littered with macros, platform-related branches and all sorts of optimizations. For higher-level ones it may be better, but still you'd be unlikely to understand even how modules are organized and how they talk to each other without spending very significant time.

I'd argue that studying the implementation of an existing mainstream language is a wrong approach if you'd like to understand the key mechanics.

Now, why should you care at all about these things? Isn't it the case that there are lots of great engineers who have never touched the internals of a compiler/interpreter? Sure, I'll grant you that. I would even say that I'm not a great engineer myself, so I can't be the judge. Every time I figure something out, it's usually a hard-won battle that takes way longer than people around me realize.

Having said that, there are a few things that are special about programming languages that make them a good learning material: