Gems in the Scala Ecosystem

Gems in the Scala Ecosystem
Photo by Anton Savinov / Unsplash

Years ago, I used to think "Scala tooling is nonexistent or bad". I've been too deep in the Scala world to compare accurately with other languages, yet I feel, as 2024 is coming to an end, that Scala tooling is in very good shape !

From small tools...

What a better way to start than introducing dexsearch ? Dexsearch is a small utility which allows to easily find dependencies in the Scaladex and copy to the required code to use it in the build tool of your choice. Funny thing, it is written in Scala with ScalaJS.

In this small tools list, let's include Coursier which serves as a building block for bigger tools. Coursier super power is to deal with dependencies, be it just getting meta data or fetching them. It is also able to complete them. The thing I really like with Coursier is its easy to embed API which is perfect to build more tools with it. As a real use case (work use case), with Coursier API and a few lines of Scala code, it is quite easy to create a tool that just check some repository for newer versions of some artifact, and update a Gradle based project written in Kotlin.

Speaking of dependencies, Scala-steward is very good at maintaining your Scala applications up to date. With an embedded Github action, it offers customization and ease of use in a corporate environment. Of course it uses Coursier API underneath ! At work, we use it with a custom configuration to carefully group and select what we want to be updated. For instance, in several repositories, we group by version update type (ie major, minor and patch), or by organization ID.

But unlike many tools dedicated to dependency auto updates, Scala-steward makes use of Scalafix to apply modifications to your code, according to required changes in your dependencies. Having scalafix migrations available on library updates is a plus as a user. And even if you do not use scala-steward to update your dependencies, you can run migrations on your own in sbt.

To bigger (historical) tools...

I think it is always valid to name sbt here. Yes it has quirks and oddities but it does the job and does it well. With plugins it is easy to shape your projects, format, publish to repositories, create docker images, manage your version. At work we use a bunch of plugins :

  • sbt-native-packager : the go to when you deploy your apps on Kubernetes and need to publish Docker images
  • sbt-tpolecat : which helps us having sane default scalac arguments, no matter the Scala version
  • sbt-scalafmt : to keep our code formatted
  • sbt-git : to produce version number, mainly

... And cool "newcomers" !

Those days I am a big user of scala-cli. This tool is very handy to make Scala the scripting language you always wanted. In my opinion it also showcases how Scala is able to be used for a wide variety of tasks. Nowadays, instead of writing a script in bash/zsh/... , I just roll out a script in Scala. Thanks to project like os-lib (and more broadly the com-lihaoyi ecosystem) it is possible to write scripts as easily as in Python, Ruby... Even if I prefer to write purely functional code, using this paradigm in short scripts is not always relevant and this is where the diversity of the Scala ecosystem really shines. Here is a bunch of things I enjoy with scala-cli : its ability to pull in dependencies (thanks Coursier !) , firing up a REPL (with dependencies !) or creating a simple artifact is just one command line. Those days, I find it quite the perfect tool to get started with Scala for newcomers : Scala 3 & scala-cli is a good match to have a "pythony" experience.

Closing words

I often heard that Scala lacked tooling. I definitely think this got solves a long time ago. Some may say IDE support is poor, but in my experience, it always worked well, both IntelliJ and metals. Scala 3 brings a syntax which is scripting friendly and I think Scala is eventually being very accessible for newcomers. Unfortunately the momentum & hype went away a few years ago but for the players who stayed I think it has never been more relevant : good tooling, paradigm choice (go fully functional, go object oriented, mix... ), vibrant sub-communities, maturity. Scala has it all.