HOWTO – make a compiler

Computers & Mobile Technology

compiler_20090210.jpg

Most hackers can spend their whole careers creating amazing software without ever needing to write a compiler or design a programming language. Like many professions, a lot of useful work can be accomplished with the established tools, rather than focusing efforts on the invention and craft of the tools themselves. Most carpenters purchase their tools at a hardware store. I’d probably raise an eyebrow if my doctor tried to measure my blood pressure with something she cobbled together in the garage (on second thought, that’d be pretty cool).

Unlike most other professions, however, the software developer has a unique advantage: the tools of the trade are made using the trade itself. A compiler is software that builds other software. I think that’s what intrigues programmers and simultaneously scares them away from language and compiler design. It’s magic.

Joel Pobar exposes a bit of this mystery in an introduction to compiler design for MSDN Magazine:

Compiler hackers are celebrities in the world of computer science. I’ve seen Anders Hejlsberg deliver a presentation at the Professional Developers Conference and then walk off stage to a herd of men and women asking him to sign books and pose for photographs. There’s a certain intellectual mystique about individuals who dedicate their time to learning and understanding the ins and outs of lambda expressions, type systems, and assembly languages.

The article is a walkthrough on the creation of a simple programming language and a corresponding compiler that targets the .NET CLR virtual machine. It’s a nice introduction to compiler design, and you can download the C# source for the sample compiler that’s discussed. Perhaps this will be the starting point for the creation of your own programming language.

Create a Language Compiler for the .NET Framework

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Tagged
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 16th iteration!

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK