4 ms·
This is the first I've heard of the "Scala runtime". Isn't it compiled to bytecode and usable as a jar dropped in anywhere on the JVM possibly with some name m
by jhspaybar 13y ago
This is the first I've heard of the "Scala runtime". Isn't it compiled to bytecode and usable as a jar dropped in anywhere on the JVM possibly with some name mangling if you don't design your public interface to be pretty for java based projects?
- jeremyjh 13y agoThat's right, its really just a library. Also, Finagle already has an idiomatic Java API so using it from Clojure would not require use of any mangled names.
- josephwilk 13y agoThanks for those replies. I've updated that section to better reflect Scala just being a library dependency. I'm looking forward to playing with Finagles Java API as at some point I'm going to need to connect our Finagle projects with our Clojure services.
- easytiger 13y ago> MainGenericRunner will look at the file and determine if it's a script (.scala) or class file (.class). A class will be passed straight through to the JVM (+/- some classloader trickery) while the script is passed into the interpreter first. It is I think just a dispatcher.
- dustingetz 13y agoim pretty sure he means the standard library, e.g. data structures. Sharing Scala and Clojure code means converting your data structures at the boundaries.
- sreque 13y agoThis is true for Java and Clojure as well. In Clojure you have to choose between using java data structures verbatim or else converting them to clojure ones. See the scala docs for JavaConversions to see how to make scala collections look like java ones.
- kodablah 13y agoThis is becoming more and more common for Scala projects that want to build libs in Scala and only export a Java interop API (as opposed to pure Java at the bottom and building Scala on top). E.g. https://github.com/apache/kafka/tree/0.8/core/src/main/scala/kafka/javaapi https://github.com/apache/kafka/tree/0.8/core/src/main/scala...
- yummyfajitas 13y agoThe real difficulty comes when you want to use multiple scala libraries in a project which are compiled against different scala runtime versions. I live in scala land, but I prefer java libraries for this reason.
- gtani 13y agoIf you want writeups on scala/java interop, the Manning "in Action" and "in Depth" books have excellent summaries. From scala you need to worry about java annotations, static members and "throws" exception declarations. Java private /protected etc are checked at runtime and compile time. (That's just me copying items out of the "In Action" ToC, but everything's very well documented). For clojure/java interop, there's also good writeups in 2 Manning books, and also the OReilly and Pragmatic books. It looks like combining them (Scala/clojure interop) would take some plumbing, depending on the specific libs involved but i havent' tried. (And the Manning authors are all pretty far along on 2nd editions of both "Joy" and "In Action") http://www.manning.com/fogus2/ http://www.manning.com/fogus2/