Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Building Programming Language Interpreters
  • Table Of Contents Toc
Building Programming Language Interpreters

Building Programming Language Interpreters

By : Daniel Ruoso
close
close
Building Programming Language Interpreters

Building Programming Language Interpreters

By: Daniel Ruoso

Overview of this book

Designing a custom programming language can be the most effective way to solve certain types of problems—especially when precision, safety, or domain-specific expressiveness matters. This book guides you through the full process of designing and implementing your own programming language and interpreter, from language design to execution, using modern C++. You’ll start by exploring when and why building a domain-specific language is worth it, and how to design one to fit a specific problem domain. Along the way, you’ll examine real-world interpreter architectures and see how their design decisions affect language behavior, capabilities, and runtime trade-offs. The book then walks through the entire process of interpreter implementation: defining syntax, building a lexer and parser, designing an abstract syntax tree, generating executable instructions, and implementing a runtime. All examples are in modern C++, with a focus on clean architecture and real-world usability. By the end, you’ll have a fully working interpreter for a domain-specific language designed to handle network protocols—plus the knowledge and tools to design your own programming language from scratch. *Email sign-up and proof of purchase required
Table of Contents (25 chapters)
close
close
1
Modeling the Programming Language Runtime Environment
7
Modeling the Programming Language Syntax
12
Implementing the Interpreter Runtime
16
Interpreting Source Code
24
Index

Preface

I grew up experimenting with BASIC on an MSX computer in Brazil. That was a time when the computer would come with a printed manual that had little games and exercises with the code listings, and you would have to type it out to see what happened. When my family got a 486 PC, I transitioned to QBASIC. I still remember the first time I built an entire game with animations and everything from scratch.

Later, I transitioned to Delphi, where I would help my older brother in some of his projects, and eventually presented a small educational application at my school that I built with a colleague to explore the periodic table. At that time, I was also transitioning to using GNU/Linux and exploring with C programming.

I only became a “real” software developer once I learned Perl. This was 1998, and my older brother bought the Learning Perl and Programming Perl books. I still spoke “baby Perl,” as Larry Wall would say, and it would be a few years until I was confident enough to ship my first module to CPAN.

I became an avid advocate for the Perl language and started publishing various CPAN modules and participating in conferences. I remember all the hours I spent on perlmonks.org, and the moment my name finally showed up on the Saints in Our Book page.

But while at the turn of the century, Perl was “the duct tape of the internet,” by the turn of the 2010s, there was a very strong sentiment against it in the industry. I had to accept that I couldn’t just be a Perl developer; I had to be an “anything developer.”

This has led me to take a very different perspective when looking at programming language and interpreter design. To look beyond the what and start asking the why. Why did Python choose to use a Global Interpreter Lock? Why did Perl have a share-nothing approach for multi-threading? Why does the C++ language have entirely different systems for programming and meta-programming?

Meanwhile, my formal education was in social sciences, which made me look at all of this from an anthropological perspective. At the end of the day, we’re talking about human communication; there’s no stick we can use to measure whether one language is better than another. You have different languages and people with different levels of fluency. You have ecosystems and communities that build a specific culture around those languages.

It is with this perspective that I arrived at the premise of this book, which is that we will never stop creating new programming languages, for as long as we have to write code. But this doesn’t need to be just a matter of aesthetic preference. Some niche problems require niche solutions, and building programming language interpreters is a way to introduce novel solutions to existing problems.

At the same time, a programming language is heavily influenced by the runtime environment it targets, but it’s also possible to build custom runtime environments that target a specific programming language.

The existing literature tends to treat those areas as fundamentally independent, while I feel that there is a lot left behind by not considering the design and implementation of the programming language and of the runtime environment it targets as a coherent set.

That is why it was important to me to choose a bottom-up approach when working on this book. I want you to look at the entire problem of both programming language and interpreter design and implementation as a single unit.

By the end of this book, I hope that you find yourself as fascinated as I am by all the technical and non-technical aspects that are connected to programming language and interpreter design and implementation.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Building Programming Language Interpreters
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon