Why Scala?



  1. Concurrency model is no more a nightmare(This concept is taken from Erlang - general purpose, concurrent, FP and garbage collected runtime system.)
    1. Same can be achieved in java with lot more code and pain.
    2. Actor concept is taken from Erlang
    3. Deadlock is handled in much better way
    4. Synchronization and shared variables are abstracted
  1. Mixins - No diamond problem
  2. Both FP + OOP - It's blend of both programming paradigms
  3. Scalable language - Goes with ideas of massive parallelism and Reactive programming( reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change)
  1. Implicits
    • Implicit conversions-Used for extending the closed class behaviour e.g. String class extension.
    • Implicit parameters
    • implicit variables
  1. Pattern matching and case classes
  1. Cost of development to delivering will go down when compared to java
  2. Combined features from different languages
  3. More type safe - You can avoid lot of errors with this. i.e. Statically typed
  4. Superset of java - borrows features from other languages
  5. REPL - Jshell is coming up in Java 10
  6. Lazy evaluation - available in java 8
  1. Immutability
    1. No side affects
    2. Execution speed up -
With immutable objects, success or failure based on mutability is forever resolved once the object is constructed. That means less checks in runtime and more optimization from compiler, which gives faster execution of your code as a result.
  1. 100% Thread-safety
  2. Cleaner code
  1. Traits - No diamond problem
  1. Monoid - Option class
  2. Programming in Bigdata makes it easy as Spark and Kafka are written in scala & flink is written using Scala and Java
  3. Have powerful collections when compared to Java e.g.?
  4. Clean and concise syntax
  5. less verbose
  6. Cross compatible with java
  7. Runs on JVM
  8. Expression Oriented Programming(EOP) language - if/else, try/catch/finally and match all returns the result

Statement - OOP style - doesn't return result & executed for side effects
expression - FP style - Always return result & No side effect at all.

Limitations of Scala:

  1. Speed is almost same as java, as scala compiles to Java byte code.
  2. Backward compatibility in scala is not available for all the releases.


Comments

Popular posts from this blog

Implicits @ brief