Groovy - a programming language to look into
So what is Groovy? Groovy is like a super version of Java. It can leverage Java's enterprise capabilities but also has cool productivity features like closures, builders and dynamic typing. If you are a developer, tester or script guru, you have to love Groovy. Below are some of it's features.
- Is an agile and dynamic language for the Java Virtual Machine
- Builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk
- Makes modern programming features available to Java developers with almost-zero learning curve
- Supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain
- Makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL
- Increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications
- Simplifies testing by supporting unit testing and mocking out-of-the-box
- Seamlessly integrates with all existing Java objects and libraries
- Compiles straight to Java bytecode so you can use it anywhere you can use Java
A simple hello world script:
def name='World'; println "Hello $name!"
A more sophisticated version using Object Orientation:
class Greet {
def name
Greet(who) { name = who[0].toUpperCase() +
who[1..-1] }
def salute() { println "Hello $name!" }
}
g = new Greet('world') // create object
g.salute() // Output "Hello World!"
Leveraging existing Java libraries:
import static org.apache.commons.lang.WordUtils.*
class Greeter extends Greet {
Greeter(who) { name = capitalize(who) }
}
new Greeter('world').salute()
Hey.....nice post!! Awesome,...
Hey.....nice post!!
Awesome, No more words to explain
:)
just....cool blog.
Post new comment