Scala Introduction

    Hey friends, in today’s blog, we are going to learn about a programming language that is functional as well as object-oriented in nature. Scala Programming language is based on Java , so if you know the Java syntax, it will be easy to learn Scala.

    Further, if you do not have expertise in Java but if you have knowledge about another programming language, like C, C++, C#, or Python, then it will also help in grasping Scala concepts since most programming basics hold true for these programming languages leaving the syntax differences that can be learned.

    Now, to understand it, we first need to be clear about the two concepts:

    1. Functional Programming: A paradigm where programs are composed using functions where a function takes some arguments and returns the same result on the same input variables, with no other side effects. Secondly, where a function can be passed as an argument to another function or a function can be returned as a result.
    2. Object Oriented Programming: A paradigm where a real-world problem can be implemented in the form of classes and objects following the basic OOPs concepts like Abstraction, Encapsulation, Inheritance, and Polymorphism.

    The file extension of the Scala source file may be either “.scala” or “.sc”. Scala language lets you create any kind of application like web, mobile, desktop, etc.

    Scala can easily be installed on any UNIX or Windows-based system. There is one prerequisite before installing Scala on your machine; you must have Java 1.8 or greater installed on your computer. If Java is already installed, you can verify it by running the below command on the CMD:

    Java -version

    Once you have Java installed on your machine, you can follow the below steps to proceed:

    1. You can download Scala from its official website: https://www.scala-lang.org/download/
    2. Set up an environment variable SCALA_HOME to point to the “scala” file where the language is installed in the package.

    1. Next, add this SCALA_HOME variable to the PATH environment variable.

    1. Now, to check if it has been installed successfully. Open a fresh command prompt window and type “scala”. Something like the one below should appear on the screen.

    Note: To start experimenting with Scala right away, you can use Scastie in your web browser. Scastie is an online “playground” where you can experiment with Scala examples to see how things work, with access to all Scala compilers and published libraries.