Contents

Alexandru Nedelcu - My Scala Story

Maria Kucharczyk

13 Feb 2024.8 minutes read

Alexandru Nedelcu - My Scala Story webp image

We're not slowing down on #scalaversary! This time, read the Scala Story of a long-time Scalar Speaker, software developer, author of Monix and Typelevel contributor, JVM, and functional programming enthusiast - Alexandru Nedelcu!

How did you first get introduced to Scala, and what did you think about it?

I picked Scala because I wanted to use the JVM to make our software more efficient. Still, I also felt the need for a language that resembled the pragmatic dynamic languages I was familiar with, namely Python and Ruby.

Around 2010, I was working for a startup, building a platform for delivering ads on mobile devices. We started with Python, as it was effortless to get something off the ground, but that didn't scale easily to the thousands of transactions per second that we needed to process. Initially, I was just wrapping lower-level Java interfaces, like the Servlet API or JDBC, with an eye for performance. Building soft real-time systems is the kind of problem that the JVM is well suited for, but you can't be wasteful. The code I wrote back then isn't the best, but some of it ended up on GitHub (not really a shameless plug, as it's unmaintained 😊).

Tell us about a moment when you realized, "Aha! Scala is awesome!" What Scala's features and capabilities made you feel that way?

Being a Python and a Ruby developer, I was initially confused, then mesmerized by Scala's yield keyword, which had a different semantic from Python's or Ruby's yield. Its use looked similar to Python's iterators (e.g., list comprehensions), except Scala's for-comprehensions desugar to a protocol making use of map/flatMap that's far more generic than plain iterators. I was hooked on the ability to work with Option or with Future in the same way I'd work with List.

There were other features of the language that I liked, such as the rich library for immutable collections, that exposed a great UX that I hadn't seen before (partially due to CanBuildFrom, which many consider to be a bad idea). My AHA moment was that I was looking at a language that exposed not just features targeting certain use cases (like Python or F# are doing) but rather a language that made more abstractions possible when compared with the mainstream languages. I was right, and I still feel that initial wonder.

If you could add a new feature to Scala, what would it be, and how would it benefit developers?

At this point, I don't think we need more new features, as the features of Scala 3 aren't utilized to their full potential. For example, I'd love to see the standard library make use of untagged union types, including explicit nulls, which isn't happening due to the standard library literally being shared with Scala 2.13.

I've seen experiments by Martin Odersky and the Scala Center for introducing continuations in the language, alongside some FUD surrounding it. I think that having support for continuations would be good, and it may even improve the status quo for us fans of monadic effects.

On the other hand, I would have loved to see "for-comprehensions" improved. F#'s "computation expressions" look more like regular, imperative code and even support "applicative functors". Say what you will about "monadic effects," but they aren't going away.

What are your go-to tools and libraries when working as a software developer?

I use IntelliJ IDEA for work, but also VS Code for general editing and even for working on Scala code, Metals being excellent. As a long-time Emacs user, I gave up on Emacs and started to use vim at the terminal. I also install vim keybindings in all editors that I use. I also recommend that people get familiar with GNU/Linux command-line utilities, which are so ingrained in my way of working that I don't think much about them until I see other people struggle to do basic tasks.

For Scala, the Typelevel ecosystem of libraries is very complete, and my latest crush is Decline for command line parsing. It's what all Scala code should be: FP, very compositional, and yet very approachable by beginners. Lately, I love using Scala CLI for personal scripts or experiments, and the Scala Toolkit is quite nice for that "batteries included" feeling.

As for other things I love, I can also recommend sbt-native-packager, which is this sbt plugin that takes the pain away from packaging your apps, enough that it's present in all my projects. Also, Scalafmt, sbt-tpolecat, and Wartremover, because all serious projects need automatic formatting and linting.

Tell us about a time when Scala proved to be a game-changer in a real-world project

