3 ms·
Does scala have that many third party libraries ala java ? Because these days for web application most of us use Java with Spring or apache commons.
by thisisananth 16y ago
Does scala have that many third party libraries ala java ? Because these days for web application most of us use Java with Spring or apache commons.
- stonemetal 16y agoAnything you can use in Java is available in Scala.
- Stormbringer 16y agoWhat about annotations?
- wheaties 16y agoYou can use them too.
- fhars 16y agoAlthough stuff that relies heavily on reflection and runtime code generation tends to be tricky. Class files generated by the scala compiler may look different from class files generated by javac and contain additional data (while of course still being valid java bytecode), and some tools rely on accidental details of the javac code generator. Someone mentioned JPA in this discussion. But most things just work. Another issue is using scala code from java. As long as the code implements a plain java interface, everything is fine, but if you try to use something impemented with some of the features that java doesn't have, you will soon see some very stange mangled names. trö_%¿ is not a valid java fuction name, after all.
- Stormbringer 16y agoScala, like most/all languages that run bolted on top of the JVM can use almost all of the libraries that Java itself can use, since the Scala code gets auto-converted to Java classes. (Typically (in the examples I've seen) one Scala class gets converted into many Java classes) This is not entirely dissimilar from the way that JSP gets converted into a Servlet. Scala/AlternateLanguageRunningOnJVM fans please provide corrections as appropriate, but be gentle, I'm making some broad generalisations here with all the flaws implied by that methodology. :D
- beamso 16y agoThere maybe exceptions to the 'you can use all Java libraries' at runtime. I'm unable to use a Scala class annotated with JPA annotations with Eclipselink. The same class works fine with Hibernate.
- sigzero 16y agoI thought one of the premises of Scala was that you could use all of the Java libraries as well?
- masklinn 16y agoIt is, and you can.
- unoti 16y agoYes. Anything you can use from within Java, you can use from within Scala. I'm quite happily using JGroups and Netty from within Scala. The code actually looks a hell of a lot better than the equivalent Java versions.
- rit 16y agoAs many other replies pointed out, the answer is most definitely 'yes'. You can easily use any Java libraries from Scala and Scala provides a number of tools including JavaConversions and JavaConverters to automatically convert to and from Scala and Java collection objects for easy interop.