Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages
Developers crave the power of creating their own domain-specific languages. It’s a very practical, productive technique that lets developers boost their productivity by building applications that are tailor-made for their unique requirements. However, most books on language development can be a waste of time. They dwell on building compilers and give the impression that language development requires a lot of theoretical computer science.
Terence Parr shatters that impression in his new book, Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages (Pragmatic Bookshelf, $34.95). Using detailed descriptions of 31 language patterns—common data structures, algorithms, or strategies—Parr demystifies the universal elements of languages. The patterns aren’t presented as language design theory or a library of language implementations, they’re presented as tools for developing modest, day-to-day language applications. This is language development put to pragmatic use.
Organized into four parts, the book leads readers to a rich understanding of DSLs and general-purpose programming languages. First, Parr presents the overall architecture of language applications and the key patterns of language recognition (parsing). Next, he uses parsers to build trees that represent language constructs in memory. By “walking the trees,” language developers use patterns that check whether input streams make sense. Then, in the third part, Parr reveals patterns for high-level and bytecode interpreters. Last, he shows how to translate languages and generate text using the StringTemplate template engine. Drawing on the architecture of some interesting language applications, readers then launch into building their own languages.
Readers apply the patterns toward building configuration file readers, data readers, model-driven code generators, source-to-source translators, source analyzers, and interpreters. Code snippets and implementations are written in Java and ANTLR (the well-known parser generator that Parr created).
But you’re not limited to Java or ANTLR. As Parr points out, “You’ll have no problem transferring your knowledge to other tools after you finish the book. It’s like learning to fly—you have no choice but to pick a first airplane. Later, you can move easily to another airplane. Gaining piloting skills is the key, not learning the details of a particular aircraft cockpit.”
No longer is language development the dark art of computer scientists. Using the patterns shared by programming languages, developers can reap the rewards of building DSLs. Language Implementation Patterns gives developers true power: the power to code in their own language.
What People Are Saying
“Throw away your compiler theory book! Terence Parr shows how to write practical parsers, translators, interpreters, and other language applications using modern tools and design patterns. Whether you’re designing your own DSL or mining existing code for bugs or gems, you’ll find example code and suggested patterns in this clearly written book about all aspects of parsing technology.” —Guido van Rossum, Creator of the Python language
About the Author
Terence Parr is a professor of computer science and graduate program director at the University of San Francisco, where he continues to work on his ANTLR parser generator (http://www.antlr.org) and template engine (http://www.stringtemplate.org). Parr has consulted for and held various technical positions at companies such as IBM, Lockheed Missiles and Space, NeXT, and Renault Automation. He is also the author of The Definitive ANTLR Reference (Pragmatic Bookshelf).
Language Implementation Patterns
Create Your Own Domain-Specific and General Programming Languages
ISBN: 9781934356456, 378 pages, $34.95US, $43.95CA, 7.5×9.
Pragmatic Bookshelf Titles are distributed to bookstores internationally by O’Reilly Media.
Sample chapters, table of contents, and more information is available on the book’s home page.
About Pragmatic Bookshelf
The Pragmatic Bookshelf features books written by developers for developers. The titles continue the well-known Pragmatic Programmer style, and continue to garner awards and rave reviews. As development gets more and more difficult, the Pragmatic Programmers will be there with more titles and products to help programmers stay on top of their game.
Press and Editorial Queries Only:
Contact Andy Hunt or Dave Thomas
800-699-7764 (+1 919-847-3884)