Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does being a competent scala programmer require you to be a competent java programmer? [closed]

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.

like image 452
knowtheory Avatar asked Nov 20 '10 01:11

knowtheory


People also ask

Should Java developer learn Scala?

Scala runs on the Java Virtual Machine (JVM) and can interoperate nicely with Java code. This also means Scala developers can use Java libraries directly from Scala code. Given, many Java developers are turning to Scala; this is the perfect way of leveraging their years of experience in real-world Java programming.

Should I learn Java before Scala?

Hello, You can learn Scala without knowing Java. examples. Java standard library.

Does Scala use Java?

Scala runs on the Java platform (Java virtual machine) and is compatible with existing Java programs.

Is Scala similar to Java?

Scala is a type-safe JVM (Java Virtual Machine) language launched by Martin Odersky in 2003. It combines both object-oriented and functional programming paradigms into a concise and logical high-level language. Scala is sometimes viewed as an attempt to create a better version of Java, and rightly so.


2 Answers

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:

  1. If Spring can do it, use Spring
  2. If Spring is too heavyweight, use what Spring uses.
  3. If Spring can't do it, check github projects
  4. If there's nothing on github, check Apache projects
  5. If there's nothing from Apache, check sourceforge(t).
  6. 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.

like image 92
Synesso Avatar answered Sep 29 '22 22:09

Synesso


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.

like image 41
Landei Avatar answered Sep 29 '22 22:09

Landei