As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened,
visit the help center for guidance.
Closed 7 years ago.
I am a big fan of Scala aesthetically, and of a lot of the conceptual work put into things like its typing system and libraries.
However, as I have begun tinkering with Scala (and seen some of my coworkers tinker with it) i find myself having to dig for more and more Java knowledge (especially in the way of libraries).
This presents me with a few problems:
- Having never been a Java programmer, i'm not familiar or comfortable with the Java standard library, or additional popular libraries (like Apache Commons).
- My google-fu in the Java-sphere is weak. It's hard to know what to search for – a problem exacerbated by the ponderously large number of irrelevant or rudimentary java tutorials for programming newbies.
At this point though, i'm not sure whether i should bite the bullet and try and find the quickest and most comprehensive tour through Java to catch myself up on 20 years of Java developments, or whether its reasonable to continue trying to incrementally patch my knowledge as i wander around scala.
Any wisdom that scala heads amongst us could offer would be greatly appreciated.
P.S.
I have no doubt in my ability to familiarize myself with Scala syntax, and i'm perfectly comfortable and happy with functional programming and the paradigms in the scala community. But a programmer's competence is not just based on one's ability to teach oneself, but also one's ability to learn from, and adopt tools and skills from other people.
You should take a lazy
approach to learning Java. Learn it when you need it.
In my opinion, much of the old Java knowledge is out of date, much of the new tutorials are redundant. You certainly don't want to bother yourself with Java's antiquated Collections
, for example. Many Java-based frameworks can be safely ignored. And the heavyweight JavaEE stack can be safely bypassed until you were forced to use a part of it.
Many common patterns in Java are much simpler in Scala, with the former being burdened with much boilerplate code. Core logic should always be implemented in Scala. I believe you can do most of your work directly in Scala and only need to dip down into Java when building things like Swing or integrating with Spring, etc.
In regard to choosing and using Java libraries, my personal guidelines are:
- If Spring can do it, use Spring
- If Spring is too heavyweight, use what Spring uses.
- If Spring can't do it, check github projects
- If there's nothing on github, check Apache projects
- If there's nothing from Apache, check sourceforge(t).
- Finally, Google randomly or just build it yourself.
That's a bit tounge-in-cheek, but is the impression I get about the maturity and stability of third party libraries after having done Java for the last 12 years.
If you want to learn Spanish, start to learning Spanish, not Latin. Same for programming languages. There are two things from Java that are good to know:
The first thing are APIs. But you need only a general overview about what exists. Even long time Java programmers don't know all the details. And finding the right API or lib for a problem is usually easy, as Java is so common, and even with weak Google Fu you shouldn't have any problems.
The second thing you need to know are some basic principles and limitations of Java and the JVM (including how to build and run), that help you to understand some of Scala's problems and design decisions. One typical example would be "type erasure": If you don't understand this limitation of Java's generics, you'll run in problems when using generics in Scala.
As you can see, the things you really need to know is limited. Everything else can be picked up on the way.
It depends entirely on your definition of "Competent Java Programmer".
A good understanding of the Java memory model and garbage collection strategies will help. As will experience with a wide range of 3rd part libraries.
On the other hand... if you're deeply indoctrinated into getter/setter dependency injection used by libraries like Spring, then you'll have to unlearn a lot of bad habits before you can properly deal with immutability - In this case, prior Java exposure is probably going to hinder you in learning Scala.
There are lots of folk coming to scala and clojure from ruby/python, lisp/scheme, C#, who need to pick up on:
primitives, autoboxing
JVM startup options, how hotspot works, 32 vs. 64 bit, use openJDK?
benchmarks, profiling, how to read stacktraces;
zillions of test libs for every conceivable need.
java.util.concurrent
Swing API calls; Classpath; Maven, ant; Hudson, Interfaces
namespaces/packages/directory layout, and all the other things automated by:
intelliJ, netBean, or eclipse
http://news.ycombinator.com/item?id=1508609
http://www.mired.org/home/mwm/papers/simple-clojure.html
+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:, EscapeAnalysis etc.
http://groups.google.com/group/clojure/browse_frm/thread/c8f69037b26e2856#
compressed oops,
http://blog.juma.me.uk/2009/10/26/new-jvm-options-and-scala-iteration-performance/
http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html
http://groups.google.com/group/jvm-languages/topics
Java for Clojure users
Learning Clojure - What should I know about Java and more
http://copperthoughts.com/p/clojurists-guide-to-java/