Re:Building Clojure Services at Scale
by jhspaybar on Friday September 13, 2013 @10:39AM
(#6380751)
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?
[ Parent
| on HN ]
That'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.
Re:Building Clojure Services at Scale
by josephwilk on Friday September 13, 2013 @06:14PM
(#6383528)
Thanks 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.
This 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...
Re:Building Clojure Services at Scale
by yummyfajitas on Friday September 13, 2013 @02:29PM
(#6382216)
The 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.
If 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")
> 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.
Re:Building Clojure Services at Scale
by dustingetz on Friday September 13, 2013 @11:46AM
(#6381206)
im pretty sure he means the standard library, e.g. data structures. Sharing Scala and Clojure code means converting your data structures at the boundaries.
This 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.