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

C:\>scalaWelcome toScala version2.9.0.1 scala>

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

scala> println("Welcome to scala programming!");

This will produce the following result:

Welcome to scala programming!

Script Mode Programming:

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

object ScalaProgram{

 /* This is my first scala program.   

* This will print 'This is my first scala program’ as the output   */ 

 def main(args:Array[String]){    

 println("This is my first scala program")}




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.

C:\> scalac ScalaProgram.scala

C:\> scala ScalaProgram

This is my first scala program

About Malti Yadav

An enthusiastic technologist , Scala developer, positive attitude and the desire to go extra mile .
This entry was posted in Scala. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s