scala exchange 2017

Scala eXchange 2017

14th -15th December, London

Recently, I had the opportunity to visit the annual Scala eXchange conference in London. With so many amazing super sessions, it’s always hard to choose which ones to join. This year I wanted to highlight two of them which I believe are showing the direction in which Scala, and programming as a whole are going into. The first one was “Move Fast and Fix Things” by Gabriele Petronella, about the power of ScalaFix. The second one, while not that technologically-focused, it illustrates how we think of programming and the way our views are changing.

Move Fast and Fix Things by Gabriele Petronella

Keeping software up to date can sometimes be a labor-intensive process, especially when upgrading to newer versions of a programming language. Normally, such an update brings with it new features that are useful to a programmer but sometimes it also removes features.

This talk was focused on the tool called ScalaFix which is a tool to automatically re-factor and re-write Scala code. The purpose of ScalaFix is to ensure that moving from an old Scala to the latest version. When upgrading to a new version of Scala, or any programming really it can be incredibly inconvenient. Being able to automate that process can go a long way as it prevents situations similar to what is currently happening with Python, which has to support different versions.

Gabriele gave some interesting examples of the power of ScalaFix and what it can do for you:

  • Re-factor non-procedural syntax – the re-factoring that ScalaFix can do can go from the most trivial things such as insert code that is optional and deprecated but will be mandatory in a later release of Scala.
  • No Auto-Tupling – In this example you’ve got a method that has a tuple in its parameters, but you don’t pass it a tuple instead you pass two distinct variables. ScalaFix can automatically re-factor this code such that a tuple is pass to the method.
  • Remove cartesian builder – Cats is a library for Scala that provides abstraction for functional programming. Essentially, what ScalaFix does in this case is look for operators or function calls that are deprecated in order to re-factor them to whatever the signature or syntax is in a newer version of Cats.

The way ScalaFix works is by analyzing the Abstract Syntax Tree of the source code. This Abstract Syntax Tree contains all the structure and tokens of the codebase. ScalaFix manipulates this tree by inserting or removing tokens according to rules so the outcome of this manipulation results in the same source codes but now updated for the latest version of Scala.

Rules in ScalaFix consist of checks and fixes. Checks in this case determines if a rule applies to a certain piece of code, fixes correspond with the actual re-factoring that is done by ScalaFix. The result of a rule is referred to as a Patch, which is essentially the same as a diff from Git; it defines what is added or removed from lines of codes.

ScalaFix is an interesting piece of tech. If it becomes more widely adopted it can be extremely useful in making upgrades to newer API versions much easier. Now, if only we could get something similar for Java…

How to name Things; The Hardest Problem in Programming by Peter Hilton

At the Scala eXchange in London Peter Hilton gave, in my opinion, one of the most intriguing talks that got me thinking about what we are doing when programming. To me, programming is about communication. But before I explain why I think that’s the case let us first look at what is usually meant by programming.

The Oxford dictionary defines ‘programming’ as the act or process of writing computer programs.

I find this definition to be unsatisfactory because it does not emphasize the communication aspect of programming. Even the synonyms for programming do not reflect that communication is integral to the act of programming.

In that case, using the word programming to describe what most software engineers at Anchormen do is a bit old fashioned. When we are writing code we do not only give instructions to the computer about what it should do. We are also communicating to our colleagues which steps we are taking and what the intent of these steps are with respect to the problem that we are solving.

Code that is written well, not only does what it’s supposed to do but is also concise, pleasant to read and easy to interpret. Perhaps a better definition of programming would be the following, the act and process of communicating instructions that form a program when executed by a computer.

At least with this definition we emphasize that programming is about communications and not just about writing instructions for a computer.

Like this article and want to stay updated of more news and events?
Then sign up for our newsletter!