We are fully immersed in the digital economy. The passage of time in the digital economy is far faster than anyone could have ever imagined. This alternative rate of time means decisions on software platforms, tools, languages, and methodologies are very critical. Anything that can facilitate faster time to market, platform resilience, and universal expressiveness and capabilities conveys distinct advantages. Couple that with a renewed resurgence of functional programming has thrust Scala clearly into the forefront of software development languages.
Functional programming is a programming paradigm with roots in lambda calculus and function abstraction which treats computation as the evaluation of mathematical functions. It avoids changing state and mutable data which avoids programming side effects while reinforcing stability and predictability.
Learning to think and program within the functional paradigm requires a change in the mind-set of the programmer who was groomed in imperative, procedural programming. Embracing that change is the key to benefiting from functional programming. Investing purely in functional programming is not necessarily an obvious decision for many firms. Their knowledge and resources all reside in procedural programming languages, like Java. Scala allows the procedural functional gap to be easily bridged.
Scala first appeared in 2003 out of Sweden with full support for functional programming and a very strong static type system all running on the Java virtual machine (JVM). That allows the Scala programmer to use their procedural knowledge of Java while still employing and incorporating all of the latest features of Scala. Companies do not have to throw away their significant investments in Java and the JVM. Applications and modules can be created using both Java and Scala simultaneously until the full transformation to functional programming is complete.
Scala brings a few other key advantages. IT handles concurrency quite well through ‘actors’, functions are first-class citizens with the same rights as objects, closures, and monads. Another interesting aspect of Scala is the terse, compact yet expressive nature of the language. The code below shows a striking example comparing a Java class with an equivalent Scala class.
Figure 1 – Example Java Class