
Traditionally, service demand spikes were things that used to happen on the national power grid when the credits on Eastenders started to roll. Power stations in the UK would get a demand surge of sometimes 3GW of electrical power when 1.5 million kettles were switched on at once.
But Social Media giants like Twitter with their global, always-on platforms, can get surges that scale into the 100s of millions of tweets per day right across the planet.
This is a magnitude of scaling that make the spikes in the national power-grids Lilliputian in comparison.
Demand surges in the social media age can crash global systems just like the 2012 Twitter New Years Day outage when tweeters in the same times zones tweeted new year’s greetings in synch. Technologies like Ruby just couldn’t perform and at the disaster post-mortem Scala came into view as the solution.
Scala is designed to scale with large global enterprise applications (it’s an acronym of “scaling language”) and provide a stronger performance than Ruby and other technologies that showed their limitations in the new age of instant global demand.
It handles scaling better because it’s both an object orientated and a functional programming language. So it’s fully interoperable with platforms built on Java or functional programming languages.
Twitter migrated its back-end to Scala after 2012. And The Guardian in the UK made the same decision for similar reasons.
It wants a global news website that scales faster and better than any current Java platform will allow. The paper also wants a news website that responds quicker to a global readership and offers a much better user experience.
The Guardian’s journey started with a conventional Java set-up but moved to Scala. Their engineers discovered that it’s a more concise language and it’s easier to code with. Compilers can infer code types and they can also pick up any bugs this side of deployment making deployment easier.
The creator of Scala, Martin Odersky, says that the language is comparable with Java and can be used in developing “mission critical” server systems.
It was designed to ease the transition from using OO languages like Java, and can initially be used as a “Java without colons” but at the same time it can facilitate the transition to a functional programming style.
Scala and Java classes can mix freely, even if they’re on different platforms and can mutually reference each other.
This is because the Scala compiler also contains a Java compiler as a subset.
All major Java based tools and frameworks like Spring and Hibernate are fully compatible with Scala. And the Scala user community is an integral part of the Java community.
The language runs on the JVM and also on Android. In fact Scala is fast emerging in the Android world as a very effective rival to Java in developing Android applications.
According to Paul Krill in InfoWorld, Scala runs faster, eats up less memory and is better optimised than JVM languages like JRuby or Groovy.
One Scala partisan, Stockholm based coder, Mike Burns, said that the language can be thought of as a “Better Java“.
In a recent interview with InfoWorld, Odersky, said that the tech industry is evolving into one where the regnant language paradigm will be functional programming.
As a result Scala is due for a fundamental rethink. It will increasingly take up a bigger share of the industry’s back-end development requirements and while it has lots of features that add value to the coding community, it needs to be simplified.
Consequently, this will boost another popular feature of Scala: more expression in less code.
Alternatively, this paradigm shift may not be as complete or as absolute as Odersky says: Java will still be current in future but there will be many more languages that do what Java has always done, they’ll just be more applicable to different situations.
Iain Hull, a leading member of the Dublin Scala community develops this idea when he spoke to Verify:
The days where our industry is dominated by a few general purpose programming languages are over. Java is a massive language, but the JVM as a platform is where I see growth in the future. Increasingly developers choose the JVM with new and more innovative languages like Scala, Clojure or Groovy.
Their choice of language is often based on the tools and frameworks available and how these enable them to deliver. The move toward micro-services makes these choices even easier.
My team chose Scala because the Actor Model makes the concurrent code we require easier to write and understand.
The reactive style also helps our services scale. Of course we could do all of this in Java but actors are much simpler to write in Scala.
Later we embraced other functional programming techniques like using the type system to improve the correctness of our code. Now we catch more errors at compile time; reducing the tests we have to write and bugs we might miss.
You can catch Ian’s presentation “Improving Correctness with Types” on 2nd December at the GoTo conference in Berlin.