Posts Tagged ‘scala’



December 5, 2015

Its been ages since I blogged. There’s been quite a few things I can probably write about – for example, I should probably write about the chess database I’ve been working on as a side project for most of this year. But that will have to wait for another time – now I want to talk about Scala.

I suppose most things worth talking about Scala have already been written or spoken about. But as someone who’s primarily worked in Java for many years, getting a new job working with a new language full-time is quite the challenge. The ease of inter-op between Scala and Java does, admittedly, make things a lot easier. Not that I’m writing Java in Scala syntax but having the benefit of compensating for a lack of supporting tools and libraries by using the corresponding libraries directly from Java helps – true for all new languages that run on the JVM of course but the cross-language syntax is a lot easier than it is on some other languages like Clojure.

I’ve been doing this for over a month now and these are my highlights:

  • No getters, setters or lines of code dedicated to initialising fields based on constructor arguments – simple and elegant
  • An object-oriented¬†AND¬†functional language at the same time? Sounds weird but it somehow seems to work
  • I’m quite used to lazy evaluations while operating on lists and maps – for example with Clojure. But a method that takes in a list of java Futures as an argument and returns another list of Futures after mapping over the (values that the futures return in the) passed-in list still has me confused. When I mentioned this to a colleague, he suggested that a good learning experience is to take a list of futures and convert it to a future that returns a list. Bonkers!
  • Using Options so that we don’t have to deal with NPEs is a nice idea theoretically but in practice, it seems to bloat the code unnecessarily. It does avoid having to check for null everywhere – I’m still not convinced it works better than the Java approach but perhaps that will change as I continue to work with it.
  • My last point (for now) doesn’t really have anything to do with Scala. I hadn’t known about Swagger until I started here – very nice documentation interface for your REST APIs!