Dear Scala Friend, I am going to start a small Twitter campaign to bring positivity into the Scala Community, and I'd love you to be a part of it. What is "ScalaThankYou"? ScalaThankYou is a small Twitter campaign in which people send tweets to thank other people or organizations that made a difference in… Continue reading Introducing #ScalaThankYou: Be a Part of It!
Category: Scala
Using Case Classes to Structure Your Data
Using Case Classes to Structure Your Data By Daniela Sfregola This article, taken from the pages of Get Programming with Scala, discusses an important tool in your Scala toolbox, called “case class.” Save 37% off Get Programming with Scala with code fccsfregola at manning.com. When coding, dealing with data is an… Continue reading Using Case Classes to Structure Your Data
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
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
Implicits: Rules and Applications
Scala implicits are a great tool to remove code duplication and convert objects from different domains. However, we need to learn not to abuse them: by hiding code they can make the code more concise but more cryptic at the same time. In order to use implicits efficiently, we need to know how the compiler tries… Continue reading Implicits: Rules and Applications