Thursday, February 20, 2020
Home Scala Learning Scala: A non-Java JVM language

Learning Scala: A non-Java JVM language

Author

Date

Category

From 1996 till date, Java captured the tag of platform independent and there are thousands of Bhakt of JAVA who can be found in the IT-SEZ of India.

Every programer says JAVA is platform independent so it is good to write code in JAVA but I have a question.

What is the meaning of Platform independent ?

Does this mean the program will run in any Operating system ?

  • If yes then what about C language which can be run in Windows as well as Linux
  • If yes then what about C++ and Python which can be run in Windows as well as Linux
  • What about JS and GO Language ?

The Answer is Platform independency is not perfectly defined in the world of computer.

We can write C program in any OS and the source code can be exactly same for all the platform. So from that point of view it may look like platform independent but the output of the compiled C program will not run in both Windows & Linux unlike JAVA. We need to compile the code written in C program separately in different OS to get different byte code.

So JAVA got the standing ovation for its write once run everywhere type platform independent feature. This type of freedom is achieved due the capability JVM. But the monopoly of the JAVA is now challenged by another powerful language whose byte code is also executable by JVM i.e. Scala.

Yes Scala program executes inside the JVM therefore it is also interoperable with JAVA.

But why a new language Scala not Java ?

  1. Scala is Open Source and can use the legacy of JAVA libraries plus its own.
  2. It is both Object Oriented and Functional Programming where as JAVA is only Object Oriented
  3. It support operator overloading
  4. Scala code is very compact to express than JAVA
  5. It support lazy evaluation
Scala is a general-purpose, high-level, multi-paradigm programming language. It is a pure object-oriented programming language which also provides the support to the functional programming approach.

FAQ


Can I develop web application using SCALA ?
Yes. There are many framework available using which web application can be developed using SCALA.
One of the most popular MVC based web framework is the Play framework.


Why the name is SCALA?
The name came from SCALABLE as the language is focused more on scalable and distributed computing. The popular AKKA open source library has been written in SCALA to create concurrent, distributed and fault-tolerant application.

Can SCALA compete with matured JAVA?
The best way to evaluate any new technology is just by using it. So do some hands on in SCALA to explore the answer. By the way SCALA is not new it is first released in 2004 around 15 years ago. Those who are working in Hadoop and other distributed programming platform they are well aware about SCALA programming language.

Installing Scala:

  1. First, make sure you have the Java 8 JDK installed.
    java -version(Make sure you have version 1.8.)
    https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Download SBT (Scala build Tool) zip file for your platform from the below URL
    https://www.scala-sbt.org/download.html?_ga=2.27341368.587888951.1555695514-1743134162.1554908988
  3. Unzip the folder and set Path to the bin> sbt file
  4. Test the sbt command in the console to ensure the installation.
C:/> sbt sbtVersion

Here is my first program with Scala: HelloWorld.scala

object Demo {
  def main(args: Array[String]) {
     println("Hello World");
  }
}

To run the Scala program, just run the following code in your computer’s command prompt.

C:/ scalac HelloWorld.scala
C:/ scala Demo

Output:

Hello World

We are coming with more articles on Scala very soon. Till then, keep reading the other articles present on the blog!

Happy Coding!

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

Niladri Bihari Mohanty
I am a Scientist-C at National Informatics Center. I am a hard core programmer with absolutely no sticky relationship with any specific language.

Recent posts

Recent comments