SlideShare a Scribd company logo
Siddharth Singh
Topics
 Why SPARK
 Evolvement of PIG
 Why PIG
 PIG vs Map reduce
 PIG vs SQL
 Processing Flow
 Data Model
 Execution modes
 Properties of PIG
 Practice Sessions
What is SCALA
 It was created by Martin Odersky and it was first released in 2003.
 Scala, short for Scalable Language is a component software with a focus is on
abstraction, composition, and decomposition and not on primitives.
 It unifies OOP and functional programming
 Runs on the JVM
 Can use any Java code in Scala
 Almost as fast as Java
 Much shorter code
 Odersky reports 50% reduction in most code over Java
 Local type inference
 Fewer errors
 No Null Pointer problems
 More flexibility
 As many public classes per source file as you want
 Operator overloading
Features of SCALA
 Scala is object-oriented language
 Scala is a pure object-oriented language in the sense that every value is an
object. Types and behavior of objects are described by classes.
 Scala is also a functional language in the sense that every function is a value
and because every value is an object so ultimately every function is an
object.
 Scala provides a lightweight syntax for defining anonymous functions, it
supports higher-order functions, it allows functions to be nested.
 Scala runs on the JVM.
Features of SCALA
 Scala is compiled into Java Byte Code which is executed by the Java Virtual
Machine (JVM). This means that Scala and Java have a common runtime
platform. You can easily move from Java to Scala.
 Scala is statically typed which supports type inference.
 You don't have to specify a type in most cases, and you certainly don't have
to repeat it.
 Scala can Execute Java Code
 SCALA supports REPL (Run Evaluate Print Loop) programming and you can
SCALA commands using interactively using the shell. This is the best feature
of SCALA which differentiate it from other languages and this feature is used
for quick BIG data analysis.
Run Examples
Run few examples in SCALA REPL to understand it better,
1
1+2
1+1+”Hello”
“Hello”+1+1
List (1,2,3)
Println (“Hello World”)
Val and Var – Val is immutable and Var is mutable.
Try more examples on REPL
It looks like interpreter but its compiling the code fast and converting in
bytecodeand giving the result.
Run Examples
Variable Declaration
Scala has the different syntax for the declaration of variables and they can be defined as value,
i.e., constant or a variable. Following is the syntax to define a variable using var keyword:
var myVar : String = "Foo“
If you do not assign any initial value to a variable, then it is valid as follows:
var myVar :Int;
val myVal :String;
Variable Type Inference
When you assign an initial value to a variable, the Scala compiler can figure out the type of the
variable based on the value assigned to it. This is called variable type inference. Therefore, you
could write these variable declarations like this:
var myVar = 10;
val myVal = "Hello, Scala!";
Run Examples
Multiple assignments
Scala supports multiple assignments. If a code block or method returns a Tuple,
the Tuple can be assigned to a val variable.
val (myVar1: Int, myVar2: String) = Pair(40, "Foo")
And the type inference gets it right:
val (myVar1, myVar2) = Pair(40, "Foo")
Data Types & operators
Scala has all the same data types as Java like int, long, float, double, String etc so we
would not study about data types.
Scala has all the same operators as Java like arithmetic, relational, logical, bitwise,
assignments we would not study about data types.

More Related Content

Learn scala and it's componenents learn it

  • 2. Topics  Why SPARK  Evolvement of PIG  Why PIG  PIG vs Map reduce  PIG vs SQL  Processing Flow  Data Model  Execution modes  Properties of PIG  Practice Sessions
  • 3. What is SCALA  It was created by Martin Odersky and it was first released in 2003.  Scala, short for Scalable Language is a component software with a focus is on abstraction, composition, and decomposition and not on primitives.  It unifies OOP and functional programming  Runs on the JVM  Can use any Java code in Scala  Almost as fast as Java  Much shorter code  Odersky reports 50% reduction in most code over Java  Local type inference  Fewer errors  No Null Pointer problems  More flexibility  As many public classes per source file as you want  Operator overloading
  • 4. Features of SCALA  Scala is object-oriented language  Scala is a pure object-oriented language in the sense that every value is an object. Types and behavior of objects are described by classes.  Scala is also a functional language in the sense that every function is a value and because every value is an object so ultimately every function is an object.  Scala provides a lightweight syntax for defining anonymous functions, it supports higher-order functions, it allows functions to be nested.  Scala runs on the JVM.
  • 5. Features of SCALA  Scala is compiled into Java Byte Code which is executed by the Java Virtual Machine (JVM). This means that Scala and Java have a common runtime platform. You can easily move from Java to Scala.  Scala is statically typed which supports type inference.  You don't have to specify a type in most cases, and you certainly don't have to repeat it.  Scala can Execute Java Code  SCALA supports REPL (Run Evaluate Print Loop) programming and you can SCALA commands using interactively using the shell. This is the best feature of SCALA which differentiate it from other languages and this feature is used for quick BIG data analysis.
  • 6. Run Examples Run few examples in SCALA REPL to understand it better, 1 1+2 1+1+”Hello” “Hello”+1+1 List (1,2,3) Println (“Hello World”) Val and Var – Val is immutable and Var is mutable. Try more examples on REPL It looks like interpreter but its compiling the code fast and converting in bytecodeand giving the result.
  • 7. Run Examples Variable Declaration Scala has the different syntax for the declaration of variables and they can be defined as value, i.e., constant or a variable. Following is the syntax to define a variable using var keyword: var myVar : String = "Foo“ If you do not assign any initial value to a variable, then it is valid as follows: var myVar :Int; val myVal :String; Variable Type Inference When you assign an initial value to a variable, the Scala compiler can figure out the type of the variable based on the value assigned to it. This is called variable type inference. Therefore, you could write these variable declarations like this: var myVar = 10; val myVal = "Hello, Scala!";
  • 8. Run Examples Multiple assignments Scala supports multiple assignments. If a code block or method returns a Tuple, the Tuple can be assigned to a val variable. val (myVar1: Int, myVar2: String) = Pair(40, "Foo") And the type inference gets it right: val (myVar1, myVar2) = Pair(40, "Foo")
  • 9. Data Types & operators Scala has all the same data types as Java like int, long, float, double, String etc so we would not study about data types. Scala has all the same operators as Java like arithmetic, relational, logical, bitwise, assignments we would not study about data types.