Scala Meet WURFL. WURFL Meet Scala.

Mar 9th, 2015

It’s a great pleasure for ScientiaMobile to host this post from Filippo De Luca. In addition to having been one of the lead engineers behind the modern WURFL Java API in the past, Filippo is an expert of the Scala Programming Language. Filippo advised ScientiaMobile on the benefits of Scala and on the architecture of a WURFL Java API for Scala that feels native to adopters of this great new enterprise language.– Luca Passani, CTO @ScientiaMobile

The web today is very different from the one of eight years ago, when I was one the engineers behind the WURFL Java API. We have become accustomed to big numbers:

More interesting, mobile traffic represents more than 50% of the total traffic of Internet nowadays. It is clear that the requirements of a web application written five years ago, especially a mobile one, are very different from the requirements of an application written today. Web applications are moving away from the concept of multi-apps containers, such as Tomcat, towards a more self-contained model such the Play! framework. And even further, with virtualization, to have several dedicated virtual machines. We need to scale more and to scale fast.

This evolution has not spared programming languages. What we were accustomed to using has become obsolete for the new generation of reactive applications. If we want to exploit a multicore architecture, we need a way to easily parallelize operations. This explains the recent spotlight over functional languages: Haskel, Erlang, Clojure… and Scala, of course, as they enable writing code that scales without the pain of dealing with race conditions and lockings.

The Scala language, in particular, is generally gathering consensus among Java developers, mostly because it allows a gradual migration from objects to a functional programming style, and it does so by providing a hybrid solution. The availability of very powerful frameworks, such as the Play! framework, Akka and Spray.io has triggered Scala’s widespread adoption.

In this context, providing a compatibility layer for WURFL (an API used by for mobile web applications ) is a natural development. While the classic Java API could be used as well, the traditional object-oriented Java style does not fit very elegantly with the programming style that Scala promotes.
The WURFL Scala API is a thin layer on top of the Java API made possible by the Java interoperability that Scala offers. While not fully implemented in Scala, the “Scala wrapper” offers a very clean and simple interface that should feel natural to Scala programmers.