Going back to the time I started using Scala, working on soft-real-time systems, I expected Scala to perform poorly, performance-wise, due to all the immutability. That didn't happen—quite the contrary, as it turns out, FP changes how you work. For example, being able to freely share data structures between threads improved the in-process caching I was doing, leading to less contention, even if concurrent mutable data structures can have better performance.

And, in all the projects I worked on, Scala changed how I worked due to its ability for fearless refactoring. This is mostly due to its expressive type system and culture for compile-time reflection. But also, FP increases our ability to reason about code and extract it from its context. I've never seen the kind of refactoring that we're doing right now at work, whereas with other programming languages and their ecosystems, it's often easier to just throw it away and restart from scratch. Which partially explains the popularity of web services.

How has the Scala community impacted your programming journey? Any standout interactions or support stories to share?

The Scala community is the only programming community that I've been part of. Even though I used many programming ecosystems, before Scala, I was just a user of other people's work and of Google searches whenever problems happened, not interacting much with others.

Becoming a part of a community is also a sign of my own maturity, but Scala's community also deserves a lot of credit for being very welcoming and very knowledgeable. Some people may raise their eyebrows when reading this; however, the communities of mainstream programming languages tend to be more aggressive and have a lower tolerance for going against the status quo. Although, granted, Python's community seemed nice, too.

I loved my interactions with people contributing to Typelevel projects, with experience and talent that exceeded mine. They welcomed me with open arms. I also loved my interactions with Monix's contributors. Here I was, a lone developer on the web, socializing only locally, in Romanian gatherings, and overnight, I started talking and collaborating with people from the US, Poland, Belarus, China, India, and many other places.

Did you have any hilarious or embarrassing moments while learning Scala?

I always had strong opinions, and in the first year or two, I was a harsh critic of Scalaz, which was Cats' predecessor. I just didn't see the point of all those abstractions and operators that made code hard to read. On one hand, I was right that Scala suffered from a proliferation of hard-to-read APIs. This was the age of internal DSLs, when Ruby was taking over some of Java's market, and Scala was flexible enough to accommodate such tastes. And Scalaz also had some unfortunate choices, such as the "tie fighter" operator.

But in retrospect, I was just afraid of learning new things. And while the abstractions and utilities exposed in Scalaz and Cats should be judged on their merits, sometimes going too far towards a style that doesn't feel like idiomatic or good Scala code, my critique was coming from a place of ignorance.

What advice would you give to someone just starting with Scala?

Scala has incredible depth in how it approaches problem-solving. It's not a one-trick pony or a "one way of doing things" programming language. And many in the community show incredible knowledge. This can be intimidating. However, the language is easy to pick up, and you don't need to go all in on functional programming or on actors or whatever else your peers seem to fancy.

Scala is quite fun, so let the fun guide you. And to speed up the learning process, the official community channels are quite welcoming.

How have you seen Scala evolve over the years, especially in your field of work?

When I started to use Scala, it felt more experimental, libraries inspired from concepts and APIs from all over the place (e.g., Ruby, Erlang, Haskell, or the wild side of Java) and tooling leaving much to be desired. I remember being attracted to Lift back then, although Play Framework eventually saved me. Nowadays, Scala seems to have its own voice, the libraries and tools are more mature, and the choices more obvious. It's no longer a risk for businesses to pick it for their next projects.

Scala has evolved, in general, towards more static-type safety. This is good for projects for which defects can be costly, such as finance, but it can be bad for projects where you just want to have fun and get things done. Scala still manages to be usable and playful.

What are your predictions for the future of Scala in the next decade?

I think that Scala 3 is a great programming language, and it will thrive. Wrote an article about it 😃

It's SCALA's 20th anniversary!

Join our big Scala Fiesta at the Scalar Conference 2024 and celebrate it with style! We already announced the agenda, but it's not the end of surprises - follow our social media and #scalaversary hashtag to be up to date with all the news!

Secure your spot now, and we'll see you in March!

Scalar 2024

Blog Comments powered by Disqus.