News for hackers. Stuff that matters.
Re:Scala == Effective Java? by thisisananth on Tuesday January 11, 2011 @09:11AM (#2091885)
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.
Re:Scala == Effective Java? by Stormbringer on Tuesday January 11, 2011 @09:18AM (#2091909)
Scala, 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

Re:Scala == Effective Java? by beamso on Tuesday January 11, 2011 @11:45AM (#2092456)
There 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.
Re:Scala == Effective Java? by unoti on Tuesday January 11, 2011 @10:49AM (#2092191)
Yes. 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.
Re:Scala == Effective Java? by stonemetal on Tuesday January 11, 2011 @09:16AM (#2091904)
Anything you can use in Java is available in Scala.
Re:Scala == Effective Java? by fhars on Tuesday January 11, 2011 @12:23PM (#2092644)
Although 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.

Re:Scala == Effective Java? by Stormbringer on Tuesday January 11, 2011 @09:18AM (#2091912)
What about annotations?
Re:Scala == Effective Java? by wheaties on Tuesday January 11, 2011 @09:20AM (#2091917)
You can use them too.
Re:Scala == Effective Java? by sigzero on Tuesday January 11, 2011 @09:26AM (#2091926)
I thought one of the premises of Scala was that you could use all of the Java libraries as well?
Re:Scala == Effective Java? by masklinn on Tuesday January 11, 2011 @11:31AM (#2092373)
It is, and you can.
Re:Scala == Effective Java? by rit on Tuesday January 11, 2011 @11:41AM (#2092431)
As 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.