It's been a while since the last article here, but I am back. I now work at Linkfluence, and I spend my days writing code mostly in Scala. So far it is an incredible experience: I return to professional Scala and it feels good. The ecosystem is vibrant and alive with some projects like ZIO, Typelevel ecosystem, and the upcoming Scala 3 version. This post is not about all this though, but about some tools & nice to have when developing in Scala.

Repl

Now that I am a full time Scala developer, I needed to equip myself with good tools. And Amonite is exactly that: a perfect replacement for the default Scala REPL. It features pretty printing, syntax highlighting, imports from ivy repositories,...

And you do not even have to force your team to use it on existing projects ! Just drop the following snippet in ~/.sbt/1.0/global.sbt

libraryDependencies += {
  val version = scalaBinaryVersion.value match {
    case "2.10" => "1.0.3"
    case _ ⇒ "1.6.7"
  }
  "com.lihaoyi" % "ammonite" % version % "test" cross CrossVersion.full
}

sourceGenerators in Test += Def.task {
  val file = (sourceManaged in Test).value / "amm.scala"
  IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
  Seq(file)
}.taskValue

// Optional alias to make it super easy to call
addCommandAlias("repl", "test:runMain amm")

This way, in any sbt project calling repl will launch an amonite repl !

VS code metals

These days, the new cool kid around when it comes to edit code is Visual Studio Code. And when you write Scala, you can use Metals which offers support for completion, doc,... I use it to replace IntelliJ when I need to save battery.