Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knowing the fundamentals of Java what is the right approach to learn Groovy?

Tags:

java

groovy

As my question already implies I want to learn a new language and have read several articles about groovy and its more pragmatic syntax. SO I have choosen Groovy as the language of my choice.

What is a good way to learn a new language like Groovy when I already know the fundamentals of Java. When I understand correctly Groovy will be running in the Java Virtual Machine and allows me to always rely on what I know from Java when I don't know how to solve the problem in Groovy.

I am looking for hints on how to organize a learning track to learn this language. I found that page explaining the differences: http://groovy.codehaus.org/Differences+from+Java But what I am looking for is more a tutorial where I can get through and get introduced to the differences.

like image 233
Liuh Avatar asked Apr 10 '10 12:04

Liuh


2 Answers

There are a couple of articles which have been written with that specific goal in mind: "From Java to Groovy in a few easy steps", part 1 and part 2. They were written by Gillaume Laforge, one of the masterminds behind Groovy. The articles are well written, easy to follow and provide a nice introduction for Java developers. Also, there is the Beginners tutorial in the official Groovy documentation.

Once comfortable with the basics, it's easy to move on to the on-line Groovy task-specific documentation.

like image 100
Tomislav Nakic-Alfirevic Avatar answered Sep 21 '22 00:09

Tomislav Nakic-Alfirevic


Personally I find that referencing an old language that I know to learn a new language is not a good idea. The reason I say this is that in a new language you want to learn to express and use data structures, idioms, style, etc in THAT language. You want to Groovy developers to say that the code is written by a Groovy developer rather than a Java developer.

An example, using Groovy and Java, is that Java developers tend to use a loop for collections, but in Groovy tend to use closure. They may look the same, but they are not. In Java we are applying to data to the code, whereas in Groovy we are applying the code to data. Learning this subtle difference is important to understanding the rest of Groovy API and will help you to grasp that concept.

Also I think that this approach of learning a new language referencing and old might not work that well with other styles of programming like functional.

like image 20
Chuk Lee Avatar answered Sep 21 '22 00:09

Chuk Lee