Tag Archives: scala

Future beginning and end in Scala

A common issue noticed when reviewing pull requests is the understanding of the boundaries of Futures. In most cases, people take for granted that given a function with this signature the full body of the function will be executed in the Future. Let’s look closely into this with a couple of examples Example 1 Here’s… Read More »

How to construct objects in Scala

Scala’s object-oriented programming style comes with some syntactic sugar and a few tricks. In order to get a better understanding of how Scala works, we will examine a few Scala examples and the corresponding byte code (in reality, the Java code resulting from decompiling the class files). Examples Empty class Simplest possible example, an empty… Read More »

Scala’s uniform object model

Scala is functional and object-oriented. In a way, Scala is more object-oriented than Java as it has a uniform object model similar to Smalltalk’s. So what is this uniform object model? In a nutshell: every value is an object and every operation is a method call. That’s right, there are no primitive types, i.e. 1… Read More »

Unveiling blocking operations

Background Developing an application following the reactive principles can be quite challenging, specially when working with third party libraries, as these may not be fit for purpose, i.e. blocking operations. In such cases, the first challenge is to find the blocking operation and the second to confine it so that it does not affect the rest of the… Read More »

Functional programming

This post presents some features of functional programming with Scala. In essence, functional programming is about programming by making use of mathematical functions. All well-known features of functional programming are just a result of using mathematical functions, e.g.: referential transparency immutable state higher-order functions pattern matching I especially like ‘pattern matching’ as it allows for a… Read More »

Dealing with memory leaks

Background This post describes my experience playing around with Scala and some of its concepts like tail recursion and futures. It also offers an opportunity to see how a memory leak can happen and how to analyse it. I created a simple web crawler that takes a seed link (e.g. http://www.bbc.co.uk) and then, recursively (using tail recursion), collects all… Read More »