On Performance and Java Interoperability: Clojure vs. Scala

前端 未结 8 767
滥情空心
滥情空心 2021-01-30 01:47

I have already read various accounts of Clojure vs. Scala and while I realize that both have their place. There are a few considerations that I haven\'t acquired a complete exp

8条回答
  •  误落风尘
    2021-01-30 01:48

    With the present JVM Scala has an advantage on the account of being statically typed, as JVM support for dynamic typing -- reflection -- is slow. In fact, one Scala feature which must be implemented through the same techniques, structural types, is often warned against for this very reason.

    Also, Scala accepts mutable objects just fine, and some algorithms are just faster to implement with mutability.

    As both Scala and Java are essentially class-based languages, they interoperate more easily. Or, perhaps, more seamlessly. A Java class is a class to Scala, and a Scala class is a class to Java. Problems might arise when it comes to Scala's singletons or Java's static members, particularly when there's a framework involved expecting things to work in a certain way.

    So I'd go with Scala on both these accounts. Clojure is, in many ways, a better language, and it certainly has very interesting features not present (so far) on Scala, but you reap such benefits by going fully functional. If you intend to do that, then Clojure is very likely better. If you don't, then you should probably stay with Scala.

提交回复
热议问题