11

For the next 3 years I will have to work with the JVM (project requirement) using a very specific third party API. They want Java but I've been given leeway to move away from Java. I was hoping we could move back to the .NET framework so I could develop code in F#, being absolutely in love with OCaml. .NET development has been struck down by our customer. It is a no go.

I've turned to looking, reading, and poking around programming blogs/forums trying to understand which language might appeal to me further: Scala or Clojure. Those seem to have the largest community/fan base. Being experienced with ML languages I see lots of people who compare Scala to ML. However, there are some real naysayers when making this comparison. If Scala was that close to ML my productivity and learning curve would benefit making this switch.

The internet is full of misinformation and wonder if I'm suffering from such. I don't like the syntax of Lisp (don't hurt me!) but if Scala has the warts I'm reading (poor IDE support, in flux Unit testing framework, performance issues) I'm wondering if Clojure is the better option. I want to be productive out of the gate, using functions as first class objects, and minimizing concurrency pain.

So anyways, before I spend too much time on the internet and not working... I'm stuck with the JVM, sick of Java and wondering where to go?

17
  • 6
    You know the alternatives, why ask here? It's mostly about personal opinion from here on. Sep 24, 2009 at 18:03
  • 2
    to a new job, so you'll work in an environment that makes you happy, and your current company can hire someone more professional
    – kdgregory
    Sep 24, 2009 at 18:03
  • 2
    And more importantly, deciding tow switch languages just because you're bored of the old one. Which means that your client will be paying for your newbie mistakes.
    – kdgregory
    Sep 24, 2009 at 18:10
  • 7
    Is it unprofessional to reach for the tools that will deliver the application the client wants faster and with fewer bugs, while retaining the same performance? Is it unprofessional to be concerned about one's produtivity and motivation, and look for ways to improve them? Is it unprofessional to state a professional opinion about the tools of your job and their aptitude to the task you are being put to? Wheaties isn't going behind his manager's back to get the job done (the job done!). Instead, he has discussed his preferences and was given freedom within limit to exercise his expertise. Sep 24, 2009 at 21:07
  • 3
    It's also unprofessional to openly insult wheaties. Give your insults one level of indirection. :-) And really, Java is verbose, I have some sympathy. That's why Scala was developed, and by the author of Sun's current Java compiler... Sep 25, 2009 at 3:22

11 Answers 11

25

In my opinion, both Clojure and Scala don't have great IDE support, if that's really important to you. That said, here's what I can collect from my reading & experience.

Scala's pros

  • Faster than Clojure thanks to more static typing
  • Closer to ML (syntax, type-directed programming)
  • Bigger standard API (Clojure's APIs grow very slowly, because they want to make sure they find the best idioms before making them public. That said, Clojure still has semi-official supplementary APIs)
  • Better integration practices with the typical Java toolset (Clojure is still making some choices, so less firmly established yet on this regard)
  • Older than Clojure (but Clojure is built on top of a very old and proven core: Lisp)
  • People say it has chances to reach mainstream, while they wouldn't say the same about Clojure

Clojure's pros

  • Incredibly easy, fast and right concurrency thanks to MVCC-based STM and other concurrency mechanisms
  • Immutability by default helps doing the right thing first
  • More stable standard API
    • When things change, usually you don't have to rewrite any existing code
    • (Scala's collections are being remade again for 2.8)
    • (I have also read somewhere that it's common knowledge that Scala's Actors implementation needs a rethinking and rewrite.)
  • Easier to learn (small language, being a (very-clean) Lisp)
  • An opportunity for you to grow by learning something different
  • Clojure's performance will only get better with time; there's still room for nice optimizations in the compiler
  • Scala's tying to Java feels more limiting than Clojure's (interactions between Scala's and Java's static type systems). One could sometimes say the same about Clojure (Object-Orientation's support is not a 1:1 fit, but support for this will soon get better)
  • Rich Hickey has a gift for making choices that put Clojure in the position of having technical leading features that will be adopted by other languages in the decades to follow. And he also has a gift for explaining them. So use them today in Clojure, or wait to use them in another language in some number of years. :)

On distributed concurrency

If your concurrency needs are distributed, Clojure doesn't yet have anything for this unless you run it on top of Terracotta or something similar, in which case you'll be able to use all its concurrency features. If you do, you will end up with a better distributed concurrency experience than with Scala's Actors, IMO.

Conclusion

IMO Scala tries to do everything, and succeeds at doing most of it. Clojure doesn't try the same thing, but what it focuses on is more than enough and succeeds so well that most people really knowing Clojure wouldn't want to go back to something else. Disclosure: my personal preference goes, of course, to Clojure. I hope I've been able to be objective in what I wrote.

2
  • You've been very objective and informational. I hadn't heard about Terracotta. One more thing to bring to my boss. Thanks again.
    – wheaties
    Sep 24, 2009 at 21:05
  • You're welcome. That said, if you consider using distributed concurrency with Clojure, make sure you search/ask the clojure google group about it; they have sometimes mentioned other choices besides Terracotta. Who knows if one of these would be a better fit for your project? I suggest searching the group for "terracotta", you'll find all discussions related to this matter, with lots of great insights. Sep 24, 2009 at 21:53
10

Have you considered Groovy? I don't think it is quite as functional as Scala/Clojure, but it's certainly a lot more functional than Java**. In general, I can get the same work done in Groovy with about 50% of the code it would take me in Java.

This is because Groovy is syntactically similar to Java and provides seamless access to the JDK libraries, but the addition of a lot of language features (closures, meta-programming, properties) and dynamic typing eliminates almost all the boilerplate associated with Java programming.

** I mean functional in the sense of 'functional programming' rather than 'working correctly'

9
  • 1
    Groovy is a great suggestion. It's similar enough to Java that it doesn't necessarily inspire fear in the hearts of Java houses, but it's similar enough to Ruby that it's a lot easier to be concise and expressive and try functional-style solutions than with plain Java.
    – Chuck
    Sep 24, 2009 at 18:28
  • Groovy, huh? I'll have to give that one some thought! Thanks for your answer. That would make the very good point Oscar Reyes brought up in his post about me working in one language, the rest working in another less of an issue.
    – wheaties
    Sep 24, 2009 at 18:58
  • 1
    That's right. But it seems Groovy has lost most of its momentum, and who knows if it'll get it back? (I have no data to prove this, other than the fact I see it less often mentioned now than the other alternatives). That said, watch out for Groovy's performance. It's definitely a lot behind Clojure's and Scala's. Plus, since you come from ML, you will find yourself quite limited on the functional programming side of the things. Sep 24, 2009 at 19:27
  • 1
    I disagree that Groovy has lost momentum recently. By way of evidence, check out the growth in Grails downloads over the last couple of years. Also, the company responsible for Groovy & Grails (G2One) were recently acquired by SpringSource, so several million of their dollars says Groovy is alive and well
    – Dónal
    Sep 24, 2009 at 20:22
  • 1
    While I have been accused in the past of dissing Groovy, I'll take this opportunity to point out that calling Groovy APIs from Java is a non-issue, while care must be taken when designing Scala code to enable seamless calling of Scala APIs from Java. Note that neither language has any problems calling Java APIs. Sep 24, 2009 at 21:12
10

I'll address the points you raised about Scala.

  • IDE support:

    Scala doesn't have the same level or IDE support Java has -- or, for that matter, that F# should have with VS10.

    That said, it has one of the best (maybe even the best?) IDE supports on JVM, outside Java. Right now NetBeans is good enough, and people have consistently said IDEA is still better (hearsay). The Eclipse plugin is unstable though.

    But you mentioned a 3-years range, and the IDE support for Scala should be greatly enhanced once Scala 2.8 is out, as it will provide some compiler-support for IDEs. There's no release date defined, but it looks to be within the next six months, maybe three. And the Eclipse plugin will be updated right along with it.

  • In flux unit testing framework:

    Yes, if you meant it is vibrant, evolving and well supported, instead of stagnant and abandoned. ScalaTest, Specs and ScalaCheck are top quality frameworks, compatible between themselves, and compatible with other Java frameworks and libraries, such as JUnit and JMock.

    The testing frameworks, in fact, are almost a child poster of what is possible with Scala.

    EDIT: Scala has basic unit test support in its standard library (scala.testing.SUnit). However, given that many superior, actively-supported and free alternatives have appeared, this has been deprecated and will likely not be part of the library shipped with Scala 2.8.

  • Performance issues:

    I'm unaware of any, aside from the fact that you can write lousy code, just as with any other language. People not used to functional programming will often do stuff that's not efficient, such as not using tail recursion, or concatenating lists, and the paradigm shift that Scala enables brings that to light.

    At any rate, you can write Scala code as fast as Java code (even faster with some upcoming features). And you can write Scala code with functional features almost as fast as Java code.

2
  • Daniel, if I could I'd give you a bump in reputation. What you say is very true of the IDE support. On unit tests, I had thought I had found misinformation regarding these. There were conflicting views from "SUnit is being deprecated" to "JUnit doesn't work on Scala." Thank you for clearing that up.
    – wheaties
    Sep 24, 2009 at 19:54
  • Ah! That makes sense. I'll complement the answer, but the short of it is that Scala (still) comes with a Unit test in its standard library, which is SUnit. While better than nothing, it has long been surpassed by the third party alternatives. Sep 24, 2009 at 20:47
9

Quite frankly, get another job.

If you are to spend the next three years feeling uncomfortable on what you're doing, you should consider looking for more attractive alternatives.

Even if you manage to get a language you like, if you are part of a team ( which I guess you are ) the rest of the team might not like that language. If the rest of them code in Java and you in "fill in the blank" programming language, then problems may arise.

It is not that bad after all.

Talk with your boss, let him know how do you feel. Start looking for alternatives and have a nice and professional "leave".

There is no reason why you can't still have a good relationship with your current boss. If eventually they have a new project for .net you may come back. Talk about that also with them. Leave your doors open.

2
  • 1
    Oscar, you raised a good point with me working in one language, the rest in another. Although I have talked to my bosses and they're ok with me going this route as long as my productivity increases. I won't leave a job just because I don't get to work in my language of choice.
    – wheaties
    Sep 24, 2009 at 19:01
  • I think the choice of language is a perfectly valid reason for leaving a job :) or even a girlfriend or wife! Feb 6, 2015 at 15:39
6

Its not really a zero sum game, learn them all!
ps: i vote for Clojure, i find it the most fun!

5

You should consider yourself lucky that you can use the JVM, because the JVM is becoming more and more popular for alternative programming languages than Java.

Besides Java there's Groovy, Scala, Clojure (a Lisp dialect on the JVM), JRuby (Ruby on the JVM), Jython (Python on the JVM), Jaskell (Haskell on the JVM), Fan (runs on the JVM as well as the .NET CLR) and lots more, and there's also an OCaml-Java, OCaml that runs on the JVM.

So, there's lots of choice in programming languages on the JVM, from purely functional to simple scripting and anvanced OO languages.

3
  • It's been years since the last time I took a look at Fan. Interestingly, it looks much more interesting than Groovy! "Productivity of Ruby, Performance of Java". See fandev.org Sep 24, 2009 at 19:51
  • Lol, I am lucky to be using the JVM but I can always have hope that one day I'll find myself working with a language which mirrors all my loves. Didn't mean to come across as totally opposed to the JVM. I'm more opposed to working with Java and all its warts. Before I get flamed... All languages have warts, it's just which ones you're willing to handle.
    – wheaties
    Sep 24, 2009 at 21:09
  • That's right, Java, the One language under the Sun with Dozens of Thousands of Classes in its APIs. :D Sep 24, 2009 at 21:55
3

Tool support for Scala and Clojure may be immature, but it's steadily improving.

Since you like F#, then Scala is most likely your best bet. I say try it out and form your own opinion - you might find that the things people gripe about are things that don't matter to you, or things you can work around.

0
2

Don't forget jRuby, and note that an IDE is optional for non-Java

I think you have a great situation. How many people get permission to choose the implementation language? With everything available for the JVM having your environment chosen is not much of a restriction.

  • You won't need great IDE support in the less verbose languages
  • In a language as powerful as Ruby with no type declarations, you don't need an IDE at all
  • Scala was developed specifically to cure the verbose-java-blues
  • Count yourself lucky that you have three years of work lined up :-)
  • Clojure might be fun and provides functional concurrency-safe design patterns
1
  • You're right. I am very, very lucky that I've been given permission to explore languages. I have heard wonderful things about Ruby. Hasn't it been described as "Perl without the baggage?" However, does it reduce concurrency pain? The client would like to see more emphasis on scalability.
    – wheaties
    Sep 25, 2009 at 12:14
0

Noop? http://code.google.com/p/noop/ (experimental though)

1
  • Can't go with something too experimental. That's why I was limiting myself to Scala/Clojure. Scala has already been shown to work in industry while Lisp has been around for ages.
    – wheaties
    Sep 24, 2009 at 18:16
0

In terms of IDE support and other doubts you're having, Clojure doesn't do any better than Scala. And for a person with ML/F# background (or generally that in strictly, statically typed FP languages), you'll definitely find Scala much closer to what you're used to.

1
  • Damn. I was hopeful it might. Thanks.
    – wheaties
    Sep 24, 2009 at 21:04
0

If you like ML you might like CAL which is more-or-less Haskell 98 for the JVM.

It is high quality and very stable, and has good IDE support on Eclipse, but sadly is no longer under active development.

Not the answer you're looking for? Browse other questions tagged or ask your own question.