A few months ago, I started looking into the Twitter API and I have developed twitter4s, an asynchronous non-blocking Twitter client in Scala. In this article, we will introduce twitter4s providing examples of how to download tweets from a user timeline and how to perform some simple data analysis. The code shown in this tutorial… Continue reading twitter4s: A Scala client for the Twitter API
Tag: Scala
How to build a Scala REST CRUD application with Spray
In previous articles we have described how to build a REST Api with Spray and how to (de)serialize case classes with json4s. However, in order to keep things simple, we didn't always do things as suggested by spray.io. In this article we will redeem ourselves and we will describe how to build a REST CRUD… Continue reading How to build a Scala REST CRUD application with Spray
Static Duck Typing in Scala
Structural Types is a neat feature of Scala that not many developers know or use. This article will provide a brief introduction on what they are and how to use them. What are Structural Types? Types can be really powerful in Scala: they can define classes, abstract classes, objects, traits, functions...and a lot more! What… Continue reading Static Duck Typing in Scala
Performance Comparison between immutable Seq, List, Vector
I have recently attended the Advanced Scala Training Course by TypeSafe during the Scala Days Conference in Amsterdam. During the course we discussed a lot on how to write cleaner and more performant Scala code: one of the parameters that can greatly influence your performance is the type of collections used. Which type of collection… Continue reading Performance Comparison between immutable Seq, List, Vector
Enrich My Library – Extension Methods
(At the time of writing of this article, this Scala technique was called "Pimp My Library", which was also reflected in its title. This term is now obsolete and discouraged and has been replaced with a much clearer and less offensive term: "Extension Methods". This article has been edited to reflect this). Methods are an… Continue reading Enrich My Library – Extension Methods
Loading Configurations in Scala
The separation of configuration from code is a good practice that makes our system customisable as we can load different configurations according to the environment we are running it in. In this article we will describe different approaches to load configurations in Scala and how they can be combined together: loading configurations from a file,… Continue reading Loading Configurations in Scala
How to Compose Futures
Futures are a powerful tool that has been developed by the Akka team and then adopted as a standard Scala library from version 2.10. A Future is a placeholder for a value that will be available in the future: thanks to it, it is possible to run operations in parallel and to worry about what… Continue reading How to Compose Futures
How to use Case Classes in Scala
Scala has adopted many concepts from other functional programming languages: higher-order functions from Haskell, actors model from Erlang, futures from Clojure, etc. However, Scala has also introduced new tools in the functional programming world: case classes is one of them. Case classes are a special type of classes, as the compiler automatically adds some useful… Continue reading How to use Case Classes in Scala
Akka Actors: Best Practices
Actors are components of message-passing systems that are particularly popular these days. They make concurrency a lot easier to understand compared to the traditional thread-monitor-lock model. An actor is a thread-like program that run independently from other actors. It has a mailbox to receive messages from other actors, where each message represents a task to… Continue reading Akka Actors: Best Practices
Type Parameterisation
The following article provides a list of all the different type parameterisations available in Scala and how to use them. Variance A class can depend on a type constructor. The following is an example trait that depends on a generic type T: The above declaration implies that the generic type T is the only valid… Continue reading Type Parameterisation