Thursday, 26 June 2014

My Favourite Functional Programming Language Scala , But Why ?

     Scala is developed by Martin Odersky, the father of modern java compiler and also introduced generics into the Java programming language.

The first reason is ,with scala you can mix together object orientation and functional programming.  Scala has a powerful type system and still keep elegant, concise code. The main difference between java and scala is, java is verbose but scala is succinct. It has advanced language features and rich java integration. 

What Is Functional Programming ?

     Functional programming is programming through the definition and composition of functions. In any FP, functions are first class citizens, you can pass functions just like normal variables to other functions, you can assign function to a variable, return function as a result from other function, and also you can define function inside other function. Object-oriented programming is programming through the definition and composition of objects. In scala, functions are objects. Programs can be constructed through both the definition and composition of objects or functions.This gives Scala the ability to focus on nouns and verbs in a program, depending on what is the most prominent.

Scala also blends expressive syntax with static typing. code written in scala can look as expressive as dynamically typed languages, like Ruby, while retaining type safety.

Finally, Scala offers a lot of advanced language features that are not available in Java. But Scala runs on the Java virtual machine (JVM) and has tight integration with the Java language. This means that developers can make direct use of existing java libraries and integrate Scala into their Java applications while gaining additional power of scala. This integration makes scala a practical choice for any JVM - based project. 

Multi Threading became simple with scala on Multi core processors :

    Writing mutli threaded applications was already hard. On a single processor multi threading is more like multi taksing. Java did something wonderful, with its own "right once run any where" concept. The beauty of this is we were able to use consistent set of APIs across these different platforms and that was great. But everything is set and done, what we have on our hand is fairly low level abstraction.  

When we are dealing with objects, we have to deal with thread safety and concurrency. Finally what i feel is , if you want to develop multi threaded applications in java, you have to be god, don't worry i am not the one. This becomes even uglier in multi core processors. In order to handle Object security and availability to Multiple threads , we need to have higher level abstractions. In Scala, you can achieve this with Actors, and reactive based programming. 

Some More Features Of Scala :
  1. Scala is child of Ruby and Java languages.
  2. It is light, concise & readable like Ruby.
  3. All the Scala source files compiles to class files that run on JVM.
  4. Statically typed language.
  5. Uses Actors model to simplify concurrent programming. 
  6. Scala is used to power the busiest websites in the world including Twitter, Netfix, tumbler, LinkedIn, Foursquare, & many more.
Scala comes from the word Scalable.

Nuggets About Scala:
  1. Scala is a pure object oriented programming & Every variable is Object, & Every operator is a method. 
  2. It is also a functional programming language, so you can pass functions around as variables as described above, You can write code using Object Oriented Programming and Functional Programming or Both.
  3. Scala code runs on the JVM and lets you use the wealth of java libraries that have bee developed over the years. 
  4. Scala has its own command line interpreter to execute code snippets called REPL (Read, Evaluate, Print, Loop).
Mention in comments section, if you have some more reasons to like Scala.


Post a Comment

Note: only a member of this blog may post a comment.