A Scala journey: from Haskell to the Scala 3 compiler
A Scala compiler engineer shares the story of his Scala journey, inspired by Scala's 20th anniversary!
A new day brings a new episode of our Scala interview series! Here’s our guest telling the story of his Scala journey, inspired by Scala’s 20th anniversary. He leads a team working on the Scala compiler.
How did Scala first come into your life, and what was your impression of it?
Just before starting university, I picked up Haskell. I didn’t yet know what the industry was like; I simply wanted to be cool and different and use a programming language as unlike the ones taught in introductory courses as possible. That turned out to be a great call, because knowing a few simple functional patterns gave me a big edge on harder assignments, even ones done in C. Haskell itself wasn’t very practical in those days, not even for small university projects. So when I heard about a language that lets you write functional code like Haskell yet runs on JVM, I had to find out more. I still remember reading Scala tutorials when I should have been listening to a physics lecture.
Describe the moment you thought, “Aha! Scala is awesome!” Which features and capabilities of Scala gave you that feeling?
The first of those moments came many years ago, during a computational geometry course. Every other week we had to implement algorithms, analyze their properties and build visualizations. Everyone else in my group went with Python, but I stuck with Scala. My choice of language let me model the algorithms easily as lazy streams of immutable state objects, each one standing for a consecutive step. That made the analysis and visualization simple. The benefit grew as the course went on and the algorithms got more complicated, needing things like backtracking. Sure, I could have done it in Python too, but I’d have been fighting the language and piling up boilerplate that would only have paid off in the long run. Scala was brilliant because it let me express my code effortlessly, exactly the way I wanted.
The most recent such moment was just a few weeks ago. I was reading up on functional frameworks for TypeScript. Structural typing offers some interesting advantages when combined with functional programming, but I didn’t like how verbose and noisy everything appeared. That’s when it hit me that the problem wasn’t TypeScript – it was that Scala 3 is genuinely remarkable. The using / given mechanism is brilliantly designed. It lets code be boiled down to just its essential parts, free of any unnecessary noise.
In what ways has Scala shaped how you tackle programming problems?
For one, Scala taught me to draw a clear line between an operation’s input and output and its environment. Even before I adopted any effect system, Scala on its own nudged me to think about this and structure my code to match. That way of thinking carries over to other languages and technologies and frequently leads to highly modular, maintainable code.
On top of that, Scala’s extraordinarily expressive type system means that whenever I have to write something in a dynamically typed language, it feels like coding with a blindfold on.
Which programming meme is your favourite?
Strictly speaking it isn’t a meme but a comic strip, and at first it had nothing to do with programming. Still, I’ve used it a great deal in programming debates. Working out what point I was making is left as an exercise for the reader ;)
Which tools and libraries do you reach for as a software developer?
These days I seldom work as a software developer, but I still regularly need to automate plenty of things. Scala CLI turns Scala into hands down the best scripting language available. Beyond that, Scala Toolkit is all I need, since uPickle and os-lib cover 90% of my work.
Where do you see Scala heading over the next decade?
I think Scala is now nearing the Plateau of Productivity of the frequently quoted Gartner Hype Cycle. I expect Scala to go on dominating certain niche use cases, like scalable systems that process huge volumes of events. I also think its popularity could rise steadily in other areas, such as scripting, dev-process automation and, above all, infrastructure-as-code.