Groovy - Do More With Less (Code) - Talk Slides from Vancouver's 1st Groovy/Grails Meetup

I've published the talk slides introducing Groovy at Vancouver's 1st Groovy/Grails User Group event. Topics include:
  • Why Groovy? What's wrong with Ruby (JRuby), Python (Jython), or Smalltalk (Bistro)?
  • Application vs. Systems (Hard-Core) Programming / Groovy vs. Java
  • Groovy is Java
  • Groovy is Java Continued: Annotations
  • Groovy is Java Continued: Enums, Static Imports, Generics
  • Groovy Joint Compiler
  • Groovy Goodies Missing In Java (Java is Not Groovy;-)
  • Groovy Loops: Higher-Level Loops Using Closures (Code Blocks)
  • What is a Closure (Code Block/Anonymous Function)?
  • Closures In Action: Groovy Collections vs. Plain Old Java Collections
  • Groovy JDK – Groovy Adds New Methods To Core Java Classes
  • Groovy Template Strings: Expressions In Strings
  • Groovy Markup (XML) Syntax
  • Scripting Ant Using Groovy Markup (Gant)
  • Groovy Heroes – G2One Inc. – The Groovy/Grails Startup
  • Groovy/Grails in Print – Books
  • Groovy/Grails Articles & Blogs
  • Getting Started – Installing Groovy – 1-2-3 Steps
  • And more...
Questions and comments welcome.
Average: 3 (2 votes)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Gerald Bauer replied on Tue, 2008/03/04 - 12:43am

Some slide highlights:

Why Groovy? What’s wrong with Ruby (JRuby), Python (Jython), or Smalltalk (Bistro)?

Why yet another scripting language?

  1. Groovy uses a Java-like syntax; easy to switch from Java to Groovy or from Groovy to Java
  2. Groovy builds on (reuses) the Java standard class library; Ruby, Python or Smalltalk include their own batteries (that is, standard libraries)
  3. 3. Groovy compiles straight to standard Java bytecode; you can use groovyc as an alternative compiler to javac

What is Java?

  1. Java is a (systems) programming language (syntax).
  2. Java is a “standard” class library.
  3. Java is a bytecode runtime (virtual machine).

Conclusion #1, #2, #3: Groovy is Java

Groovy is Java

Groovy Standard Class Library Types == Java Standard Class Library Types

  • A Groovy String is a Java String:
$ hello = "Hello" 
$ hello.class

=> java.lang.String
  • A Groovy List is a Java List:
$ list = [ "Vancouver", "Ottawa" ]
$ list.class

=> java.util.ArrayList
  • A Groovy Map is a Java Map:
$ map = [ "Vancouver":"British Columbia", "Ottawa":"Ontario" ]
$ map.getClass()

=> java.util.LinkedHashMap

Groovy Joint Compiler

Compiles Groovy and Java code; can handle any dependency cycles Use the -j compiler switch to enable the joint compilation. Example: Country.groovy:
class Country
{
   String name
   String capital

   String toString() { return "The capital of ${name} is ${capital}." }
}
World.java:
public class World
{
  public static void main( String args[] )
  {
    Country canada = new Country();

    canada.setName( "Canada" );
    canada.setCapital( "Ottawa" );

    System.out.println( canada.toString() );
  }
}
Let’s joint compile the Groovy and Java source.
$ groovyc -j Country.groovy World.java 
That’s it. Run it.
$ java World

=> The capital of Canada is Ottawa.
Read More...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.