Introducing tumblr4s: A Scala Library for the Tumblr API

Back in February of this year I stumbled upon an amazing article on about Tumblr’s infrastructure. It’s a great read for many reasons (go read it). One of the greatest take-aways I had from this article, was this “new” programming language called Scala. I had never heard of Scala before, and was immediately intrigued. Also, after doing a lot of PHP back at the time – which I hate – I wanted something new, fresh and fun.

I started reading “Programming in Scala 2nd Ed” by Martin Odersky – creator of Scala – and was completely blown away by the language’s beauty, design and powers. I became obsessed with it, reading dozens of articles and tutorials, going thru many open source projects and watching conference talks. I even started listening to The Scala Types podcast. To top it off I attended the Coursera course given by Odersky himself called “Functional Programming Principles in Scala” (which attracted over 50,000 developers).

Every coder knows that the best way to really learn a new programming language is to dive right in – start writing code and doing your first project. Seeing as I had Tumblr to thank for introducing me to Scala, I figured it was only appropriate I do something with it’s API for my first project. Unfortunately I couldn’t find any Scala library for the Tumblr API, so I figured I’d write it myself.

And so tumblr4s is my first Scala project. It’s supposed to be a simple, elegant and idiomatic Scala implementation for Tumblr’s API. The GitHub repository has some examples on how to start using it. It’s pretty straight forward, and implements all the functionality of the Tumblr API.

I have put a lot of effort in to this, attempting to make it as “Scalaty” as possible. It took me a while to change my way of thinking from imperative/mutable to functional/immutable. In my code I tried to follow these concepts meticulously:

  • Functional programming – everything is an expression, no side-effects
  • Immutability – no use of vars and only immutable collections
  • Conciseness
  • Use the appropriate Scala tool in the appropriate place
  • Not write Java code in Scala

I also tried to comply with the Scala Style Guide as much as possible, mixed with some Effective Scala advice from Twitter.

And so I must say I’m pretty happy with the result. If you get a chance, please check the library out and let me know what you think. I’m especially interested in hearing the opinion of experienced Scala developers on some of the things I did, and if I should have done some things differently. I’d love your feedback.