We recently started off on a couple of projects that target the JVM. The team had no prior Java experience but had worked on C#/.Net. We found Java tedious and ceremonial and decided to investigate the other languages that target the JVM – Groovy, Scala and Clojure. These notes summarize findings based on my interpretation of the language specs, examples and scanning the project sites. They are not based on any real programming experience on these languages.

1. Groovy

  • Language
    • Syntax very similar to Java, therefore easy for a Java programmer to pick up. Semantically seems to be influenced from Ruby
    • Scripting language – the engine can be used in the JSR 223: Scripting for the Java Platform API classes
    • Dynamically typed
    • Eagerly evaluated
  • Why not use JRuby or Jython instead to target the JVM?
    • Groovy is targeted to the Java developer – superset syntax and tighter integration
    • So if you have a background with Python or Ruby, you would use JRuby or Jython. Java libraries syntax may feel awkward while being called from a Ruby / Python
  • Frameworks
    • Grails – Rails inspired
    • Griffon – for the desktop
  • Projects – http://groovy.codehaus.org/Related+Projects
  • Books – Groovy in Action seems to be the authoritative one
  • Community – http://groovy.codehaus.org/Community+and+Support

 

2. Scala

  • Language
    • Statically typed, Type inferred
    • Not a scripting language like Groovy
    • OO with functional features
    • Targets both JVM and CLR (with quirks)
    • Eagerly evaluated
    • Higher order functions
    • Automatic closures
    • Mixins and Traits
    • List Comprehensions
    • No concept of static (fields, methods, classes) – singletons instead
    • Tail call optimization
    • Concurrency support – Actors (like Erlang)
  • Frameworks – Lift – Rails like
  • Books – Programming in Scala – written by Martin Odersky himself
  • Community – http://www.scala-lang.org/node/1707

 

3. Clojure

  • Language
    • Lisp dialect that targets the JVM and the CLR
    • Focus on functional programming and concurrency
    • Immutable objects
    • Macros
    • Multi-method dispatch instead of OO (see http://en.wikipedia.org/wiki/Multiple_dispatch to understand this)
    • Tail call optimization – via recur
    • Concurrency support – Refs (STM), Agents and Atoms
  • Books – Programming Clojure
  • Community – http://clojure.org/community

 

Conclusion

  • Groovy – If you are an experienced Java programmer and need to do scripting work.
  • Clojure – If you have a Lisp background and want to target the JVM. Take the high ground on concurrency – very promising.
  • Scala – If you want sophistication, and the best of OO and functional. Most impressive.
  • Cool part is that like the CLR, you can do language interop here – so choose the best language for the job

Personally, I am excited about Scala – I think it will replace Java as the mainstream language on the JVM in the long-term. Clojure is exciting because I always wanted to learn Lisp – here’s the perfect opportunity!

  • No name

    interesting… thanks for sharing… Groovy has another small advantage… Its being supported by spring now… check http://www.springsource.com/products/grailsWould love to check other two languages soon…And ya… a post after loooong time… :)

  • Janakiram MSV

    Dude – Good to see your long blog post after a long gap! Call me when you are free.- Janakiram

blog comments powered by Disqus