A Scala journey: from Python and Ruby to open source and Typelevel
Discover the Scala journey of a longtime Scala conference speaker, software developer, open source library author, Typelevel contributor and fan of the JVM and functional programming!
The celebration of Scala’s 20th anniversary keeps going at full speed! This time we bring you the Scala journey of a longtime Scala conference speaker, software developer, open source library author, Typelevel contributor and fan of the JVM and functional programming!
How did Scala first come into your life, and what was your impression of it?
I chose Scala because I wanted the JVM to make our software more efficient. At the same time, I needed a language that felt like the pragmatic dynamic languages I already knew, namely Python and Ruby.
Around 2010 I worked at a startup that was building a platform for serving ads on mobile devices. We began with Python, since getting something off the ground with it was effortless, but it couldn’t easily scale to the thousands of transactions per second we had to handle. At first I was simply wrapping lower-level Java interfaces such as the Servlet API or JDBC, keeping performance in mind. Soft real-time systems are exactly the kind of problem the JVM handles well, provided you aren’t wasteful. The code I wrote in those days isn’t my finest, but part of it landed on GitHub (it’s no longer maintained 😊).
Describe the moment you thought, “Aha! Scala is awesome!” Which features and capabilities of Scala gave you that feeling?
Coming from Python and Ruby, I was confused at first and then fascinated by Scala’s yield keyword, whose semantics differed from yield in Python or Ruby. Using it resembled Python’s iterators (list comprehensions, for example), except that Scala’s for-comprehensions desugar into a protocol built on map/flatMap that is much more generic than plain iterators. Being able to work with Option or Future the same way I’d work with List got me hooked.
I liked other parts of the language too, like the rich library of immutable collections, which offered a great UX I’d never encountered before (partly thanks to CanBuildFrom, which many people regard as a bad idea). My AHA moment came when I realized this language didn’t merely offer features aimed at specific use cases (as Python or F# do), but instead enabled more abstractions than the mainstream languages did. I was right, and that first sense of wonder is still with me.
Which new feature would you add to Scala, and how would developers benefit from it?
At this stage I don’t think we need further features, because Scala 3’s features aren’t yet used to their full potential. For instance, I’d love for the standard library to use untagged union types, including explicit nulls – which isn’t happening because the standard library is literally shared with Scala 2.13.
I’ve seen experiments by Martin Odersky and the Scala Center aimed at introducing continuations into the language, along with some FUD around them. I believe support for continuations would be a good thing, and it could even improve the status quo for those of us who like monadic effects.
Then again, I’d have loved to see “for-comprehensions” get better. F#’s “computation expressions” read more like ordinary imperative code and even support “applicative functors”. Whatever you think of “monadic effects”, they’re here to stay.
Which tools and libraries do you reach for as a software developer?
At work I use IntelliJ IDEA, but I also use VS Code for general editing and even for Scala code, since Metals is excellent. After many years with Emacs, I abandoned it and switched to vim in the terminal. I also add vim keybindings to every editor I use. I’d also encourage people to learn the GNU/Linux command-line utilities; they’re so deeply woven into how I work that I barely think about them until I watch others struggle with basic tasks.
For Scala, the Typelevel library ecosystem is very comprehensive, and my most recent crush is Decline for parsing command lines. It’s what all Scala code ought to be: FP, highly compositional, yet very accessible to beginners. Recently I’ve loved using Scala CLI for personal scripts and experiments, and the Scala Toolkit is really pleasant for that “batteries included” feeling.
Among other things I love, I’d also recommend sbt-native-packager, an sbt plugin that makes packaging your apps painless – so much so that it’s in every one of my projects. Likewise Scalafmt, sbt-tpolecat and Wartremover, since every serious project needs automated formatting and linting.
Share a time when Scala turned out to be a game-changer in a real-world project
Back when I first started with Scala, working on soft-real-time systems, I assumed it would perform badly because of all the immutability. That’s not what happened – quite the opposite, since FP turns out to change the way you work. Being able to share data structures freely between threads, for example, made my in-process caching better and reduced contention, even though concurrent mutable data structures can be faster.
And in every project I’ve worked on, Scala changed my way of working because it allows fearless refactoring. That’s mostly thanks to its expressive type system and its culture of compile-time reflection. FP also improves our ability to reason about code and lift it out of its context. I’ve never seen refactoring on the scale we’re doing at work right now, whereas with other programming languages and ecosystems it’s frequently easier to throw everything away and start over. That partly explains why web services are so popular.
How has the Scala community shaped your programming journey? Any memorable interactions or stories of support?
The Scala community is the only programming community I’ve ever belonged to. I’d used many programming ecosystems before Scala, but I was merely a consumer of other people’s work and of Google searches whenever something went wrong, and I hardly interacted with anyone.
Joining a community also reflects my own maturing, but Scala’s community deserves a great deal of credit for being so welcoming and so knowledgeable. Some readers may raise an eyebrow at this, but communities around mainstream programming languages tend to be more aggressive and less tolerant of challenging the status quo. Admittedly, Python’s community seemed nice as well.
I loved interacting with Typelevel contributors whose experience and talent surpassed mine. They welcomed me warmly. I also loved interacting with the contributors to my own open source library. There I was, a lone developer on the web who socialized only at local meetups, and practically overnight I was talking and collaborating with people from the US, Belarus, China, India and many other places.
Were there any funny or embarrassing moments while you were learning Scala?
I’ve always held strong opinions, and during my first year or two I was a fierce critic of Scalaz, the predecessor of Cats. I simply couldn’t see the purpose of all those abstractions and operators that made code difficult to read. In one respect I was right: Scala did suffer from a proliferation of hard-to-read APIs. It was the era of internal DSLs, Ruby was eating into some of Java’s market, and Scala was flexible enough to cater to such tastes. Scalaz also made some unfortunate choices, like the “tie fighter” operator.
Looking back, though, I was simply afraid of learning new things. The abstractions and utilities that Scalaz and Cats offer should be judged on their merits, and sometimes they do go too far toward a style that doesn’t feel like idiomatic or good Scala – but my criticism stemmed from ignorance.
What would you tell someone who is just getting started with Scala?
Scala approaches problem-solving with remarkable depth. It’s neither a one-trick pony nor a “one way of doing things” programming language. Many people in the community also display remarkable knowledge, which can feel intimidating. Still, the language is easy to learn, and you don’t have to commit fully to functional programming, actors or whatever else your colleagues happen to be into.
Scala is a lot of fun, so let that fun lead you. And if you want to learn faster, the official community channels are very welcoming.
How have you watched Scala change over the years, particularly in your area of work?
When I began using Scala, it felt more experimental: libraries drew on concepts and APIs from everywhere (Ruby, Erlang, Haskell or the wild side of Java, for instance), and the tooling left a lot to be desired. I remember being drawn to Lift at the time, although Play Framework rescued me in the end. Today Scala seems to have found its own voice, its libraries and tools have matured, and the choices are clearer. Choosing it for a new project is no longer a risk for businesses.
Overall, Scala has moved toward greater static type safety. That’s great for projects where defects can be expensive, like finance, but it can be a drawback for projects where you just want to have fun and get stuff done. Even so, Scala remains usable and playful.
Where do you see Scala heading over the next decade?
In my view Scala 3 is an excellent programming language, and it will flourish.