• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making Java Groovy vs Making Java Scala?

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As languages based on JVM, I'd like to know how Groovy is different from Scala. Are there some aspects that Groovy is better than Scala?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though they are both JVM languages, they share no syntactic structure.

There is very little in Groovy that would surprise a Java developer; Scala is a completely different beast.
 
Kenneth A. Kousen
gunslinger & author
Ranch Hand
Posts: 100
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scala is a statically-typed language with immutables, which most people consider a bridge language on the way to functional programming. Its biggest success stories are the Akka concurrency library and the Play framework, and Scala is used as the heart of Twitter. It's a very powerful language, but also very different from Java.

Groovy is an object-oriented language, but with some functional capabilities (like collect, findAll, and inject, which correspond to map, filter, and reduce). It cleans up Java in a variety of ways while still letting you integrate with Java on a line-by-line basis. Groovy classes can implement Java interfaces, instantiate and use Java classes, and vice versa. The blend is (almost) seamless. It's similarity to Java also makes it very easy for existing Java developers to learn.

The other major JVM language is Clojure, which is a LISP on the JVM. It's a pure functional language with immutables. If our next major paradigm shift is to functional programming, as so many have said, then Clojure is a great way to get there.

If you're considering concurrency as your biggest motivation and therefore thinking about Scala or Clojure, let me mention that the GPars library has actors, dataflows, concurrent collections, and everything else you might need. The other "breakout" projects in the Groovy ecosystem are Grails (which is a web framework but more than that), Gradle (the build tool gradually replacing Maven in the open source world), and Spock (the unit testing library).

Btw, there's no real rivalry among the three languages. Which you choose is largely a question of style and personal preference. I will say that the Groovy community is very friendly and helpful, which was a plus for me.
 
Burk Hufnagel
Ranch Hand
Posts: 814
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kenneth A. Kousen wrote:It's similarity to Java also makes it very easy for existing Java developers to learn.


To me, Groovy is to Java what Java was to C++. Groovy makes it easier to write good code faster - and as a Java developer you already know how to write Groovy code. There's niceties you can learn along the way, and using Spock for unit tests is a great way to introduce Groovy to your development team.

Burk
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will say that the Groovy community is very friendly and helpful, which was a plus for me.

From speaking to colleagues, I don't think the same can be said for the Scala community at present.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic