On Performance and Java Interoperability: Clojure vs. Scala

前端 未结 8 677
滥情空心
滥情空心 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 02:05

    The November 2010 issue of PragPub discusses Clojure-Java interoperability. Calling Java methods is straightforward, but extending Java classes/interfaces is quite different.

    Scala on the other hand is much closer to Java. Scala-Java interoperability is elaborated at http://www.codecommit.com/blog/java/interop-between-java-and-scala

    Calling Java code and extending Java classes/interfaces works the same way as calling Scala code. Some pain points might be some edge cases of dealing with Java's generics, because Scala's type system is much stronger than Java's. Creating getters and setters following the Java Bean convention requires an annotation.

    Calling Scala from Java is most of the time straightforward, but for example Scala's companion objects requires knowing how they are compiled to bytecode. Also using traits with non-abstract methods from Java should be complicated, and calling methods with special characters would require knowing how they are encoded in the bytecode.

提交回复
热议问题