Tuesday, May 28, 2013

First step into Scala Framework

I have been recently moved to a new project, which is using Scala Framework. It seems to be an new word to me first, when i heard about the framework which we are going to use. So i have started digging into deep, to understand the real usage of the framework. So here's my record so I don't forget in future what i have learnt and how i did it.

Scala is a Functional/Object-Oriented and scripting language that exectues on Java Virtual Machine (JVM) and is becoming popular now, especially with the JAVA developers. It cleans up what are often considered to have been poor design decisions in Java (e.g. type erasure, checked exceptions, the non-unified type system) and adds a number of other features designed to allow cleaner, more concise and more expressive code to be written.

You can download Scala from here. If you have downloaded the .msi file, just double click it, it will do everything for you, if you have downloaded the zip file, extract it and put it in a location, and set the environment variable SCALA_HOME point to the bin directory of the scala folder. Once you did the above, just go to the command prompt, and type scala, you will enter into the scala prompt as below.



Once you are in scala prompt just type 8 * 5, your screen should be like this, once you typed just press enter

scala> 8 * 5

it will return res0: Int = 40

res0 is result index 0, Int is the type of output, 40 is the result. Suppose if you want to use the output for further processing, you have to just say

scala> res0 * 2

It will return res1: Int = 80

res1 is result index 1, Int is the type of output, 80 is the result.

Nice one right, seems to that it limits the number of lines we need to code to get the result :)

In the coming weeks, you can see some more examples on Scala, as and then, when i learn new things on this.

Happy programming ...!!!


No comments:

Post a Comment