Introduction to Scala
What is Scala ?
Scalable Language.
A Multipurpose programming language that can be used to write any code ranging from Scripts to Big sized libraries.
Introduced in 2003 by Martin Odersky.
Why Scala ?
Scala is hard to learn, but it is worth the investment.
1) Features like - Tuples, Functions, Macros etc make it easier for the developer to write better code.
2) Increased performance.
3) Scala is a type-safe JVM language.
4) Supports object oriented and functional programming.
5) Scala is concise, logical, and extraordinarily powerful language.
6) Scala is high level. (Abstraction makes user's life easier.)
Major Applications :
Apache Spark, Apache Kafka, Publish-subscribe message queue used in Spark.
What is Functional Programming Language ?
A Programming paradigm. It is a style of building the structure and elements of computer programs.
Each computation is treated as the evaluation of mathematical functions which :
1) Does not allow “Changing States” double badSqr(double x) {
double r = x * x;
if (System.currentTimeMillis() % 42L == 0L) return r;
return r + 0.000000001; }
2) Does not have “Mutable Data”
int a = 0;
...
...
a = 2; //a is mutable here.