Scala is an object-oriented, open-source programming language released under the Apache 2.0 license. This makes it possible to examine its source code for learning or adaptations.
According to the Scala website:
Scala combines object-oriented and functional programming in one concise, high-level language. Scala’s static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries.
Scala runs on the JVM, so Java and Scala stacks can be freely mixed for completely seamless integration. In fact, there are many similarities in the syntax of both languages.
Since it runs inside the JVM then we can install it on almost any operating system such as Windows, Linux and macOS, but it also runs in the browser using the JavaScript engine.
Where is Scala used? Well, Scala is used to develop all kinds of applications from Machine Learning to web applications. This makes the language quite flexible, inclusive and stable.
I will show you the installation process in Linux Mint, so you can use it without too many problems.
Preparing the system for Scala
Installing Scala is easy, but you need to prepare the system so that it can happen smoothly.
First, open a terminal via the main menu or by pressing the CTRL + ALT + t
keys. When it opens, update the distribution completely:
sudo apt update
sudo apt upgrade
Normally, Java is already installed in Linux Mint, but in case it is not, you can run this command
sudo apt install default-jdk
Then, you can check the version installed on the system:
java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
Besides this, you should already have the curl
command installed, but still, you have to be sure of that.
sudo apt install curl
And check the installed version:
curl --version
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
With this, we can continue the process.
Install Scala Compiler on Linux Mint 20
The installation process is simple because the developers have created a script that does everything for you. So, there should be no issues.
In the terminal, just run this command to download and run the script.
curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup
Answers the question about adding the installation directory to your PATH
Checking if ~/.local/share/coursier/bin is in PATH
Should we add ~/.local/share/coursier/bin to your PATH via ~/.profile? [Y/n] Y
If all goes well, you will see this output on the screen
After this, you need to log out and log back in to apply the changes to the shell. You can then run this command to see if Scala is ready.
scala -version
Sample Output:
Scala code runner version 3.1.2 -- Copyright 2002-2022, LAMP/EPFL
This method is the one recommended by the developers themselves, since it provides the latest version, it is easy to perform and therefore the one that can give fewer errors.
Conclusion
The Scala programming language is a modern language that aims to rival other more established solutions such as Java. The latter being an important part of the language which ensures stability, but above all robustness.
I hope you liked this post, and help us by sharing it with your friends. You can also tell us your experience with the language.