SCALA: Introduction of scala

Scala is object oriented and functional programming language which is created by Martin Odersky and it was first released in 2003.

Scala is known due to development productivity, applications scalability and overall reliability.

Scala and Java have common runtime platform and most of feature of java are extended in scala.

Scala is compiled into Java Byte Code which is executed by the Java Virtual Machine (JVM). The scala command is similar to the java command, in that it executes your compiled Scala code.

Scala Program:

There are two ways to writing scala programming which are as follows:

  1. Interactive Mode Programming
  2. Script Mode Programming


Interactive Mode Programming:

Open command prompt and type “scala” , this return following

Type the below text to the right of the Scala prompt and press the Enter key:

This will produce the following result:

Script Mode Programming:

Create a scala file name as “ScalaProgram.scala” .



Followings are compile and run program steps:

  1. Open notepad and add the code as above.
  2. Save the file as: ScalaProgram.scala.
  3. Open a command prompt window and go o the directory where you saved the program file. Assume it is C:\>
  4. Type ‘scalac ScalaProgram.scala’ and press enter to compile your code. If there are no errors in your code the command prompt will take you to the next line.
  5. Above command will generate a few class files in the current directory. One of them will be called class. This is a bytecode which will run on Java Virtual Machine (JVM).
  6. Now, type ‘scala ScalaProgram’ to run your program.
  7. You will be able to see This is my first scala program printed on the window.

Leave a Reply

%d bloggers like this: