Meaningless Drivel is fun!*
The moose likes Clojure and the fly likes clojure vs scala Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Clojure
Bookmark "clojure vs scala" Watch "clojure vs scala" New topic
Author

clojure vs scala

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

How do they compare against each other ?


Groovy
Chris Houser
author
Greenhorn

Joined: Feb 07, 2011
Posts: 22

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.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

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)?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Thanks Chris. Like groovy are java apis available from clojure.
Michael Fogus
author
Greenhorn

Joined: Feb 07, 2011
Posts: 12

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.

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Me too, I hope it will be Clojure and let the aliens prevails
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clojure vs scala