Scala for Python developers

Antoine Doeraene
6 min readFeb 5, 2020

Introduction

If you are a Python developer, perhaps you ever felt the need to step up your Django application, or your data pipeline, to the next level, towards a technology which allows to build larger, safer and more robust softwares.

It turns out that Scala is an excellent fit to these issues. In particular for Python developers who, I’m sure, value the clear and intuitive syntax, the scripting-like feeling while coding, and the support for object oriented programming. Good news, you also have all of that in Scala, and so much more…

One thing that could refrain someone is the “where to start” impression that a new language can give. So let’s be reassuring and put in parallel the basics of Python and the basics of Scala. Also, the resistant legend that Scala is hard is certainly something that could push back a company to take the last leap. Well, as you will discover, you can learn in, say, two days basically everything that you were doing in Python (except of course manipulating the `__dict__` field of objects, but you should not do that).

In the following, we are going to explore some of the basics of Scala with a Python developer mindset, and see how some of the features of Python translate to Scala.

There are three important things to note before diving in:

  • As you might know, Scala is a statically typed, compiled language. I’m not stressing this fact in the following. This is because how matter how you put it, it is only when you actually practice the language that you feel how comforting and helping it is. After all, the compile phase can (also) be viewed as a first set of unit tests, that are automatic and mandatory.
  • This should not be taken as a “dictionary” between Python and the basics of Scala. In fact, a dictionary between two languages should never exist. You should rather read this with the mindset of “I’m doing this in Python, how would Scala developers achieve the same?” instead of “this class in Python translates to that class in Scala”.
  • you won’t find any instruction for setting you up. If you’re like me and you consume Medium articles while waiting at the dentist, or doing the line at your grocery store, then you most probably don’t have a computer to do it right now anyway. There are plenty of resources out there for helping you with that. Most of them will probably include installing sbt, IntelliJ, adding metals extension for VScode…
Antoine Doeraene

Mathematician, Scala enthusiast, father of two.