How to Create Pragmatic, Lightweight Languages

Build programming languages like a pro.

Learn how to build something usable in the real world. A true programming language, with an efficient parser and a complete compiler. A language with its own editor. This is not about building toys.

There is no need to reinvent the wheel: we reuse open-source components and organize them together, to get something usable with a targeted effort.

Do you think it is impossible to build a parser, an interpreter, an editor and a simulator in less than 1.000 lines of code? Think again.


For those of you who have decided to build your own language or tool, and thus have the necessary impetus, I can recommend this as THE entry level guide to lexing, parsing and compiling. No prior experience required!

Nikos Vaggalis, i-programmer

I just bought ‘How to create a pragmatic, lightweight language’ book and I want to say thank you. I have ‘Using ANTLR Like A Professional: Basic Edition’ course too. I’m not up to day with any of these materials because I’m learning parsing techniques first, specially building recursive descent parsers by hand (just for getting the ability) but I’m pretty sure I’ll be getting my hands dirty with these wonderful resources.

August 03, 2020 – Irwin Rodriguez

Why Build a Language?

In this book we will show you how to build languages and the tools to support them.

For starters, it’s a challenge and that is motivation enough for some people. Maybe that’s why you are here. And if that is the reason, I promise it’s going to be a good challenge and you are going to have fun meeting it. But there are other good reasons.

With the help of this book you will learn how to:

  • develop tools for a language, like a static analysis engine for Java or a transpiler from Python to JavaScript;
  • build a domain-specific language (DSL), a language really good at specific tasks, like HTML or SQL;
  • create a general-purpose language (GPL), a language suitable for any task, like C# or Ruby;
  • create an esoteric-programming language, a  language designed to make a point, like Piet or Shakespeare.


Creating a tool or a DSL can simplify your life as a programmer. And when your employer hears the magic words “increase productivity” it can even help in your job.

Creating an esoteric programming language can be a great way to put a new idea out there. To show that things can be done differently.

It is harder to succeed creating a GPL, but it can be done: Kotlin, Go, Ruby, Julia, Rust, etc. Just think about the many new languages created in the last decade. Many of them have taken hold in various communities and made developers happier.

A Bit of Theory and Lots of Code

When I was learning how to build languages I was disappointed: I could just find basic tutorials here and there, but what was missing was a complete course. One organized to lead me from the very beginning to the end. Whenever I found something more advanced, it was too abstract: a lot of compiler theory and not enough code.

I wanted a book with a clear plan and a pragmatic approach, but there wasn’t one.

That is when I decided to learn how to build languages on my own. It took me years of professional experience in building languages to get there. Now I can share this knowledge, so that you can learn how to create your own language in a few weeks.

It’s still going to be a lot of work, but you will have help.

How This Book Will Help You

This book shows how to reuse existing libraries and frameworks to create the necessary ecosystem to support our languages.

The cost of building the machinery to properly support a language used to be very high.

Today, with a limited effort, we can design a language and:

  • obtain a fast parser from a concise grammar definition;
  • obtain validation and model transformations with little code;
  • generate JVM bytecode and get interoperability with other JVM languages or generate the language with the help of LLVM;
  • obtain rich editors with syntax highlighting and autocompletion.

We will show you how to build all of this and more by defining small components in a smart way. The result will be something solid, complete and understandable.

The programming language used is Kotlin, but the techniques are universal and can be used with any language.

About the author

Federico Tomassetti is a Consultant Software Architect specialized in Language Engineering: I build languages, editors, parsers, compilers, interpreters and simulators.

I have an insane passion about Software Development: I have loved it since I was 8 years old and I keep thinking about it all the time. I have done several things: got my PhD in Software Engineering, done research and worked in Italy, Germany, Ireland and France. I spoke at meetups and scientific conferences, wrote papers and articles, worked for TripAdvisor and Groupon.

Table of Contents

Part 0: Creating a Language

  1. Motivation: why do you want to build language tools?
  2. The general plan
  3. The example languages we are going to build

Part I: the foundation

  1. Writing a lexer
  2. Writing a parser
  3. Mapping: from the parse-tree to the Abstract Syntax Tree
  4. Symbol resolution
  5. Typesystem
  6. Validation

Part II: compiling

  1. Build an interpreter
  2. Generate JVM bytecode
  3. Generate an executable using the LLVM

Part III: editing support

  1. Syntax highlighting
  2. Autocomplete

Three Packages

100% Satisfaction Guaranteed
If you are not happy, just ask for a refund.

Basic edition


  • Ebook with 370 pages of content
  • 3 formats: PDF, ePUB and Mobi (Kindle)
  • Invitation to the reserved area of the Strumenta community on Language Engineering

Standard edition


  • Ebook with 370 pages of content
  • 3 formats: PDF, ePUB and Mobi (Kindle)
  • Invitation to the reserved area of the Strumenta community on Language Engineering
  • The whole source code with in addition build files and tests. Ready to be used in your own projects

Note About VAT
Not based in Europe? No need to worry about VAT, it does not concern you. Are you a European Company? You can get VAT back: you simply have to enter your VAT ID into your Invoice, which you can generate through your receipt.

Not Ready to Buy the Book Yet?
Start With the Free Email Course!