3 ms·
I learned Scala on the job with no previous Java or JVM experience. At the time I had been writing software professionally for 8 years. Before Scala I had profe
by philipkglass 7y ago
I learned Scala on the job with no previous Java or JVM experience. At the time I had been writing software professionally for 8 years. Before Scala I had professionally written C, Fortran, and Python.
You will inevitably have to learn about the Java ecosystem when things go sideways.
One example that comes to mind is problems with dependency resolution. SBT, the most common Scala build tool, allows you to add libraries to your project easily with notation like this:
libraryDependencies += "com.lihaoyi" %% "upickle" % "1.0.0"
Normally that is fine.
But when things go awry, sbt may provide unhelpful messages. You actually end up having to learn about how Java's Maven (or Ivy) and its repositories work.
A couple of instances I recall:
- SBT repositories were configured to look for dependencies on site A. A was redirecting downloads to site B. Site B was configured with an expired TLS certificate. The error message reported from sbt only mentioned site A. I only figured out what was going on by tracing the network activity.
- Maven central disabled insecure (HTTP) access earlier this year and started requiring HTTPS. Some of our build configurations still referenced repositories via HTTP URLs. I don't remember what the SBT error message was, but it was again cryptic and unhelpful. Other developers who mostly work with Go had to enlist my help in diagnosing the problem and fixing it.
A lot of Scala teaching material also assumes familiarity with Java. "Scala's Traits are like Java Interfaces, but with these improvements: ...."
That didn't help when I hadn't used Java Interfaces before.
Fortunately, it looks like Hands-On Scala Programming doesn't assume a Java background.
It also took me longer than it should have to understand the deep stack traces you often run into. The key: look for lines that reference your own application code, and focus there. (But this doesn't work if you are really encountering library bugs or infrastructure flakiness.) The traces can be very deep and a lot of the lines are not really relevant to solving your problem. I was accustomed to reading shallower Python traces.
Learn to use a debugger early on. JVM code debugging with an IDE is powerful and easy to use. Plus you can't just monkey-patch your dependencies on the fly to add more diagnostics, the way I had done in Python.