Paul King

Groovy Technical Lead - OCI Groovy/Grails Team

Paul King, a member of the OCI Groovy team, leads ASERT, an organization based in Brisbane, Australia, which provides software development, training, and mentoring services to customers looking to embrace new technologies, harness best practices, and innovate. He has been contributing to open source projects for nearly 20 years and is an active committer on numerous projects, including Groovy. Paul speaks at international conferences, publishes in software magazines and journals, and is a co-author of Manning's best-seller, Groovy in Action.

Presentations

Groovy doesn't claim to be a fully-fledged functional programming language but it does provide the Java or Groovy developer with a whole toolbox of features for doing functional style programs. This talk looks at the key Groovy features which support a functional style and compares and contrasts with what is possible in Java 7 and Java 8 including Java 8 Lambda expressions and streams.

Topics covered include using closures, currying and partial evaluation, closure composition, useful functional-centric AST macros, useful functional-centric runtime meta-programming tricks, trampolining, using Java functional libraries, immutable data structures, lazy and infinite lists, using Groovy 2's static typing and approaches for moving beyond Java's type system. Examples compare Groovy with Java 8 equivalents and we show you what Groovy can do beyond Java 8.

There are many advantages to using a functional style in your programs. Learn what can be done to leverage functional style while retaining many of the productivity gains of the Groovy programming language.

This talk looks at using Groovy for writing multi-threaded, concurrent and parallel programs. We'll briefly review legacy Java techniques for writing such programs and some current best practices such as using immutable and persistent collections and leveraging some of Groovy's built-in AST transforms before jumping in and exploring the techniques offered by GPars.

Reviewed legacy Java techniques include multiple processes, multiple threads, the java.util.concurrent APIs and shared-state atomicity. We'll then explore some built-in Groovy functionality. We'll cover some useful AST transforms (Lazy, Synchronized, Immutable, WithReadLock and WithWriteLock). We'll also look at immutable and persistent collections.

GPars is a comprehensive library for parallel execution that provides a menu of options to the developer.We'll explore parallel collection support, examine Map/Reduce, Dataflow, Actors, composable asynchronous functions and the use of Agents and Active Objects. The different choices available have pros and cons depending on the circumstances. We'll provide some guidance.

We'll also briefly look at Multiverse (Software Transactional Memory) and JCSP, two emerging approaches that might appear more prominently in future versions of GPars. Then we'll wrap up with a brief look at testing multi-threaded programs.

Groovy has excellent support for the creation of Domain Specific Languages (DSLs). Such DSLs can be particularly useful when writing business rules. Rules can be written in English-like phrases which are straight-forward to read or write (by non-developers) yet can be fully executable code corresponding to a layer over the top of a traditional logic solving API. This talk illustrates various DSLs, highlights several logic solving APIs and looks at the pros and cons of the various approaches (including tool support, flexibility, lock-in).

Whilst Groovy is the language of choice for this talk, the techniques and principles are not specific to Groovy and apply readily to your favourite modern scripting language. The “logic solving” APIs being highlighted are primarily Choco, Drools Expert and Drools Planner but again these are just illustrative of the logic APIs that you can use when writing a DSL layer. We look at the benefits and costs when writing such DSL layers, numerous real-world examples and the all-important aspects of tooling; covering what non-developer, developer and cloud tooling is available with this kind of approach.

To give a flavour of the talk, here is a snippet from one of the code examples (Einstein’s riddle) - yes, this is code:

the Briton has a red house
the owner of the green house drinks coffee
the owner of the yellow house plays baseball
the person known to play football keeps birds
the man known to play tennis drinks beer
the green house is on the left side of the white house
the man known to play volleyball lives next to the one who keeps cats
the Norwegian lives next to the blue house

When discussing this example, we look at how you create and debug such code, illustrate how several APIs can be used underneath this DSL layer, discuss the costs involved in creating the above DSL in its basic form and in more complex forms that allow type checking, code completion etc. and options for parallelism and cloud deployment.

Groovy provides excellent facilities for parsing and creating XML. As well as providing syntactic sugar on top of traditional Java-based parsing approaches (e.g. SAX, DOM, StAX), it has its own XmlParser and XmlSlurper libraries which support XPath-like expressions at the object level (akin to LINQ in the .Net world). In addition, Groovy's markup builders provide an elegant and efficient way to create and modify XML.
Groovy also has various options available for SOAP and RESTful web services. We'll examine the most popular of these.

We'll cover:

  • Reading, creating and updating XML using various approaches including the pros and cons of the various parsers and markup builders
  • dealing with XML namespaces and XPath
  • using other XML frameworks: XOM, Dom4j, JDom
  • integrating with XSLT, XQuery and validators
  • treating non-XML like XML
  • GroovySOAP, GroovyWS and Spring web services
  • JAXB, XmlBeans, CXF and Axis2 for SOAP web services
  • XML-RPC and RESTful options, RSS, ATOM
  • trade-offs using Apache Xerces or with native XML support on 1.4 through to 1.7 JVMs
  • Testing Web services with SoapUI
  • A quick look at Groovy integration in common XML/web-service tools
  • Groovy use in web service related products including ESBs and SOA frameworks

Books

  • Groovy in Action: Covers Groovy 2.4- Wiley India-Dierk Konig and Paul King-2015-EDN-2

Groovy in Action

by Dierk Koenig, Andrew Glover, Paul King, Guillaume Laforge, and Jon Skeet

  • Groovy, the brand-new language for the Java platform, brings to Java many of the features that have made Ruby popular. Groovy in Action is a comprehensive guide to Groovy programming, introducing Java developers to the new dynamic features that Groovy provides. To bring you Groovy in Action, Manning again went to the source by working with a team of expert authors including both members and the Manager of the Groovy Project team. The result is the true definitive guide to the new Groovy language.

    Groovy in Action introduces Groovy by example, presenting lots of reusable code while explaining the underlying concepts. Java developers new to Groovy find a smooth transition into the dynamic programming world. Groovy experts gain a solid reference that challenges them to explore Groovy deeply and creatively.

    Because Groovy is so new, most readers will be learning it from scratch. Groovy in Action quickly moves through the Groovy basics, including:

    • Simple and collective Groovy data types
    • Working with Closures and Groovy Control Structures
    • Dynamic Object Orientation, Groovy style

    Readers are presented with rich and detailed examples illustrating Groovy's enhancements to Java, including

    • How to Work with Builders and the GDK
    • Database programming with Groovy

    Groovy in Action then demonstrates how to Integrate Groovy with XML, and provides:

    • Tips and Tricks
    • Unit Testing and Build Support
    • Groovy on Windows

    An additional bonus is a chapter dedicated to Grails, the Groovy Web Application Framework.

    Purchase of the print book comes with an offer of a free PDF eBook from Manning. Also available is all code from the book.