Tech companies delivering services from the cloud are not only concentrating resources like processing power, software, platform, data and content but they’re also accruing more and more responsibility for their clients operations.
Whether they’re storing data or infrastructure on a cloud platform the client needs assurance that the service is reliable and secure. Or if the vendor is offering web services the end user needs to be confident that the service they receive is exactly what they expected without any interceding bugs.
Currently, most cloud operations are making a pretty good fist of this. A driver in this efficacy is a paradigm shift in the approach to coding: this is a slow but persistent move from dynamic programming to functional programming.
Before its advent in the cloud industry, functional programming (FP) was found more in the academy among computer scientists than in the live industrial environment.
Functional Programming is a way of coding; a language is said to be an FP language or have incorporated functional elements if it uses mathematics at the language core.
This means that the programme’s output depends only on the inputted data and not on the programme state which doesn’t change. And of course the results are highly predictive and much less vulnerable to bugs.
The benefit deriving from this is the reduction of errors. This is important if the code is handling data streamed from the cloud or when its being used across a vast network of platforms like a cloud operator’s data centre. The code produces exactly what the developers want at the other end. Also, functional programmes are an “order of magnitude” shorter than dynamic programmes making them quicker more and productive.
“Functional programs contain no assignment statements, so variables, once given a value, never change. More generally, functional programs contain no side-effects at all. A function call can have no effect other than to compute its result. This eliminates a major source of bugs.”
Currently functional programming is being used in the finance industry and also with social media platforms like Twitter and Facebook. In fact Facebook have used functional programming in a newsfeed app for their IoS client. The feed which is being updated constantly uses functional programming to improve data integrity and reliability. As well as protecting brand integrity and user satisfaction, this also drives down maintenance overheads.
The driver here was the pain the Facebook Newsfeed team experienced in keeping the pages of more than a billion users constantly updated. And each time a user logs into their Facebook account or when they interact with the newsfeed itself by, for example, “liking” an item, a new feed has to be generated.
Users are expecting the update to be instantaneous and any disappointment will drive user dissatisfaction. Problems could arise from complex and compound user interactions with the newsfeeds, generating hard to predict results. Using functional programming means any updates are completed quickly without any bugs in the system.
The lead developer on this project, Adam Ernst, said that his team used Objective C++, a multi-paradigm language that, just like Scala and F#, includes functional elements.
Scala is one of the most prominent functional hybrid languages in the industry today and it’s being used by Twitter in its back-end infrastructure. According to Twitter insiders it’s becoming more popular along with JS at the expense of langauges like Ruby. Twitter needed a language that could handle astronomical scaling and offer security for data integrity as well as simply being faster than Ruby.
The company had to handle unprecedented scaling events in the 2012 US Presidential Election. An example of this was Obama’s victory tweet “Four more years”; it was retweeted 769,000 times in 22 minutes. Twitter has moved much of it’s back-end services to Scala. Although, throughout the industry, as the infographic below shows, Scala and other functional languages like Haskell are a long way off replacing Ruby.
F# – Putting the Fun into Functional Programming
F# is another flag carrier for functional languages in the coder world. It’s Microsoft backed, but it’s an open source technology supported via the F# Software Foundation. The TIOBE Index for July 2014 shows that it’s zoomed up the rankings of language popularity from 37 in 2013 to 13 this year.
Functional programming is being used in more and more projects in 21st century web services. These services are sold into one world markets where the shop is always open and service consumers can be north of 1 billion. In addition to this constant huge demand there can be surges in user access and activity so scaling is critical to all modern web companies. The answer to these problems has to be code that’s robust, scales quickly and delivers output services that the vendor and user expected. Functional programming or languages with functional elements are successful in doing this.