Groovy for Domain-specific Languages - Second Edition

Extend and enhance your Java applications with domain-specific scripting in Groovy

Groovy for Domain-specific Languages - Second Edition

Progressing
Fergal Dearle

1 customer reviews
Extend and enhance your Java applications with domain-specific scripting in Groovy
$39.99
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to learn new skills. Cancel anytime.

Preview in Mapt

Book Details

ISBN 139781849695404
Paperback386 pages

Book Description

The times when developing on the JVM meant you were a Java programmer have long passed. The JVM is now firmly established as a polyglot development environment with many projects opting for alternative development languages to Java such as Groovy, Scala, Clojure, and JRuby. In this pantheon of development languages, Groovy stands out for its excellent DSL enabling features which allows it to be manipulated to produce mini languages that are tailored to a project’s needs.

A comprehensive tutorial on designing and developing mini Groovy based Domain Specific Languages, this book will guide you through the development of several mini DSLs that will help you gain all the skills needed to develop your own Groovy based DSLs with confidence and ease.

Starting with the bare basics, this book will focus on how Groovy can be used to construct domain specific mini languages, and will go through the more complex meta-programming features of Groovy, including using the Abstract Syntax Tree (AST). Practical examples are used throughout this book to de-mystify these seemingly complex language features and to show how they can be used to create simple and elegant DSLs. Packed with examples, including several fully worked DSLs, this book will serve as a springboard for developing your own DSLs.

Table of Contents

Chapter 1: Introduction to DSLs and Groovy
DSL – a new name for an old idea
Groovy
Summary
Chapter 2: Groovy Quick Start
Installing Groovy with GVM
How to find and install Groovy from binaries
Running Groovy
The Groovy IDE and editor integration
Summary
Chapter 3: Essential Groovy DSLs
Installing Gradle
Gradle basics
Spock tests
Further reading
Summary
Chapter 4: The Groovy Language
Introducing the Groovy language
Summary
Chapter 5: Groovy Closures
What is a closure?
Closures and collection methods
Closures as method parameters
Calling closures
Finding a named closure field
Closure parameters
Closure return values
The closure scope
Summary
Chapter 6: Example DSL – GeeTwitter
Twitter
Working with the Twitter APIs
Groovy improvements
Removing the boilerplate
Adding a command-line interface
Adding built-in methods
Summary
Chapter 7: Power Groovy DSL Features
Named parameters
Command chains
Builders
SwingBuilder
Method pointers
Metaprogramming and the Groovy MOP
How builders work
ExpandoMetaClasses
Summary
Chapter 8: AST Transformations
What is an AST
Compiler phases
Local AST transformations
Using ASTBuilder
Global AST transformations
Summary
Chapter 9: Existing Groovy DSLs
Grails object relational mapping – GORM
Spock as a DSL
Summary
Chapter 10: Building a Builder
The builder code structure
BuilderSupport
FactoryBuilderSupport
Summary
Chapter 11: Implementing a Rules DSL
Groovy bindings
Building a rewards DSL
Summary
Chapter 12: Integrating It All
Groovy as a teaching language
A game DSL for kids
A game DSL – goals
Summary

What You Will Learn

  • Familiarize yourself with Groovy scripting and work with Groovy closures
  • Use the meta-programming features in Groovy to build mini languages
  • Employ Groovy mark-up and builders to simplify application development
  • Familiarize yourself with Groovy mark-up and build your own Groovy builders
  • Build effective DSLs with operator overloading, command chains, builders, and a host of other Groovy language features
  • Integrate Groovy with your Java and JVM based applications

Authors

Table of Contents

Chapter 1: Introduction to DSLs and Groovy
DSL – a new name for an old idea
Groovy
Summary
Chapter 2: Groovy Quick Start
Installing Groovy with GVM
How to find and install Groovy from binaries
Running Groovy
The Groovy IDE and editor integration
Summary
Chapter 3: Essential Groovy DSLs
Installing Gradle
Gradle basics
Spock tests
Further reading
Summary
Chapter 4: The Groovy Language
Introducing the Groovy language
Summary
Chapter 5: Groovy Closures
What is a closure?
Closures and collection methods
Closures as method parameters
Calling closures
Finding a named closure field
Closure parameters
Closure return values
The closure scope
Summary
Chapter 6: Example DSL – GeeTwitter
Twitter
Working with the Twitter APIs
Groovy improvements
Removing the boilerplate
Adding a command-line interface
Adding built-in methods
Summary
Chapter 7: Power Groovy DSL Features
Named parameters
Command chains
Builders
SwingBuilder
Method pointers
Metaprogramming and the Groovy MOP
How builders work
ExpandoMetaClasses
Summary
Chapter 8: AST Transformations
What is an AST
Compiler phases
Local AST transformations
Using ASTBuilder
Global AST transformations
Summary
Chapter 9: Existing Groovy DSLs
Grails object relational mapping – GORM
Spock as a DSL
Summary
Chapter 10: Building a Builder
The builder code structure
BuilderSupport
FactoryBuilderSupport
Summary
Chapter 11: Implementing a Rules DSL
Groovy bindings
Building a rewards DSL
Summary
Chapter 12: Integrating It All
Groovy as a teaching language
A game DSL for kids
A game DSL – goals
Summary

Book Details

ISBN 139781849695404
Paperback386 pages
Read More
From 1 reviews

Read More Reviews