Chapter 12. Working with the GDK

 

This chapter covers

  • How Groovy extends the JVM
  • GDK extensions
  • Working with objects

Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer.

Fred Brooks

Learning a new programming language is a twofold task: learning the syntax and learning the standard library. Learning the syntax is a matter of days and getting proficient with new language idioms may require a few weeks, but working through a new library can easily take several months.

Luckily, no Java programmer needs to go through this time-consuming activity when learning Groovy. They already know most of the Groovy Standard Library, because that’s the set of APIs that the Java Runtime provides. You can work with Groovy by solely using objects and methods as provided by the Java platform, although this approach doesn’t fully leverage the power of Groovy.

Groovy extends this foundation by providing an extension to the core Java classes, called the GDK. The GDK includes some new classes and utility libraries, but for the most part, it seamlessly integrates with existing core Java classes like String, Numbers, Collections, and Object, offering a superset of functionality for each class. Groovy does this in a way that’s normally not possible for Java applications. Figure 12.1 provides an architectural overview.

Figure 12.1. GDK’s place in the Groovy architecture

12.1. Working with objects

12.2. Working with files and I/O

12.3. Working with threads and processes

12.4. Working with templates

12.5. Working with Groovlets

12.6. Summary

sitemap