You are here
Home > Tech >

How to install Scala

The first question to ask is, what is Scala?

Scala is an object-oriented, general purpose programming language, which is also functional. Scala also supports static typing. Scala was designed to give a simple interface for functional programming while addressing the criticism aimed at Java. The code written in Scala is compiled to Java bytecode, which then runs on JVM. So Scala and Java are interoperable.

On the other hand, Scala offers some of the best known features of functional programming, including currying, type inference, immutability, and pattern matching. Higher-order types in Scala is also pretty awesome. People who have Java knowledge and have worked on other programming languages, such as PHP and NodeJS, would love to know that Scala has the best of all worlds. By this I mean that while Scala provides strong OO programming with the best of Java, it also includes features such as operator overloading, optional and named parameters, raw strings, and much more.

You can know more about Scala on the official website. Now let’s see how to install Scala on a Linux machine. Installing Scala is very easy:

    1. Download the latest version of Scala from here, ver. 2.12.2 as of this writing.
    2. Unzip it and place the folder wherever you want.
    3. Setup a couple of path variables in your .bashrc or .zshrc file, as below:
export SCALA_HOME="/home/sunny/Programs/scala-2.12.2"
export PATH=$PATH:$SCALA_HOME/bin

That’s it. You’re done. Now open a new terminal window and type the following command:

scala

You should see a prompt like this:

Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Type in expressions for evaluation. Or try :help.

scala>

If you get the “scala>” prompt, your installation was successful. You can type :help at the Scala prompt for a list of commands. You can type :quit or :q to exit the Scala CLI.

Sunny Srinidhi
Coding, reading, sleeping, listening, watching, potato. INDIAN. "If you don't have time to do it right, when will you have time to do it over?" - John Wooden
https://blog.contactsunny.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Top