views:

542

answers:

10

the question im asking, is it worth to learn a new language like groovy? cause if i learn groovy, it feels like i code in groovy and not java. and how smart is that when i have to be good in java to code desktop applications too in the future. so if i use groovy a lot for web applications, i will just be worse and have to start over to be good in java when i code desktop applications right?

so why don´t I just stick with java and be good at ONE language instead of having to switch between 2 languages and their syntax. Cause it would be so confusing...

+3  A: 

The Java platform is slowly starting to change direction to one where the JVM is targeted by multiple source languages (a trick .net has been showing off since day 1, but it's taking Java a while to catch up there). The Java7 classfile format is even adding a new instruction to make these dynamic languages work faster.

If you want to keep yourself current, then learning Groovy is a good way to do it, without abandoning all your investment in the Java platform.

Furthermore, Groovy (and Grails) is now maintained by SpringSource, so its popularity is only going to increase.

skaffman
The JVM has supported multiple languages since it's inception and there have been alternative JVM languages for a long time, e.g. JRuby has been around since 2001 and Jython since 1997
Don
I didn't claim otherwise. But they've had no explicit support from the JVM until now. Java7 adds a `invokespecial` bytecode instruction that allows dynamic languages to be better optimised.
skaffman
+2  A: 

Why don't you code your desktop apps in groovy too? Just because groovy is the choice of a web framework (grails) doensn't mean that you can't use it for desktop apps.

Indeed, it is great for desktop apps too. It's more a matter of dynamic or static languages...

In my opinion, it is quite good to have for each task the right language at hand. So go ahead and learn groovy - the result will be that you'll miss grovy features when you try to use java again ;-)

Ralf
ok i didn't know that. with static language one means that you have to define the data types of the variables? and with a dynamic language you don't have to?
weng
Correct. Actually, the formal terms are "statically typed" and "dynamically typed".
Carl Smotricz
@Carl: If you want to be pedantic, "dynamic typing" is a contradiction.
skaffman
I don't think so. IIRC dynamic type means the compiler infers their type during runtime. So they are typed dynamically.
Daniel Fath
@skaffman: I only wax pedantic when that helps me make somebody else look stupid. So in this case I'll gladly pass ;)
Carl Smotricz
+3  A: 

Quote:

so why don´t I just stick with java and be good at ONE language instead of having to switch between 2 languages and their syntax.

This seems like a more general question about learning programming languages than learning a new language (Groovy) which runs on top of the Java Virual Machine.

Here's a question:

Suppose you are learning a foreign language because you want to be fluent in multiple languages so you can converse with many people. You're learning German right now, but you're getting good at it, but you also want to learn Spanish. Would you just suddenly forget German if you start to learn Spanish? If you are indeed worried that you will, what would you do?

If you were going to learn Groovy, but don't want to forget how to write Java, then why not continue to use both languages at the same time?

One of the things about being a programmer is going to be learning to adapt to new technologies as they come along. It's a good thing to be able to learn new languages, as it's going to be a skill that's going to be very useful in a field which is constantly changing.

coobird
+4  A: 

I would say in general in this field it's always good to be learning. I try constantly to learn new concepts to add to my toolbox, while getting better at the core things I'm interested in like Java. I recently purchased a book on learning Clojure - another functional language for the JVM.

The downside to learning something without using it every day is that some details don't stick in your head. That said, I'm glad I spent some time with Clojure; the important stuff stuck and I know I can quickly look up the details if and when I need to. You may want to take a similar approach to Groovy.

darren
+1  A: 

First of all I'm this is a highly subjective question.

In my humble opinion it is worth learning a new language especially if it varies in paradigms (as is the case with groovy). I'm fairly young myself so for me learning a new language is not a much of hassle but the way I see it if you like the language, you estimate that coding in language X will be profitable you should learn it.

It won't hurt your resume. It won't make your head hurt (much). The only problem is, will you use it. You need to use a language to become good at it. If you are going to learn it now and never use it tomorrow it probably ain't worth learning it.

Daniel Fath
A: 

It's always good to learn a new language to be a better programmer. Groovy is a natural choice for java programmer - easy to learn and you can still use your all java knowlege.

Groovy is a dynamic language, after try to learn any functional language (like Scala). With this experience you will see java from different perspecitve. Some task that was painful in Java will be trivial in Groovy/Scala.

cetnar
you can mix them in your code like javascript and jquery?
weng
Yes, that's the power. You can call groovy form java and java from groovy. Having more 'tools' give you a choice to choose a right tool for a job.
cetnar
@noname: jquery is not a programming language, it's a "class" written in javascript. you're not mixing anything when you use jquery in javascript.
just somebody
+1  A: 

Learning something new does not take away something you already know. You may be a bit rusty when you get back into Java, but it'll come back real quick.

Also--

I'm not a Java guy, but I believe Groovy targets the JVM. If this is the case, then programming in Groovy will make you a better Java programmer, because you'll still be targeting the same framework as Java (the language) so you'll still continue to gain experience with the Java libraries. Knowing the available libraries is what really matters, not how well you know every minute detail of a particular language.

Giovanni Galbo
+5  A: 
Carl Smotricz
Thanks much for the thumbnail sketches!
larryq
+1  A: 

Going from java to groovy isn't a lot of work. No where near what would be needed to move to a less Javaish language like clojure.

I really like groovy for one-off apps and for scripting existing java code. I've used it to parse data from REST calls and feed the data to a JMS queue. I've used it to create scrambled test data for a partner from our production data. For stuff like that it is amazing.

If the goal is to learn a dynamic language to add to the toolbox, Python and Ruby are both good choices. They run on the JVM and have native versions. Both are well supported on a large number of platforms.

If the goal is to learn an alternative JVM language, groovy is an excellent choice. Both Scala and Clojure would also be good choices.

I used to stick to the "learn a new language every year rule" from The Pragmatic Programmer, but that was before I had kids. Now I learn a new building toy every six months.

sal
+1 for "before I had kids"
ammoQ
A: 

Great thread, which has wandered a bit off topic, and I'm not helping, especially finding it quite late, but with good reason.

My two strongest languages at the moment are perl & java, in that order. I recently changed jobs and here they are big on java, but perl not so much, preferring python for what little scripting they do.

I have the freedom to use groovy (as an alternative) if I don't want to use python (I've always hated the whitespace thing: flashbacks of COBOL & RPG; I could get over it though). Here's the thing though:

Are java & groovy too similar, to the point where I'd confuse them while coding?

In the same way I used to revert to C while trying to learn C++ (back before there was a java), although that might be a different problem? In the same way that you can't play both badminton and tennis well, but you can play both tennis and golf well? In the same way that a yank spending a year in France will not speak English like inspector Clousseau but after spending the year in the UK will sound a bit like Sherlock Holmes?

Or am I crazy?

Keith Wingate