Jump to ratings and reviews
Rate this book

Language Implementation Patterns: Techniques for Implementing Domain-Specific Languages

Rate this book

Knowing how to create domain-specific languages (DSLs) can give you a huge productivity boost. Instead of writing code in a general-purpose programming language, you can first build a custom language tailored to make you efficient in a particular domain.

The key is understanding the common patterns found across language implementations. Language Design Patterns identifies and condenses the most common design patterns, providing sample implementations of each.

The pattern implementations use Java, but the patterns themselves are completely general. Some of the implementations use the well-known ANTLR parser generator, so readers will find this book an excellent source of ANTLR examples as well. But this book will benefit anyone interested in implementing languages, regardless of their tool of choice. Other language implementation books focus on compilers, which you rarely need in your daily life. Instead, Language Design Patterns shows you patterns you can use for all kinds of language applications.

You'll learn to create configuration file readers, data readers, model-driven code generators, source-to-source translators, source analyzers, and interpreters. Each chapter groups related design patterns and, in each pattern, you'll get hands-on experience by building a complete sample implementation. By the time you finish the book, you'll know how to solve most common language implementation problems.

374 pages, Paperback

First published January 1, 2009

79 people are currently reading
587 people want to read

About the author

Terence Parr

16 books24 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
42 (22%)
4 stars
92 (48%)
3 stars
43 (22%)
2 stars
9 (4%)
1 star
2 (1%)
Displaying 1 - 13 of 13 reviews
Profile Image for Stefan Kanev.
125 reviews235 followers
August 28, 2013
It's a great book, but it has a few shortcomings.

The book explains a lot about implementing languages and it is definitely worth a read. The table of contents is impressive enough. Furthermore, the author has written a lot of executable code for each chapter, so you can play with the techniques explained. Unfortunately (for some), all the code is ANTLR and Java. While not necessarily bad, I'm under the impression that people who like Java and people who are interested in language implementation are two (almost) disjoint sets. Furthermore, it feels less rigorous and more "hands-on" that befits the subject.

Apart from that, it is an awesome book and definitely worth reading if you're into the subject.
15 reviews2 followers
November 16, 2018
I have not read the last half of 12th chapter and the 13th chapter. So take my review with a grain of salt. Also, I'm not that good at reading technical books too, so also take that into account.

TL;DR: You want to learn about the science behind compilers, probably not the best. If you want to straight away implement the compiler, probably the best.

With that out of the way, let's focus on the book. The one major downside I found in the book is that it is written for the older version of ANTLR. So you can't just start copy pasting code and start tinkering with grammars right away. You gotta combine it with the ANTLR v4 reference. The algorithms presented in the book are pretty easily adaptable to the v4 of ANTLR. As any of you reading the book should know, this is not a theoretical or conceptual book. This is down right implementation focused. It could be considered its strength and also somewhat of a weakness. The book is simple, I'd definitely give it that. Terence has done a great job boiling it down to just the essentials, so almost anyone can follow it. Even a person who has never done anything with compilers and just knows Java will do fine, except for some bits where help might be needed. Sometimes I think that the author has taken one too many examples and so the book feels slow. All in all, great book.
8 reviews1 follower
January 20, 2024
An excellent book on programming language implementation patterns written in the style of Gamma et al. It presents patterns for lexing, parsing, static analysis, interpreting, unparsing, and more. It provides examples using ANLTR (the parser generator/tree walker the author has been writing for many years). My only beef is that the earlier patterns were more clear to me then the later patterns. This may have been a function of my smooth brain, but regardless this is a great reference book!
600 reviews11 followers
May 31, 2017
A nice reintroduction to computer science theory and how parsing and compilers work at the lowest level. The structure makes sense, but as soon as the author starts a part it quickly jumps to other things that are related, but not need to be introduced right now. It’s rather useless when you try to build your own domain specific language on top of something existing.
Profile Image for Adrian McCarthy.
Author 2 books8 followers
May 27, 2017
A very practical book. It doesn't dwell in the theory that you might get in an early CS class and skips ahead right to the patterns necessary for parsing, analyzing, transforming, generating, and interpreting your own domain-specific languages.
Profile Image for César.
21 reviews
April 25, 2024
Un buen libro para conocer técnicas y patrones que sí son comunes en la implementación de lenguajes. Mi única objeción (caprichosa) es que los ejemplos están en Java y están diseñados con objetos. Las ideas siguen siendo claras.
Profile Image for Tristan Hume.
3 reviews4 followers
July 2, 2017
Excellent overview of how to get started implementing a language. This is the book that got me interested in compilers and gave me the tools to write my first interpreter and compiler.
Profile Image for Marko Kunic.
20 reviews1 follower
June 30, 2019
Most of the book is around ANTLR. I want to learn how to do this stuff from scratch, not generate everything from grammar. Theory part was good and that is the only reason for 3 stars.
7 reviews1 follower
May 23, 2016
Helped me immensely during my dissertation - covered and exposed a lot of concepts I needed to understand and that weren't being touched on at all at an undergraduate level.

Mostly just used it as a reference book and didn't read it cover to cover but I think just as a programmer you can gain a lot of insight from understanding these concepts and I'll likely come back to it in the future to further explore.
1 review4 followers
Want to read
February 15, 2010
So far this book is really nerdy, but I'm actually enjoying it. It makes sense giving I have no real experience with languages.
Profile Image for Tony B.
62 reviews3 followers
January 26, 2015
Skimmed through this book. A good start for a modern programmer to understand about parsers\generator\compilers.
3 reviews
November 11, 2022
Excellent book to start with parsing, creating interpreters, domain specific languages...
Displaying 1 - 13 of 13 reviews

Can't find what you're looking for?

Get help and learn more about the design.