Domain-Specific Languages

Domain-Specific Languages

3.86 (252 ratings by Goodreads)
By (author)  , By (author) 

Free delivery worldwide

Available. Dispatched from the UK in 2 business days
When will my order arrive?


When carefully selected and used, Domain-Specific Languages (DSLs) may simplify complex code, promote effective communication with customers, improve productivity, and unclog development bottlenecks. In Domain-Specific Languages, noted software development expert Martin Fowler first provides the information software professionals need to decide if and when to utilize DSLs. Then, where DSLs prove suitable, Fowler presents effective techniques for building them, and guides software engineers in choosing the right approaches for their applications. This book's techniques may be utilized with most modern object-oriented languages; the author provides numerous examples in Java and C#, as well as selected examples in Ruby. Wherever possible, chapters are organized to be self-standing, and most reference topics are presented in a familiar patterns format. Armed with this wide-ranging book, developers will have the knowledge they need to make important decisions about DSLs-and, where appropriate, gain the significant technical and business benefits they offer. The topics covered include:* How DSLs compare to frameworks and libraries, and when those alternatives are sufficient* Using parsers and parser generators, and parsing external DSLs* Understanding, comparing, and choosing DSL language constructs * Determining whether to use code generation, and comparing code generation strategies* Previewing new language workbench tools for creating DSLs
show more

Product details

  • Hardback | 640 pages
  • 177.8 x 233.68 x 38.1mm | 1,156.65g
  • Pearson Education (US)
  • Addison-Wesley Educational Publishers Inc
  • New Jersey, United States
  • English
  • w. figs.
  • 0321712943
  • 9780321712943
  • 107,866

Back cover copy

Designed as a wide-ranging guide to Domain Specific Languages (DSLs) and how to approach building them, this book covers a variety of different techniques available for DSLs. The goal is to provide readers with enough information to make an informed choice about whether or not to use a DSL and what kinds of DSL techniques to employ. Part I is a 150-page narrative overview that gives you a broad understanding of general principles. The reference material in Parts II through VI provides the details and examples you will need to get started using the various techniques discussed. Both internal and external DSL topics are covered, in addition to alternative computational models and code generation. Although the general principles and patterns presented can be used with whatever programming language you happen to be using, most of the examples are in Java or C#.
show more

Table of contents

