Scala

Scala is a general purpose programming language.
Supports both object oriented and functional programming style
Martin Odersky and his team started in 2001, publicly released in Jan, 2004 and few months later on .NET platform.
Everything in Scala is Object, doesn't have primitives, why?
Doesn't allow any mutable state.

Framework in Scala

  1. Play - for web development
  2. Akka - Actors based framework
  3. Scalding - For Map Reduce
  4. Spark - in memory processing

Why Scala?

Developers want more flexible language to improve their productivity, which leads to languages like Python, ruby etc.

Scala - Static Language
Scala REPL : Read - Evaluate - Print - Loop
Scala Shell, even though it appears as interpreter, all typed code is converted to Byte code and executed.

2 kinds of variable:

  1. immutable (val) (Read only)
  2. mutable (var) (RW)

lazy values are very useful for delaying costly initialization instruction. Lazy values don't give error on initialization.

lazy val file=scala.io.Source.fromFile("vikas").mkString

From A Java Developer's POV:

  1. HelloWorld

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

    Save this code and let's say the file name is "HelloWorld.scala"

To compile

scalac HelloWorld.scala

To Run the program

scala HelloWorld

  or 

  scala -classpath . HelloWorld

output:

Hello World

results matching ""

    No results matching ""