Evojam

View Original

Glimpse at the State of Functional Programming

Recently, our whole backend team visited Lambda Days - The Functional Programming Conference. Two days, multiple presentation tracks, lobby and pub talks gave our five agents unique glimpse into the state of the functional programming ecosystem.

The conference scope covered several functional languages - Erlang, Haskell, Clojure, Lisp, OCaml - which gave us a broader context to what we do in Scala and JavaScript.

Don’t Be Religious

The biggest observation is that those aforementioned languages have some very devoted fans! Devoted to the extent of being religious about being functional in 100%. During the first day of the conference plenty of presentations were interrupted by someone in the audience raising their hand and saying the example is not “pure functional”. It’s gotten to a point where one of the speakers on the second day added a leading slide to his presentation warning that his presentation will not be “pure functional” :)

The key is to be flexible and pragmatic. Functional approach may be a very good tool to the problems of the present day (parallel concurrent processing) but as experience shows, pure functional approach is not practical in most real-life problems. It creates its own set of artificial problems that need workarounds, funky ways of handling input, etc. Some experiments show that implementing a solution 100% in a functional way ends up being suboptimal in terms of performance.

Conclusion: Realistic mix of functional and OOP is the way to go.

Big Data -> Fast Data -> Inconsistent Data :)

Do you remember the days when you’ve added a newly met person to your LinkedIn network and they gave you “people you may know” updated the next day? Now this kind of behavior means lost opportunities and less engagement from the users. It’s hugely important to serve timely recommendations relevant to the actions taken by the users.

Spark and Spark Streaming being on everybody’s lips are one of the answers to this problem. They make Hadoop and batch-processing look like a story of the past. Business and web programming demand velocity of data processing, sometimes at the expense of the not being fully correct or consistent.

Conclusion: Computations based on user behaviors have a very short validity date before they get stale. It’s better to have something relevant now, than a very accurate result in an hour or even in minutes.

Scala & The Reactive Approach

It seems that the blend of OOP and functional programming in Scala is great in terms of code quality and performance. Going further the way Akka and Akka Streams are integrating with Spark further consolidates the Scala ecosystem around Reactive principles and makes it a hugely powerful and future-proof ecosystem for web programming.