3 ms·
When I said Java interop, I meant two-way. With few exceptions (traits being the only I can think of) all Scala code can be used by Java. You can even use impli
by paulddraper 11y ago
When I said Java interop, I meant two-way. With few exceptions (traits being the only I can think of) all Scala code can be used by Java. You can even use implicit parameters, though of course the Java compiler won't resolve them for you. And almost all Java constructs can be created with Scala (Java enumerations being an exception). For example, using Scala you can define an abstract class that Java code can use.
You can't do that in Clojure.
Real world examples: Play and Akka are two large projects that include Java development in their primary use cases.
Two-way interop is the cause for a huge number of less than ideal decisions: different Array equality than Seq, @specialized, universal equality, hash codes, and toString, abstract class vs trait, generic type erasure, etc.
You can call the compromise misguided (and you wouldn't be the first to do so) but that's why.
- catnaroek 11y agoWhy is there a need for a one-to-one correspondence between Java and Scala features? In any case, you can call Clojure code just fine from Java. Of course, the API won't look like one a Java programmer would've designed, but that's okay - Clojure isn't trying to be Java. It's trying to leverage the JVM environment.
- daxfohl 11y agoTake twitter for example. They do a ton of stuff in Scala but make everything straightforward enough to use from Java that you wouldn't know it was Scala. This is fairly trivial in Scala but difficult in Clojure.