4 ms·
I'd have to ask how much Scala and how much Clojure you know to challenge my statement about the equivalence of the code and the reduction in size? (no offence
by seancorfield 15y ago
I'd have to ask how much Scala and how much Clojure you know to challenge my statement about the equivalence of the code and the reduction in size? (no offence intended - a genuine question)
I like Scala. I'd hoped it would become my company's "One True Language". It has a lot less ceremony than Java. I went thru the very painful 2.7 to 2.8 transition. I attended Scala Lift Off! 2010 and Scala Days 2011. I think Scala is very impressive - a (much) better Java. I hope it will succeed and I still follow it closely.
I've always liked functional programming, and Lisp, and Clojure hits a particular sweet spot for me. It also happens to hit a sweet spot for our company - our developers like dynamic scripting languages and Clojure fits that better than Scala. Scala _allows_ you to adopt a functional style but doesn't enforce it (and, to be honest, makes you work at it) - Clojure makes you work at deviating from the functional path.
Clojure has less ceremony than Scala, is more functional (or at least more purely functional), and - in my opinion - far fewer demands on developers in terms of what you must learn to be productive...
- snprbob86 15y agoI've written a substantial prototype in Scala, which included half a dozen Neo4j-backed implementations of scala.collection traits. As for Clojure, I've only really toyed with it, but I have written meaty code in several other Lisp dialects. So while I am by no means an expert in either, I'd say I'm qualified to be skeptical of your claims. Furthermore, I have no vested interest in either language. I have a future production project in mind for each of them. I'm going to ignore the discussion about functional vs OOP, and team sweet spots, and cognitive load of the Scala type system, and all of that. I agree with and disagree with several of your points, but they are not relevant. Scala, being a statically typed language, has some additional "ceremony" over a Clojure. That's for sure. But, in my experience, that ceremony is a relatively small fixed cost of around 5 to 10 lines per "big scary top-level thinggie" in the problem and solution domains. In general, I'd expect the Clojure source code to be shorter by about 5%, not 75%. In some cases, either Scala or Clojure will be significantly shorter that the other, depending on whether or not the type system or macros are employed cleverly. Regarding your specific claim -- "The form of the Clojure code mostly follows the form of the Scala code" -- I am beyond skeptical. I do not trust your account of "mostly the same functions". Without seeing concrete examples of how the code shrank so significantly, your anecdote is not useful to any reader.
- seancorfield 15y agoThanx for taking the time to give some background. I posted the anecdote on the Clojure list just by way of sharing some of the progress we were making with Clojure. If someone had actually asked me, I'd have probably said "No, don't post this on HN" because it's an isolated anecdote - not a general case. A couple of folks have picked on the "Clojure code follows the Scala code" claim. Since the code embodies a fair bit of proprietary business logic, I can't share it - which is a shame because it would clearly show the structure really is very similar with almost all of the same function names. I'll see if I can find some time to sit down with the two code bases side by side and produce a more detailed comparison which would answer some of the more critical voices here. A couple of folks mentioned library support and part of the increased conciseness in the Clojure probably comes from that - in particular, in Clojure, a SQL query result is a sequence of maps whereas I had to construct a collection wrapper around ResultSet in Scala (remember, the code was written back 2009 - there are better SQL abstractions available for Scala now as third party libraries). Using parallel collections in Scala would more closely mirror the approach we now use in Clojure - and that would shrink the Scala code a bit - but parallel collections weren't available when the code was written. However, using agents in Clojure - which would more closely mirror the old Scala code - would only add a few lines. I think the Scala code could be made quite a bit more concise because of the advances in Scala over the last two years. I suspect I could make the Clojure code a little bit more concise too. I don't believe I could make the Scala code more concise than the Clojure code.
- BrandonM 15y ago> I like Scala. I'd hoped it would become my company's "One True Language". With all of these exciting languages that target the JVM, I think it makes a lot of sense to have a company's "One True Language" simply be the JVM itself. That allows a programmer to use Scala, Clojure, JRuby, or Jython to initially write software quickly. Anything that becomes a core library can be rewritten in Java for efficiency and so that bindings can be added for all of the high-level languages. Then projects themselves can be written in whatever language best suits the individual employees. Does anyone use this approach?