10/30/2013 01:37 pm ET Updated Jan 23, 2014

Why Functional Is Better Than Imperative

Flickr: Andrea in Amsterdam

Recently I ported a small piece of Ruby(on Rails) code into Scala. Nothing fancy, I just want to share with developers who are interested but not yet start coding in functional programming paradigm.

The code is on the server side and the business logic is simple: from the incoming request, read some session information from the cookie; send it to an external service which validates it and returns a username; find the user with the username from the DB and finally return the user information in Json response.