Programming Language Blues

16 11 2011

I spent some time recently putting together a list of pros and cons for various programming languages for a large (thousands of devs) Java shop that tests after in Ruby. (Ruby 1.8, not JRuby.) We’re bucking for approval to write a greenfield project in something more modern than Java.

The project will require high-volume data processing.  There’s a big relational database, many MQ queues, and web services galore.  We’ll be modifying a couple of existing web applications, but not writing any from scratch–at least not of any significant size.

Several folks on Twitter have requested to see the list; here it is. If you read carefully, you may detect the barest hints of bias.  Enjoy.

Java Advantages:

1. Lots of people know Java.

2. Extensive installed base of support in the form of software libraries.

Java Disadvantages:

1. Difficult to learn in a modern Agile TDD environment, because it predates many of the concepts on which Agile and TDD are based.

2. Very verbose, compared to modern languages. Example:

Groovy:
def ageMap = [Kurt: 29, Dan: 45]
Scala:
val ageMap = Map ("Kurt" -> 29, "Dan" -> 45)
Clojure:
(let [age_map {:Kurt 29 :Dan 45}])
Ruby:
ageMap = {'Kurt' => 29, 'Dan' => 45}
Haskell:
let ageMap = Map.fromList [("Kurt", 29), ("Dan", 45)]
Java:
Map<String, Integer> ageMap = new HashMap<String, Integer> ();
ageMap.put ("Kurt", 29);
ageMap.put ("Dan", 45);

3. Weighted down with obsolete concepts the rest of the community has moved away from, like checked exceptions and static typing without type inference.

4. Glaring lack of closures.

5. Compulsively imperative syntax in a season where the industry is of necessity moving toward functional programming.

6. Concurrency primitives are very low-level; hence non-trivial concurrent programming is nearly impossible to get right and nearly impossible to fix if it’s not gotten right.

7. JUnit, the most popular testing framework, is definitely showing its age alongside more modern rspec-like frameworks; Java syntax pretty much precludes anything rspec-like that’s not distracting kludgework.

Groovy Advantages:

1. Dynamic typing makes writing powerful tests very easy.

2. Almost a superset of Java; easy to learn for Java programmers. (Most .java files will compile and run without modification as .groovy files.)

3. Receptive to a functional style of coding.

4. Much more concise than Java; therefore less error-prone.

5. Modern testing frameworks already exist for Groovy.

6. JVM language; compiles to .class files just like Java; instantly and completely compatible with all existing Java libraries and frameworks.

7. Healthy and growing Groovy community.

Groovy Disadvantages:

1. Over-use of dynamic typing can make program code difficult to read.

2. Dynamic typing means the compiler can offer much less help than in a statically-typed language.

3. Dynamic typing means that deciding at runtime what a given method call means is a non-trivial operation; performance is lower than statically-typed Java, for which the meaning of a method call is always clear.

4. IDE plugins for Groovy are notoriously bad, both because Groovy’s dynamic nature fundamentally limits the amount of help they can provide, and because they’re immature software. IntelliJ IDEA has the best Groovy plugin, but it’s still bad compared to the worst Java plugin. (Update: I’ve been informed that the Groovy plugin for the SpringSource Tool Suite version of Eclipse is much improved in its newest version; I haven’t been in STS for a number of months.)

5. No better than Java at concurrency.

Scala Advantages:

1. Statically typed, so that the compiler can give significant help and performance is at the same level as Java.

2. Much more powerful and flexible type system than Java’s.

3. Smart type inference engine, so that types are not overspecified and change is easier.

4. Syntax is more logically consistent than Java’s; easier to learn for beginning developers than Java.

5. Tremendously powerful language in general; ease of writing domain-specific languages in Scala means that it can be made even more powerful in particular areas of interest.

6. Functional programming is built into the language, although imperative programming is made simple as well.

7. Significantly more concise than Java.

8. Features such as implicits provide many of the advantages of a dynamic language without the disadvantages.

9. High-level concurrency primitives–actors, in particular–are built right into the language.

10. XML is native syntax in Scala: you can write XML literals in Scala without putting them in strings.

11. Enough like Java that Java programmers can quickly learn the Java-like imperative side of Scala and become productive, then absorb the goodness of the language more slowly.

12. Modern rspec-like testing frameworks exist for Scala–for example, ScalaTest.

13. JVM language; compiles to .class files just like Java; instantly and completely compatible with all existing Java libraries and frameworks.

14. A prospective hire who knows Scala is likely to be a significantly better developer than a prospective hire who only knows Java.

