3 ms·
5+ years here writing Java professionally in the video surveillance industry and I switched to writing geospatial systems in Scala six months ago. I'm past the
by aaron-santos 10y ago
5+ years here writing Java professionally in the video surveillance industry and I switched to writing geospatial systems in Scala six months ago. I'm past the initial Scala learning curve and am at least as productive in Scala as I was in Java. I've also been writing personal projects at home in Clojure for 4 years.
My initial impressions of Scala:
1. There is an unavoidable learning curve when onboarding. My personal experience with Clojure lowered the curve a noticeable amount. While I was tackling learning a new syntax, my team mates were struggling with syntax + functional concepts. People with exposure to functional concepts will have an easier time.
2. Our experience was made more difficult in that there were no in-house Scala experts/mentors to whom we could ask questions and get answers. Bootstrapping Scala knowledge takes some time and I admit that while I'm productive writing Scala, I know I'm not at the level where I can analyse design trade-offs, extol best practices, or use my language knowledge to pre-empt and avoid problems like I can in Java. We had a good experience with a consultant + videos + books + online articles, but it isn't the same as having a mentor colleague.
3. I write a LOT less boilerplate. Both my Java work and Scala work involve consuming and producing JSON data. In Java-land I used Jackson to annotate classes and used builders to build that as the data classes themselves were made to be immutable. It was a lot of repetitive code and mind numbing to write. Now you could argue that the code should be generated automatically, and you're not wrong. But it feels like something is broken in the language if this is the best solution.
In Scala, I find myself using case classes and spray-json and typically write two lines of code for a JSON-serializable class definition. (1 for the case class, and one for the implicit JsonFormat definition. Occasionally I have to break out RootJsonFormat and write more code, but it's short and concise and non-boilerplaty. I like writing Scala much more than Java and I'm because I like it I'm more productive.
4. Some of the libraries feel like a force multiplier. Specifically Spark, and to a lesser extent Akka let me do things I wouldn't consider trying in Java. Sure, they can be used outside of Scala, but the way they are presented in Scala is beautiful and makes the programmer feel powerful because when using them, the are.