Preface xix Part I: Narratives 1Chapter 1: An Introductory Example 3Gothic Security 3The State Machine Model 5Programming Miss Grant's Controller 9Languages and Semantic Model 16Using Code Generation 19Using Language Workbenches 22Visualization 24 Chapter 2: Using Domain-Specific Languages 27Defining Domain-Specific Languages 27Why Use a DSL? 33Problems with DSLs 36Wider Language Processing 39DSL Lifecycle 40What Makes a Good DSL Design? 42 Chapter 3: Implementing DSLs 43Architecture of DSL Processing 43The Workings of a Parser 47Grammars, Syntax, and Semantics 49Parsing Data 50Macros 52 Chapter 4: Implementing an Internal DSL 67Fluent and Command-Query APIs 68The Need for a Parsing Layer 71Using Functions 72Literal Collections 77Using Grammars to Choose Internal Elements 79Closures 80Parse Tree Manipulation 82Annotation 84Literal Extension 85Reducing the Syntactic Noise 85Dynamic Reception 86Providing Some Type Checking 87 Chapter 5: Implementing an External DSL 89Syntactic Analysis Strategy 89Output Production Strategy 92Parsing Concepts 94Mixing-in Another Language 100XML DSLs 101 Chapter 6: Choosing between Internal and External DSLs 105Learning Curve 105Cost of Building 106Programmer Familiarity 107Communication with Domain Experts 108Mixing In the Host Language 108Strong Expressiveness Boundary 109Runtime Configuration 110Sliding into Generality 110Composing DSLs 111Summing Up 111 Chapter 7: Alternative Computational Models 113A Few Alternative Models 116 Chapter 8: Code Generation 121Choosing What to Generate 122How to Generate 124Mixing Generated and Handwritten Code 126Generating Readable Code 127Preparse Code Generation 128Further Reading 128 Chapter 9: Language Workbenches 129Elements of Language Workbenches 130Schema Definition Languages and Meta-Models 131Source and Projectional Editing 136Illustrative Programming 138Tools Tour 140Language Workbenches and CASE tools 141Should You Use a Language Workbench? 142 Part II: Common Topics 145Chapter 10: A Zoo of DSLs 147Graphviz 147JMock 149CSS 150Hibernate Query Language (HQL) 151XAML 152FIT 155Make et al. 156 Chapter 11: Semantic Model 159How It Works 159When to Use It 162The Introductory Example (Java) 163 Chapter 12: Symbol Table 165How It Works 166When to Use It 168Further Reading 168Dependency Network in an External DSL (Java and ANTLR) 168Using Symbolic Keys in an Internal DSL (Ruby) 170Using Enums for Statically Typed Symbols (Java) 172 Chapter 13: Context Variable 175How It Works 175When to Use It 176Reading an INI File (C#) 176 Chapter 14: Construction Builder 179How It Works 179When to Use It 180Building Simple Flight Data (C#) 180 Chapter 15: Macro 183How It Works 184When to Use It 192 Chapter 16: Notification 193How It Works 194When to Use It 194A Very Simple Notification (C#) 194Parsing Notification (Java) 195 Part III: External DSL Topics 199Chapter 17: Delimiter-Directed Translation 201How It Works 201When to Use It 204Frequent Customer Points (C#) 205Parsing Nonautonomous Statements with Miss Grant's Controller (Java) 211 Chapter 18: Syntax-Directed Translation 219How It Works 220When to Use It 227Further Reading 227 Chapter 19: BNF 229How It Works 229When to Use It 238 Chapter 20: Regex Table Lexer (by Rebecca Parsons) 239How It Works 240When to Use It 241Lexing Miss Grant's Controller (Java) 241 Chapter 21: Recursive Descent Parser (by Rebecca Parsons) 245How It Works 246When to Use It 249Further Reading 249Recursive Descent and Miss Grant's Controller (Java) 250 Chapter 22: Parser Combinator (by Rebecca Parsons) 255How It Works 256When to Use It 261Parser Combinators and Miss Grant's Controller (Java) 261 Chapter 23: Parser Generator 269How It Works 269When to Use It 272Hello World (Java and ANTLR) 272 Chapter 24: Tree Construction 281How It Works 281When to Use It 284Using ANTLR's Tree Construction Syntax (Java and ANTLR) 284Tree Construction Using Code Actions (Java and ANTLR) 292 Chapter 25: Embedded Translation 299How It Works 299When to Use It 300Miss Grant's Controller (Java and ANTLR) 300 Chapter 26: Embedded Interpretation 305How It Works 305When to Use It 306A Calculator (ANTLR and Java) 306 Chapter 27: Foreign Code 309How It Works 309When to Use It 311Embedding Dynamic Code (ANTLR, Java, and Javascript) 311 Chapter 28: Alternative Tokenization 319How It Works 319When to Use It 326 Chapter 29: Nested Operator Expression 327How It Works 327When to Use It 331 Chapter 30: Newline Separators 333How It Works 333When to Use It 335 Chapter 31: External DSL Miscellany 337Syntactic Indentation 337Modular Grammars 339 Part IV: Internal DSL Topics 341Chapter 32: Expression Builder 343How It Works 344When to Use It 344A Fluent Calendar with and without a Builder (Java) 345Using Multiple Builders for the Calendar (Java) 348 Chapter 33: Function Sequence 351How It Works 351When to Use It 352Simple Computer Configuration (Java) 352 Chapter 34: Nested Function 357How It Works 357When to Use It 359The Simple Computer Configuration Example (Java) 360Handling Multiple Different Arguments with Tokens (C#) 361Using Subtype Tokens for IDE Support (Java) 363Using Object Initializers (C#) 365Recurring Events (C#) 366 Chapter 35: Method Chaining 373How It Works 373When to Use It 377The Simple Computer Configuration Example (Java) 378Chaining with Properties (C#) 381Progressive Interfaces (C#) 382 Chapter 36: Object Scoping 385How It Works 386When to Use It 386Security Codes (C#) 387Using Instance Evaluation (Ruby) 392Using an Instance Initializer (Java) 394 Chapter 37: Closure 397How It Works 397When to Use It 402 Chapter 38: Nested Closure 403How It Works 403When to Use It 405Wrapping a Function Sequence in a Nested Closure (Ruby) 405Simple C# Example (C#) 408Using Method Chaining (Ruby) 409Function Sequence with Explicit Closure Arguments (Ruby 411Using Instance Evaluation (Ruby) 412 Chapter 39: Literal List 417How It Works 417When to Use It 417 Chapter 40: Literal Map 419How It Works 419When to Use It 420The Computer Configuration Using Lists and Maps (Ruby) 420Evolving to Greenspun Form (Ruby) 422 Chapter 41: Dynamic Reception 427How It Works 428When to Use It 429Promotion Points Using Parsed Method Names (Ruby) 430Promotion Points Using Chaining (Ruby) 434Removing Quoting in the Secret Panel Controller (JRuby) 438 Chapter 42: Annotation 445How It Works 446When to Use It 449Custom Syntax with Runtime Processing (Java) 449Using a Class Method (Ruby) 451Dynamic Code Generation (Ruby) 452 Chapter 43: Parse Tree Manipulation 455How It Works 455When to Use It 456Generating IMAP Queries from C# Conditions (C#) 457 Chapter 44: Class Symbol Table 467How It Works 468When to Use It 469Statically Typed Class Symbol Table (Java) 469 Chapter 45: Textual Polishing 477How It Works 477When to Use It 478Polished Discount Rules (Ruby) 478 Chapter 46: Literal Extension 481How It Works 481When to Use It 482Recipe Ingredients (C#) 483 Part V: Alternative Computational Models 485Chapter 47: Adaptive Model 487How It Works 488When to Use It 492 Chapter 48: Decision Table 495How It Works 495When to Use It 497Calculating the Fee for an Order (C#) 497 Chapter 49: Dependency Network 505How It Works 506When to Use It 508Analyzing Potions (C#) 508 Chapter 50: Production Rule System 513How It Works 514When to Use It 517Validations for club membership (C#) 517Eligibility Rules: extending the club membership (C#) 521 Chapter 51: State Machine 527How It Works 527When to Use It 529Secret Panel Controller (Java) 530 Part VI: Code Generation 531Chapter 52: Transformer Generation 533How It Works 533When to Use It 535Secret Panel Controller (Java generating C) 535 Chapter 53: Templated Generation 539How It Works 539When to Use It 541Generating the Secret Panel State Machine with Nested Conditionals (Velocity and Java generating C) 541 Chapter 54: Embedment Helper 547How It Works 548When to Use It 549Secret Panel States (Java and ANTLR) 549Should a Helper Generate HTML? (Java and Velocity) 552 Chapter 55: Model-Aware Generation 555How It Works 556When to Use It 556Secret Panel State Machine (C) 557Loading the State Machine Dynamically (C) 564 Chapter 56: Model Ignorant Generation 567How It Works 567When to Use It 568Secret Panel State Machine as Nested Conditionals (C) 568 Chapter 57: Generation Gap 571How It Works 571When to Use It 573Generating Classes from a Data Schema (Java and a Little Ruby) 573 Bibliography 579Index 581
show more

About Rebecca Parsons

Martin Fowler is Chief Scientist at ThoughtWorks. He describes himself as "an author, speaker, consultant, and general loudmouth on software development. I concentrate on designing enterprise software-looking at what makes a good design and what practices are needed to come up with good design." Fowler's books include Patterns of Enterprise Application Architecture; UML Distilled, Third Edition; and (with Kent Beck, John Brant, and William Opdyke) Refactoring: Improving the Design of Existing Code. All are published by Addison-Wesley.
show more

Rating details

252 ratings
3.86 out of 5 stars
5 27% (69)
4 41% (103)
3 25% (62)
2 5% (12)
1 2% (6)
Book ratings by Goodreads
Goodreads is the world's largest site for readers with over 50 million reviews. We're featuring millions of their reader ratings on our book pages to help you find your new favourite book. Close X