The Hello World version of the program in Groovy! A dynamic language for the JVM runtime with a very Java-like syntax.
By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html
where I give some details on WHY these "OO Hello World series" samples.
Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet { def name Greet(name) { this.name = name[0].toUpperCase() + name[1..-1] } def salute() { println "Hello $name!" } } // Greet the world! g = new Greet('world') g.salute()
Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
package GreetProgram private class Greet { private def name public def Greet(name) { this.name = name[0].toUpperCase() + name[1..-1] } public def salute() { println "Hello $name!" } } // Greet the world! g = new Greet('world') g.salute()
The Program Output:
Groovy Info:
“Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform.
Groovy uses a Java-like bracket syntax. It is dynamically compiled to Java Virtual Machine bytecode and interoperates with other Java code and libraries. Most Java code is also syntactically valid Groovy.” Taken from: (http://en.wikipedia.org/wiki/Groovy_(programming_language))
Appeared:
|
2003
|
Current Version:
|
1.7.5 and 1.8 Beta 2 (latest version in "Languages" page)
|
Developed by:
|
Guillaume Laforge
|
Creator:
|
Guillaume Laforge
|
Influenced by:
|
Java (James Gosling)
|
Predecessor Language
| |
Predecessor Appeared
| |
Predecessor Creator
| |
Runtime Target:
|
JVM
|
Latest Framework Target:
|
JDK 6
|
Mono Target:
|
No
|
Allows Unmanaged Code:
|
No
|
Source Code Extension:
|
“.groovy”
|
Keywords:
|
57
|
Case Sensitive:
|
Yes
|
Free Version Available:
|
Yes
|
Open Source:
|
Yes
|
Standard:
|
JSR 241
|
Latest IDE Support:
|
NetBeans
Eclipse
IntelliJ IDEA
|
Language Reference:
| |
Extra Info:
|