Showing posts with label Scala. Show all posts
Showing posts with label Scala. Show all posts

Sunday, May 3, 2009

Groovy versus Scala (Update)

Back in March of last year, I wrote a post comparing Groovy and Scala.  Enough time has passed that I thought it was worth revisiting the topic.

In my original post, I reached the conclusion that at least for me, it made sense to first focus on Groovy and then later learn more Scala.  I still feel that way, but my thoughts on the matter have evolved.  How about combining Groovy and Scala in the same program or architecture?  That thought had vaguely occurred to me already, but it was solidified by the discussion of Twitter’s use of Ruby and Scala.  They started off using Ruby (Ruby on Rails, in particular) to run their whole site.  When they ran into performance and scalability issues, they determined what was causing the most trouble (back-end tasks) and gradually converted the relevant parts of the system into Scala.  This kind of polyglot programming makes sense to me.  It follows the principle of “using the best tool for the job.”  I think the combination of Groovy and Scala makes even better sense: they’re designed to run and interoperate with other languages on the same VM.  Not surprisingly, I’m not the first person to think of this.  I found two posts from Andres Almiray (“Griffon: Groovy & Scala working together” and the follow up “Follow up on Griffon/Groovy/Scala”) showing some practical examples and another on a different blog discussing the ability jointly compile “Groovy+Scala+Java”.  I’m excited to watch and perhaps participate in these exciting developments.

Side Note: On the subject of Groovy, when my one-year IntelliJ license was close to expiring, I decided to check out NetBeans.  I was pleased to discover it had quite good Groovy and Grails support.  I’ve been using the 6.7 milestone builds and now the beta, in order to get support for Grails 1.1.  If you haven’t tried Groovy/Grails development in NetBeans yet, you should.

Update: Here are links to the items Andres mentioned in the comments

Update (Jan 12, 2010): Andres recently posted the highly relevant Groovy & Scala: a tale of two JVM languages

Saturday, March 8, 2008

Groovy versus Scala

After looking at Groovy and Scala for a bit, I've come to a decision about how I plan to learn and work with them in the near future. I'm going to learn and use Groovy first and then move on to Scala. In this post, I'll explain why.

First, I'll cover the areas in which I see the two languages as similar. They are both script-friendly, object-oriented, can integrate easily with Java libraries and run on a JVM, and make heavy use of closures. Once you're familiar with either of the languages, it's obvious that they'd be great for dashing off a quick script. At the same time, their fundamental OO natures helps you produce (but does not guarantee!) maintainable code. Being able to use and interact with Java code means that you can take advantage of investments in existing technologies and that you can gradually transition a code base from Java to Groovy or Scala. Closures are a very succinct, clear way of expressing solutions to a lot of common problems. Whether or not Java gets them as a language feature, they're unlike to work as well in Java as in these two languages, where they haven't been shoehorned in.

Of course, there are also ways that the languages and developing in them are different. Scala has a greater emphasis on functional programming, has implicit static typing, and (having looked at a decompiled bytecode generated by scalac and groovyc using Jad) appears to translate into tighter code. On the other hand, Groovy looks much more like Java (making the transition easier), Sun has endorsed Groovy, the development tools for Groovy are currently in better shape (and that's without trying what they've got in NetBeans), and Grails seems like a very promising application framework.

So, when I put all of those considerations together, blended them a bit, and took a drink, I decided that Groovy should come first. It helped me make the decision to realize that whatever time and energy I put into Groovy should pay off when it comes time to move on to Scala. I think the languages require a similar mindset and follow similar enough philosophies that once I've got one down, the other should be substantially easier.

Wednesday, January 30, 2008

Scala Links

Well, I said I'd have more Scala links, so here they are: If anyone else provides links (that aren't already on the first page linked above), I'd be happy to add them.

Wednesday, January 16, 2008

Experimenting with Scala

Although I'm really comfortable with Java and like it a lot, I came to the conclusion a while ago that I needed to add a language to my repertoire that facilitates rapid development. I know some JavaScript (which is actually a more powerful language than you might think), PHP, and Perl, but none of those quite fit the bill. I've been considering Python and Ruby for a while, but I've recently gotten very interested in Scala. I bought the e-book Programming in Scala available at Artima. I'll let you know what I think of it, along with posting a bunch of useful Scala-related links I've tracked down.