15. If you spec a project in Scala, and word gets out that you’re becoming a Scala shop, throngs of said significantly better developers will be pounding on your doors to get away from J2EE.

16. Large and growing Scala community; may be the fourth most popular language behind Java, C#, and Ruby.

Scala Disadvantages:

1. Powerful syntax requires powerful compiler; compile time can be twice or three times as slow as Java.

2. Scala programmers don’t grow on trees (although they’re not that hard to create), and Scala shops attract the ones who already exist.

3. Scala IDE plugins are, like Groovy plugins, still immature; but Scala plugins can provide more assistance than Groovy plugins because Scala is statically typed.

Clojure Advantages:

1. By far the coolest language in common use today, except for J and maybe Erlang.

2. Almost completely functional; provides future-proofing against the coming wide swing toward functional programming, and eliminates much of the hassle associated with writing tests for imperative languages.

3. More flexible and powerful than an object-oriented language–especially a partially-OO language like Java; can be made to act OO for people who are uncomfortable outside OO.

4. Much more concise than Java.

5. Optionally-typed; dynamic typing when flexibility is needed, static typing when performance is needed.

6. The testing framework distributed with the language itself, clojure.test, already beats JUnit.

7. High-level concurrency primitives–agents, futures, promises, and software transactional memory, in particular–are built right into the language.

8. JVM language; compiles to .class files just like Java; completely compatible with all existing Java libraries and frameworks.

9. Small but growing Clojure community.

Clojure Disadvantages:

1. Syntax is wildly different from anything most Java programmers have seen before.

2. Imperative programmers will be uncomfortable at first with the functional style of coding that Clojure pushes heavily.

3. Clojure programmers don’t grow on trees, and are not easily created unless they already have a passion for learning.

4. Lisps have always had academic interest, but every Lisp so far has faded eventually into obscurity in the business world. If ever a Lisp could succeed, it seems Clojure has the best chance; but Clojure may end up fading too.

Ruby Advantages:

1. Dynamic typing makes writing powerful tests very easy.

2. Receptive to a functional style of coding.

3. Much more concise than Java; therefore less error-prone.

4. The original rspec was written for Ruby; JUnit & Co. cough and choke in its dust.

5. Ruby community is the third largest after Java and C#. Ruby programmers are easy to find.

Ruby Disadvantages:

1. Syntax is different enough from Java to make for a fairly steep learning curve (steeper than Scala, not as steep as Clojure).

2. Ruby is notoriously slow, especially in its own virtual machine.

3. Not a JVM language; no access to existing Java libraries or frameworks; if used with JVM languages, much code will need to be duplicated.

4. Dynamic typing means the compiler can offer much less help than in a statically-typed language.

5. Ruby is no better than Java at concurrency.

Haskell Advantages:

1. Pure functional language–or as pure as it gets, anyway. All data is immutable. Easy to test, easy to understand, easy to reason about.

2. Statically typed, with a type system so powerful that Haskell programmers claim, with some justification, that the compiler can find all your bugs before you even run the code.

3. Powerful high-level semantics offer both conciseness and descriptiveness.

4. Performance is high.

Haskell Disadvantages:

1. Syntax and semantics are both wildly different from anything most Java programmers have seen before.

2. Imperative programmers will be uncomfortable at first with the functional style of coding.

3. Haskell programmers don’t grow on trees, and are not easily created unless they already have a passion for learning.

4. Not a JVM language; no access to existing Java libraries or frameworks; if used with JVM languages, much code will need to be duplicated.

Advertisements

Actions

Information

2 responses

21 11 2011
Mike Cornell

I think you’re discounting JRuby a little here. JRuby interacts quite well with the JVM. A library like Celerity, which wraps the Java HtmlUnit library with a Ruby Watir interface is proof of this.

https://github.com/jarib/celerity/blob/master/lib/celerity/htmlunit.rb

A simpler example can be found here:

https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby

One thing to consider is to be sure that you use the Ruby standard of Snake Casing methods for your Ruby code, which makes it more obvious when you’re calling Camel Cased Java methods.

Additionally, JRuby is taking advantage of InvokeDynamic. We saw a 20% decrease in time for our Celerity Suite to run when we switched to JDK 7 and JRuby 1.6.4.

22 11 2011
Dan Wiebe

Exactly the sort of comment I was looking for. I have no experience with JRuby, only with the “real thing,” and my client is uninterested in JRuby as well; so it’s good to have info from someone in the know.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: