Clojure vs Scala, Part 2

Photo by PhillipC

There are two languages stirring up the Java World: Clojure and Scala. Clojure a Lisp dialect on the JVM, powerful and pure and the Scala language a tight integration of object and functional programming. Which should you learn? Matt is wondering:

The two leading candidates in the JVM/concurrent/multicore arena seem to be Scala and Clojure. […] Scala is a multiparadigm language, supporting both object-oriented and functional constructs. It is statically typed, yet offers very nice type inference. Clojure, on the other hand, is a functional Lisp derivative with almost no OO constructs that is dynamically typed. Both are designed to enable concurrent programming. Which one do I choose?


Clojure as the first contender to the Java throne came out of nowhere and conquered the blogosphere in a storm.

Clojure […] is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. […] Clojure provides easy access to the Java frameworks […] Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system.

There is some traction with companies already, FlightCaster who predict flight delays use Clojure for backend code:

The research and data heavy lifting is all in Clojure.

Some obvious reasons that speak for Clojure:

  • Big momentum, mainly in the dynamic language (Ruby) avant-garde and in Lisp circles
  • LISP community
  • STM, software transactional memory, an easy way to share data
  • Very clever immutable datastructures
  • Well thought Seq concept, tightly integrated with Java

Depending on your standpoint there are some downers with Clojure:

  • no objects (might not be a problem for you)
  • hard to read for C tradition developers, this does include the many (), prefix notation and functional programming style in Lisp
  • no Lisp skills in most companies, harder to recruit than Java or Scala

Clojures Java Integration

Although it does not possess objects, astonishingly Clojure has excellent Java integration. This might be because one of the main arguments of Clojure it makes against other Lisp dialects is the Java plattform. So it does make a lot of sense of excellent integration.

  • Java methods as functions in Clojure
  • Collections in Clojure implement Collection
  • Functions implement Callable and Runnable
  • “Core abstractions, like seq, are Java interfaces”
  • “Clojure seq library works on Java Iterables, Strings and arrays”


Scala is the rising star on the JVM. James Strachan, the inventor of Groovy writes: “I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I’d probably have never created Groovy.” Though one must admit the Groovy back than is not the Groovy from today. The question remains: What is Scala?

Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application.

The main reasons for using Scala:

  • Big momentum, mainly among Java developers
  • Java community
  • Has objects (might not be a plus for some)
  • Very powerful type system
  • Object oriented and functional integration

Some downers:

  • Functional programming can be difficult to understand for a Java developer
  • The type system is more complex than the Java one (might be a plus for you)
  • Actor concurrency in Scala is nice, STM feels more natural to lots of problems (shared state vs. agents), Akka could help
  • Scala is very powerful, some developers might shoot themselves into the foot

The biggest promise of Scala nevertheless is power and terseness. As I’ve showed in “Top 5 Things to Know About Constructors in Scala”, Scala has much less boilerplate code. This example in Java:

can be written in Scala in one line:

Which is important, to a degree that you should drop setter and getters if not needed. I wrote in “Go Ahead: Next Generation Java Programming Style”:

If you have simple data holders or data transfer objects, don’t write boiler plate code with getters and setters. I know this is heresy in Java, but just use public fields.

Scalas Java integration

Scala has good, but compared to Clojure a rather basic integration. One can implement Java interfaces in Java, extend Java classes and vise versa. Scala isn’t tightly integrated on the API side – only with some in this context clumsy, unneeded Meta-Programming with impliciets. Scala promises Clojure like Collection integration with Java in the future – we’ll see. From the Java side things also do not look as nice, Scala classes and traits have lots of ugly named methods, until IDEs know how to deal with this, code completion is spammed by Scala.

As a side note, Groovy has also deeper Java integration that leverages the dynamic nature of Groovy. For example the “as” keyword.
With as closures or maps can easily be coerced to a Java interface. This goes beyond the Scala way of implementing interfaces.

Nice, wish to have this in Scala – the map version if as will be hard to make play nice with static typing.


Andrew Glower wrote last year:

Is Scala or Clojure poised for stardom? Can two languages co-exist as stars or does one invariably outshine the other? If history is any indication, then I’d venture to guess that the answer is that both can’t be stars– just like both Groovy and JRuby aren’t stars. They co-exist and, in truth, divide the market and have followers with strong opinions on both sides. Thus, if I had to guess right now, I’d say that Scala has the edge with some good momentum.

I concur. The conclusion might not be what you want to hear. Draw your own.

Clojure has a lot of appeal to me, it looks so clean, the Java integration has such a pure feel, hard to describe. I do not buy the argument that Lisp is so much more powerful than e.g. Scala – so this doesn’t influence me much. And Clojure as a Lisp dialect is way out of the mainstream. It will make it hard to recruit developers – do not listen to people who declare this a non issue. I’ve been recruiting Java developers for years, and it’s hard. It’s much harder for Clojure.

Scala isn’t as pure as Clojure, not as en vogue. But it is pragmatic and powerful. It has a lot of momentum now and is easily learned by Java developers – at least by those that are open enough. The good ones usually are. The main promise and reason for Scala is how much less lines of code you need than in Java. Less code, less bugs, easier to read – to some extent – and faster to write, leading to higher productivity. Who doesn’t need higher productivity with the same safety as Java?

Which should you use in your company? Daniel warns on Stackoverflow, in “Scala vs. Groovy vs. Clojure”:

It’s also a much more dynamic language than Java, in the sense that the language evolve. From the perspective of the language, that’s a good thing. From the perspective of users who plan on having thousands of lines of code written on it, not so.

You need to decide on your own. Which would I use? Scala. Which should you learn? Both obviously.

What is your plan?

302 thoughts on “Clojure vs Scala, Part 2”

  1. Pingback: nike factory paris
  2. Pingback: electric scooter
  3. Pingback: nike free run v2
  4. Pingback: nike huarache 1992
  5. Pingback: コピー時計
  6. Pingback: gucci ハット
  7. Pingback: fifa 16 coins
  8. Pingback: electric scooter
  9. Pingback: broe&co ベルト
  10. Pingback: fifa coins price
  11. Pingback: cheap fifa 14
  12. Pingback: buy coins fut
  13. Pingback: fifa coin sell
  14. Pingback: fifa coins trade
  15. Pingback: nike outlet uk
  16. Pingback: air max
  17. Pingback: Nike Tn Pas Cher
  18. Pingback: cs go market price
  19. Pingback: cs go a
  20. Pingback: cs go log
  21. Pingback: cs go update log
  22. Pingback: csgoskins
  23. Pingback: Ralph Lauren Polo
  24. Pingback: buy csgo cheap
  25. Pingback: nike tn pas cher
  26. Pingback: sport shoes woman
  27. Pingback: botas MBT
  28. Pingback: global offence
  29. Pingback: cs go key price
  30. Pingback: best
  31. Pingback: fucoxanthin
  32. Pingback: geniux pills
  33. Pingback: intelligex
  34. Pingback: intellux
  35. Pingback: probrain
  36. Pingback: radian-c
  37. Pingback: red rhino
  38. Pingback: genius reviews
  39. Pingback: testomax
  40. Pingback: alpha fuel
  41. Pingback: alpha man pro
  42. Pingback: alpha peak
  43. Pingback: alpha xtrm
  44. Pingback: anabolic rx24
  45. Pingback: cognifocus
  46. Pingback: garcinia melt
  47. Pingback: max synapse
  48. Pingback: nerventrax
  49. Pingback: premium cleanse
  50. Pingback: testorip
  51. Pingback: testoroar
  52. Pingback: zynev
  53. Pingback: forskolin slim
  54. Pingback: garcinia cleanse
  55. Pingback: garcinia xt
  56. Pingback: forskolin fuel
  57. Pingback: vitapulse
  58. Pingback: Vita pulse
  59. Pingback: vitapulse reviews
  60. Pingback: vitapulse review
  61. Pingback: pure colon detox
  62. Pingback: perfect biotics
  63. Pingback: reviews vitapulse
  64. Pingback: vitapulse scam
  65. Pingback: vitapulse
  66. Pingback: vitapulse
  67. Pingback: vita pulse
  68. Pingback: probiotic america
  69. Pingback: taurus
  70. Pingback: Sciatica SOS scam
  71. Pingback: Alexapure Pro
  72. Pingback: Ecomaxx
  73. Pingback: T90 Xplode Reviews
  74. Pingback: Maxtropin Reviews
  75. Pingback: Fungus Key Pro
  76. Pingback: Tea tox
  77. Pingback: MegaDrox Reviews
  78. Pingback: Test X180 Review
  79. Pingback: vita pulse
  80. Pingback: probiotics america
  81. Pingback: Perfect Biotics
  82. Pingback: check it out
  83. Pingback: read this article
  84. Pingback: Vfx Body Review
  85. Pingback: click site
  86. Pingback: my company
  87. Pingback: Vert Shock Review
  88. Pingback: click here now
  89. Pingback: news
  90. Pingback: a fantastic read
  91. Pingback: find more
  92. Pingback: Visit Website
  93. Pingback: anchor
  94. Pingback: internet
  95. Pingback: other
  96. Pingback: see this
  97. Pingback: Wood Profits
  98. Pingback: see this
  99. Pingback: visit
  100. Pingback: directory
  101. Pingback: read more
  102. Pingback: look at this site
  103. Pingback: click
  104. Pingback: my response
  105. Pingback: other
  106. Pingback: find more
  107. Pingback: my site
  108. Pingback: check my site
  109. Pingback: look at this site
  110. Pingback: read more
  111. Pingback: click here
  112. Pingback: tires
  113. Pingback: wheels
  114. Pingback: read more
  115. Pingback: read more
  116. Pingback: read more
  117. Pingback: read more

Comments are closed.