Groovy(Java on Steroids)

As every programmer starts his coding journey with a Hello world program. I decided to do the same with my first WordPress blog.

Basically this post will show how easy it is to do things in groovy than in java and be more productive.

Aim is to promote the Groovy language and Grails framework.

Here’s our classic Hello World program in java.


public class HelloWorld {
         public static void main(String[] args){
               System.out.println("Hello, World");
} }

That’s a lot of work just to print 2 words. At this stage it may seem nothing, but consider writing your complex applications with hundred lines of code to do small tasks.

More Lines of code—–>More time for small tasks—–>Less Productivity—–>Hard to debug—–>More code to test—–>More chances of doing errors—–>More Maintainability—–>More Memory—–>High chances of delivering buggy code.

There were languages like python, helping us to do same thing in one line.

But that would mean sacrificing Java, its features and security.

So here is Groovy—> Savior for Java developers.

The Groovy way of doing things…..

Here’s the Groovy 1 Liner…

println "hello, world"

As it goes in Hindi Sidhi baat,No bakwaas(Straightforward, No nonsense).

Awesome thing is we can also write java code in groovy because Groovy classes compile down to Java bytecode.

In later posts we will dig more into groovy and see how to use it for rapidly building web applications in Grails.

Happy Coding.

Image