This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Clojure and Scala have a lot in common. Both provide support functional-style programming and make some effort to address concurrency issues. Both provide compilation to .class files as well as interactive prompts (REPLs) for interactive development. Both enjoy support in various IDEs. Both compile to Java bytecode and run on the JVM, and both have had efforts to bring them to the .Net CLR. Both languages make it easy to use libraries provided by Java.
But of course there are also differences:
Scala's syntax is inspired by Java's, though I dare say it's got quite a bit that doesn't look that much like Java anymore. Clojure's syntax is inspired by LISP, but has its own extensions as well.
Clojure doesn't provide as much support for imperative-style programming as Scala, preferring to stay simpler and more firmly in the functional camp. In fact, simplicity and separation of concerns (not tangling different ideas into a single feature) is something you'll find throughout Clojure's design, a goal that I'm not sure Scala holds in such high regard.
Clojure never requires the types of arguments or locals to be specified in the code, falling back on runtime reflection when necessary. Scala on the other hand requires the type of everything to be known at compile time, though it does have some type inference so you don't have to write out the types of things quite as often as in Java. This is good because Scala's static type system is significantly more complex than Java's.
While I've never tried to use a Scala library from Java, my understanding is that it can be tricky and/or messy. However Clojure's gen-class and deftype macros make it easy to write very clean libraries for use in Java code that may have no idea the library it's using was written in Clojure.
I'm sure there are other significant differences, but I hope this gives you a feel for how the languages compare.
Dears Michael and Chris,
Since you are working on Scala and Clojure, do you see that Java the language has reached an end on life point?
Sure it will be still used in the enterprises as the business language but do you think it will be eventually be replaced by another language (also sometimes called Java.next)?
John Todd wrote:Since you are working on Scala and Clojure, do you see that Java the language has reached an end on life point?
Java is like the old man from the "bring out your dead" scene in Monty Python's Holy Grail. People are often claiming that it's dead, yet it keeps on ticking. I don't think Java has reached the end of its life yet.
John Todd wrote:Sure it will be still used in the enterprises as the business language but do you think it will be eventually be replaced by another language (also sometimes called Java.next)?
If history has anything to say about it then inevitably something else will come along to steal the majority share of programming job listings. Who knows what it will be. I'm hoping Clojure, but I might be a bit biased.