Scala - a better Java

Good programmers should always be looking for better ways to develop software. Functional programming has recently come in vogue with the promise of delivering increased effectiveness of programmers and code of higher quality. To dip our toes into functional programming waters also at Zemanta, we had a hackday on Friday with a sole rule that whatever we do should be written in one of functional programming languages. tom_functional_programming

I've decided to do my hackday project in Scala. I've heard many people experimenting with this new programming language, most notably Twitter which moved all its backend to Scala a few years ago. I questioned sanity of Twitter's decision at the time, but after spending two days programming in Scala I've realized their decision wasn't so risky after all. Namely, Scala and Java both run on java virtual machine and it's very easy to interleave code written in either of programming languages. Therefore a programmer used to imperative programming style, can migrate to functional programming style gradually, interleaving code and libraries written in either programming language.

While it takes some adjusting, writing code in Scala feels much nicer than writing Java code. For starters, Scala is much more succinct and there is no need to write type declarations over and over again. Then, pattern matching is much more powerful technique then structuring your program using if statements. Similarly, mapping, filtering, and reducing should capture intent of a programmer much more concisely than loops could ever do. And, since my hackday project was about log processing, I really appreciated great regex support that Scala offers.

I'm very happy that I dipped my toes into Scala. While we will very likely remain predominantly Python/Django shop for a foreseeable future, I consider Scala a serious contender to replace our aging backend Java code.

Enhanced by Zemanta