This post contains some thoughts I have after working with Java and Scala professionally for 8 weeks. The content assumes the reader has some experiences writing Java/Scala code.

Starting from scratch

There are several components a learner must understand before he/she can get productive.

  • An easy installation process, preferably something along the lines of download something, extract or run an installer, modify the user path if necessary. I think anything more than that is asking too much from the user.
  • An intuitive package manager. Golang comes with go get and go install. Node has npm, Python has pip, and Java has maven, ant, gradle. In my opinion, Java is probably the least beginner friendly for setting up.
  • The syntax (literal or not) for initializing common datatypes such as list/array, map/dictionary, and for manipulating data.

Java

Java requires good mastery of the IDE

From compilation to running the program, the IDE is immensely important.1 The IDE, I use intelliJ, have probably generated more code than I what I physically typed. I feel that half of knowing Java is knowing which shortcuts to press in the IDE. The following are the shortcuts that bring me pleasure when I use them.

  • Method/variable extraction (ctrl alt v and ctrl alt m)
  • Introduction of local variables. I’d type new Foo(); and then have the IDE create the local declaration for me.
  • Go to implementations (ctrl alt B).
  • Quick documentation and argument type hint. Ctrl Q and Ctrl P are awesome!
  • Auto formatting. Not everyone agrees with this, but to me not having to bother with how code looks like is a huge win.
  • Suggestions on simplifying the code.

It is almost like the IDE is doing the work for me when I express vaguely what I’m trying to do

Writing lambda

This is so much more satisfying than writing anonymous classes. The stream API is definitely nice to work with2! The ability to define an interface with a single function, and then use lambda as an instance for the interface makes code comprehension so much nicer!

Design patterns

When I was writing in golang, I didn’t have to use that many patterns, this could be partially due to the simplicity of the language. Going to java, the “limitations” of the Java type system made me realize the usefulness of all those textbook design patterns that I have read about.

Scala

Scala is a nice middle ground for functional and procedural code. However, it may require a lot of discipline from the coder to not abuse it. The paradigm of thinking functionally is to treat expressions as values, and relying on functions like fold, map to iterate over values instead of defining conditionals and then writing code branches.

The higher order type system is so much more advanced than Java, which allows us to express many mathematical concepts such as monoids and monads. However, sometimes it really feels like an academic exercise to give things the more “honest” type. For example, if your code is going to make a network call (a side effect), it should be typed with effects instead of just unit.

Besides the functional style, the amount of syntactic sugar on top of java is a mixed bag for me. On one hand, it’s elegant in that the compiler can do what is not typed (when compared to java). However, with some mastery of the IDE, perhaps there could be more readable code.

This language is nice if one is already familiar with functional programming, otherwise the learning curve can be quite steep as there are many mathematical concepts to understand.

Golang

This is still my go-to language for writing servers, and simple cli tools. The ease of setting up the tools and start getting productive is unmatched. The binary output also a deployment euphoria.


  1. I was shocked when I once quizzed someone whether they know how to compile a java program if they didn’t have an IDE. They said they didn’t but then asked why would anyone want to do that. ↩︎

  2. Even the oracle article on java stream espouses the terseness of the new API ↩︎