I am a java developer and I want to know, what is the main benefit from learning a language such as Scala or Groovy?
Scripting language advantages inside jvm. Seamless interaction with compiled java code.
You can get the same benefit from learning another JVM language as learning any new language. It increases your understanding of programming in general and more importantly, it adds another tool to your toolbox.
So the next time you have to solve a problem, you may reach for a nail gun instead of a hammer.
To be more specific, Groovy is a good language for mocking up code quickly, and Scala, while I've never used it, is suppose to great for writing concurrent applications due to it's functional approach. As others have mentioned, the JVM languages can interact with Java code. Which can be useful for adding onto legacy systems or for mocking up pieces of a application quickly.
from http://groovy.codehaus.org/:
"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."
So in many cases it does make sense to use Groovy over Java; For instance in Java unit tests!
Because then you'll know a new language, which means a broader skill set and another way of looking at problems. But because Groovy and Scala run on the JVM and you know Java, you can integrate existing libraries and code if you want or need to.
I know with Groovy, you can load scripts (from files) at runtime from your Java application. This allows me to customize the behavior of application actions at a client site without requiring me to recompile code. It's rather lovely.
The languages you've mentioned practice a different programming paradigm that could help you be more productive. They are also more fun to work with.
Languages such as Scala and Clojure run on the JVM and exhibit great performance in multi-core systems without imposing synchronization requirements.
And of course you are still able to use the full wealth of libraries that are available for Java.
The other answers here have very good points, but there's one thing I'm missing.
A good coder rarely identifies himself as a 'Java developer', a 'Python developer' or any ' developer'. Learning another language (be it a JVM language or not) will make you understand there's a lot more in the world to learn.
If you're satisfied with only one language, it usually means you're oblivious to the problems it has, and that there are many tasks that are better suited for other languages.
This is why the Pragmatic Programmers encourage every programmer to learn a language a year.
Sorry more questions then answers..
- What would you spend your time on if you are not learning a new language?
- Why are you limiting yourself to JVM languages?
- Would it be of more benefit to learn test driven development?
- What about learning standard design patents?
- What are you trying to achieve with your investment of time?
Learning a language is always good, however if you don’t learn them very well and use them you don’t get a great benefit, as you need to be able to “think in a language” so as to broaden your mind.
Using more than one language in a company leads to lots of additional long term costs so you may gain more by learning how to programme better in your main language, only you can decide.
Some good reasons that come to mind:
- They have features that Java doesn't have and that you may find useful in certain circumstances.
- They use different programming paradigms, different way of thinking.
- Learning other languages opens your mind.
- Learning languages makes you conscious about their respective strengths and weaknesses.
- They are getting more and more attention and better JVM support (with Java 7).
Actually, maybe ask yourself the reverse question:
- Why not learn an addiitional JVM language?