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.

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.
If this question can be reworded to fit the rules in the help center, please edit the question.

4

No, I would imagine one could learn/use/write Scala without touching Java at all, but... there are the things I can think of why it'd be nice to "know" Java: 1) How to create objects "usable" from Java (if required) 2) Take advantage of the Java API with no Scala-specific interface or replacement (but a javadoc will get you through this) 3) Finer details of the JVM like lock semantics 4) Although it's becoming less, how to work with the "Java Ecosystem" tools such as Ant/Maven/etc. -- so just do it already :p scala-lang.org lists a number of publications.
–
user166390Nov 20 '10 at 1:41

4 Answers
4

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 person 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.

I'm not sure why you color Java's Collections as "antiquated". They're fundamental data structures, and are still being updated when needed (which shouldn't be often). Vector and Stack otoh could be called antiquated.
–
erjiangNov 20 '10 at 2:14

2

Why search github first? I would search Apache first since they've been the "fathers" of building libraries/projects in java. Many libraries consists, at least, of 1 Apache library.
–
Buhake SindiNov 20 '10 at 3:56

1

@TEG fair enough! It's just my opinion. @erijiang I term them antiquated because they have only a fraction of the utility of Scala's collections. In fact, for me, programming with Scala's collections was wonderful new paradigm for me (and for many others too, I suspect).
–
SynessoNov 20 '10 at 4:33

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.

Ironically, i took Latin in high school, so perhaps that's not the best analogy, in that i think that knowing latin has been helpful to my life in a variety of ways. ;) That said, i have been convinced that i should just keep plowing forward in Scala rather than detouring through Java. Still i'm curious what people think is necessary to know from Java. (i'll look up type erasure) Thanks :)
–
knowtheoryNov 20 '10 at 13:38

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.

Ah, this is useful. So, why should i know java.util.concurrent over scala's actor libs? Knowledge of the JVM is something i'm trying to pick up, and all the classpath magic and startup options. Lastly, i am absolutely allergic to complicated IDEs. If i can't figure out what it does by loading it up in a REPL and poking it with a stick, or writing isolated script tests, i get concerned.
–
knowtheoryNov 20 '10 at 13:34

1

@knowtheory, I think if you're working on messaging or threaded apps, you should be conversant in scala actors and akka, j.u.c, STM in clojure and haskell, erlang processes, and zeroMQ. And how the C#/F# asynch framework is evolving (which i don't know much about) And node.js, just for the heckuvit.
–
Gene TNov 20 '10 at 17:32

@knowtheory: IDE's don't rerrquire you to use any features, just the ones you understand/like. For IDEA, at least, you might have to rejigger the heap and permgen (up, obviously) and possibly flip to 32-bit JVM to get it to run large repo's like lift, but it works pretty well. And there's a lot of blogs and list activity: delicious.com/tag/scala+intellij ; dir.gmane.org/gmane.comp.lang.scala.tools
–
Gene TNov 20 '10 at 17:42