Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Introducing Groovy

Started by James Strachan in 2003, the main objective of Groovy is to provide an agile and dynamic language for the JVM, with features inspired from other popular scripting languages including Python, Ruby, and Smalltalk. Groovy is built on top of Java, extends Java, and addresses some of the shortcomings in Java.

In the following sections, we will discuss some main features and concepts behind Groovy and how it supplements Java to address specific application needs. Note that many features mentioned here also are available in other scripting languages (for example, Scala, Erlang, Python, and Clojure).

Dynamic Typing

One main difference between Groovy (and many other scripting languages) and Java is the support of dynamic typing of variables. In Java, all properties and variables should be statically typed. In other words, the type should be provided with the declare statement. However, Groovy supports the dynamic typing of variables. In Groovy, dynamic typing variables are declared with the keyword def.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial