Who am I?

Software engineer, passionate about math, physics, technology and science in general.

I'm a true polyglot when it's about coding and I usually don't like spending my time argumenting which language is better as I would rather spend it learning a new one. This doesn't mean that I don't have opinions: I do have strong opinions on tools and practices in general and I like discussing about them as this is to me the way forward to improve.

With a past characterized by some Java, C# and lots of PHP/Symfony development I recently begun moving toward functional programming with Scala and considering the possibility to learn also some Haskell to improve my understanding of the functional word. I also begun hanging out at the London Scala User Group events where I enjoy hacking with some amazing people.

I live in London and I spend my time off between good food, parks, books, movies and anything that will attract my (eager) curiosity.

More about me

18 Mar 2014 - TDD game of life in Scala

In this series of articles I want to talk about how to build the popular Conway’s game of life in Scala with a functional and test-driven approach. We did this with the London Scala User Group during an Hack The Tower event and it was a really fun way to get people involved in Scala and to see some TDD in action.

The game of life is an example of cellular automata in which an imaginary universe is represented by a board divided in cells that can be alive or dead; at each generation of the simulation the board evolves to a new status; some cells dye, other cells live on and other get born following four simple rules:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

It’s amazing how, given an initial state with some living cells, these four simple rules can give birth to a variety of more or less chaotic behaviours. To start with this we are going to imagine that we have an infinite board and on this board we keep track only of living cells. We will avoid using classes and other OO-like constructs and we’ll focus on functions and data types.

See full post
02 Mar 2014 - Bootstrapping an sbt project

I usually find the initial frustrations that I experience when I try to learn a new language to depend quite often on getting acquainted with the tools. When I approached Scala sbt has been a major source of headaches and this often distracted me from learning the language. It is quite a complex tool, maybe a bit too complex sometimes, but it is also very powerful when you understand it: the fact that the build file is a Scala class itself allow you to achieve great levels of reuse and modularity in your build files. In this small tutorial we won’t talk about any advanced feature of sbt, but we will see hot to get out of the way some common roadblocks and how to get quickly started with a new project.

See full post
19 Feb 2014 - Retrying the ask pattern

In the last months I participated to the course about Reactive Programming on Coursera. It was a great course, and quite hard too in several parts. I quite liked learning and playing with the Akka Actor System architecture: I appreciated the focus on resilience via supervision strategies, I liked the Actor abstraction and how strongly it resembles OOP in many ways (I would say that is more object oriented than classes in many object oriented languages) and I enjoyed the possibility to use routers to factor out big processes to many parallel (and possibly distributed) actors.

During one of the exercises, while trying to use the ask pattern in a distributed system with faulty communication I ended up writing a small reusable snippet of code that allows retrying the same communication a specified number of times before failing in case of timeout in receiving the response as follows:

val f: Future[Any] = target.askretry(message, nOfAttempts, attemptsRate)

But let’s start with a brief introduction to the ask pattern…

See full post
13 Feb 2014 - Simple chat on Akka Actors

The past Saturday I’ve been attending the Hack The Tower in London Salesforce office. The format is basically the one of an hackaton where people coming from different technology user groups (namely Scala, Java and Clojure) meet and have fun for one day in the nice setting of the Heron Tower in the centre of the City of London. It was the second time for me to attend this event, I will probably speak about the first one in another post, and I joined the group of people that was there to work on Scala.

See full post