Minimal set of tools for scala 2 or 3

First of all, I am completely new to scala. But I have many years of experience in programming for high performance computing (fortran, later python) as well as functional programming (Wolfram Mathematica). So, I understand the basic concepts of the language quite well, but unfortunately I cannot penetrate its organization. My basic problem is that I cannot find the stuff that interests me in one place. All the information is dispersed over many sites. Therefore, I would appreciate answers with a couple of well targeted links.

Below I will describe a few of my very basic questions. They are so short and simple that it make no sense to split them in several posts.

  1. Scala 2 vs. Scala 3. I learnt that they are very different languages. Scala 3 is essentially not backward compatible. There is no full documentation. Does it mean that one should start with Scala 2? What are the pros and the contras?

  2. Style: 2 spaces is recommended indent for Scala 2, whereas the proper spacing is mandatory in Scala 3. This means a dedicated editor is needed and I cannot use my favorite Emacs editor, right? I am a bit skeptical about IntelliJ IDEA because it is a huge tool. The .dmg package for MacOS is 776MB. I already have a huge Anaconda on my laptop. With only 5GB free space currently available I simply cannot effort this tool.

  3. Exactly due to the space limitation, I cannot install many packages via brew because it insists on installing the full xcode. Can one get along without xcode? My attempt to install Metals for emacs was therefore not successful. What would be the minimal tool to type sbt projects?

  4. Assume I want to find a documentation on the MurmurHash3 function from the standard scala library, where I have to look?

  5. I can compile a program with scalac, it can also generate .jar files. However, there are cases when java cannot run this file because it does not include Scala stdlib. Does it mean that scalac is useless and one should go with sbt even for tiny projects?

  6. On my laptop I currently have 3 versions of java, one is from Apple, and in the course of work I had to install two more:

java version “1.8.0_321”
Java™ SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot™ 64-Bit Server VM (build 25.321-b07, mixed mode)

java version “17.0.2” 2022-01-18 LTS
Java™ SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot™ 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

Which one should be preferred?

I am sorry for being so incoherent. I am just trying to understand things and organize myself. Therefore your suggestions on how to do scala programming with minimal tools, however not interactively are super welcomed.

  1. Scala3 is very new and the ecosystem hasn’t caught up yet. I would rather stick with Scala 2, at least while learning.
  2. I would recommend metals and vscode.
  3. The recommended way of installing Scala tools is thought coursier:
  4. On the Scaladoc. For 2.13 and for 3.1.1
  5. You can also run those using the scala command, as I said on StackOverflow that worked out of the box on Scala 2, not idea with Scala 3. - BTW, for any real project you want to use sbt anyways.
  6. Any JDK should work as long as it is at least 8 if you want stability stuck with 8 or 11, however the language already supports 17
1 Like

Thank you, your answers are very useful, concise and precise!

I second the suggestion of using coursier for installing most tools.

I’m not sure, why the spacing requirements limit your choice of editor? If it isn’t clear, Scala 3 requires you to use consistent spacing, i.e. code on the same nesting level should have the same indent, but it doesn’t force any specific indentation width.

Did you use the emacs installation instructions for Metals? It describes how to install metals via an emacs-command or via coursier, no xcode or brew required. Otherwise, if you really want minimal, you can just open sbt in a terminal, enter ~compile to let it continuously compile and show errors, and edit in emacs without any additional tools. Metals gives you a lot of utility, like completion and inline error display, but it is not strictly required.


Thank you for your answers, really useful! Yes, I followed emacs installation instructions. In fact, i would be completely happy if it works. But I found that emacs has its own PATH environment, which is different from the PATH in the system. Somehow it does not find all the java tools. I could probably make it work, but it is not straightforward. By the way, my emacs recognizes now the scala mode, but the “TAB” for indentation does not work. I got used that this is a nice way to ident fortran programs, for instance.

Hi, I am sorry to disturb, I followed your suggestion and installed vscode with 3 more extensions as it suggested. Trying to run the code give me Exception in thread "main" java.lang.IllegalStateException: Unable to create a system terminal . Any idea what can be the reason?

Hi, sorry no idea to be honest; I have never seen that error.

You may try asking in the metals discord server: Scalameta

For an easy to install of tool set you may consider IntelliJ with Scala plugin. Beside a very good development environment it will also install Java and SBT and other needed tools, so they do not need to be installed or maintained separately. The IntelliJ Community edition is free and works well with Scala. The Ultimate edition add some more tools for web and database development and is worth the price. As mentioned with other tools, Scala 3 support is not fully mature yet and requires some patience. For smoother experience you may stick with Scala 2 for time being.

1 Like