REST-based User Management web service in Scala

Today I’ve opened access to my sentinel repo which is still at a very early stage development, but I thought was worth sharing with others.

I’ve been using Scala on and off for the past couple of years, since I’ve completed the Coursera Scala course (passed with 95% and distinction, obviously!); however, to really learn a language (and a development framework) one really needs to develop a fully-fledged project, so a few months back I decided to replicate some of apache usergrid functionality.

scala-record

Actually, I had become aware of usergrid_ only recently – but it would seem that what I had in mind was being done there already: my take is to just create a simple REST API-driven user authorization framework, with associated SDKs, for developers to easily prototype their online or mobile applications.

I’m clearly still at the “baby steps” stage with Scala, and much still remains to be discovered; however, this is what I’ve found thus far that makes me like Scala much:

  • very concise, expressive language: when compared to some of Java’s verbosity, using Scala is a breath of fresh air;
  • functional paradigm – although not much in use in the Sentinel code, the code developed for the course proves what level of conciseness and expressivity is possible in Scala;
  • strong, static typing – this is probably the feature that I favor the most; like in Java, it makes easy to reason about what is going on – unlike Python, it makes it easy to refactor and maintain the code;
  • ScalaTest is a real pleasure to use and makes running unit tests (and analyzing results) a breeze (see here for an example)

These are the areas that I’m not so sure about:

  • concise code is all good and well; but how will it fare on the maintenance scale? in other words: three months from now, will I be able to just read my own code and figure out what was I trying to achieve? what about someone else’s code?
  • implicits – are a great resource; but I’m also old enough to remember C++ (and, most infamously, STL) where implicit type conversion sometimes caused weird, unwanted behavior (not to mention, completely incomprehensible compiler error messages);
  • lots of “magic” (see my implementation of an Authenticated request) – which is really the one single thing I dislike most about Python

Overall, however, it’s been a really pleasant activity (maybe that’s because I just enjoy so much learning new stuff!) and the more I use Scala (and Play) the more I seem to become proficient at it (my Sprint velocity has gone from 2-3 points up to 10!).

One thing that struck me is how Java 8 streams are modeled over Scala collections and their functional architecture – however, it seems to me that, due to those being native to Scala and just the more functional nature of the language, Scala still has the edge here.

Expect to see more Scala Trips here soon!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s