CSC/ECE 517 Fall 2014/ch1a 9 kn

From Expertiza_Wiki
Revision as of 17:50, 17 September 2014 by Vgarg2 (talk | contribs)
Jump to navigation Jump to search

Functional Programming Languages i.e Scala over Object Oriented Languages i.e Java

What is Functional Programming

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions. In functional programming, programs are executed by evaluating expressions, in contrast with imperative programming where programs are composed of statements which change global state when executed. Functional programming typically avoids using mutable state. Examples of functional Programming languages are:

  • Haskell
  • Scala
  • Erlang

What is Object-oriented Programming

Object-oriented programming (OOP) is a programming language model which is organized around objects rather than "actions" and data rather than logic. A program has always been thought as a logical function that takes input data, processes it and produces the output. Object oriented programming cares about the objects we want to manipulate rather than the logic required to manipulate them. Objects here are usually instances of classes which are used to design applications and computer programs. Object-oriented programming languages have a come a long way starting from Simula all the way to languages like JAVA, Ruby etc. Some of the key features of object oriented programming languages are:

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Reflection
  • Abstraction

Introduction to Scala

Scala is an acronym for “Scalable Language”. It is an object- functional programming and scripting language which fuses functional and object-oriented programming in a practical package. Scala is now being used in a rapidly increasing number of open source projects and companies. It provides the core infrastructure for sites such as Twitter, LinkedIn, Foursquare, Tumblr, and Klout.

Aspects of Scala

The major aspects of Scala are:

  • Object oriented

Scala is a pure-bred object-oriented language. Conceptually, every value is an object and every operation is a method-call. The language supports advanced component architectures through classes and traits. Many traditional design patterns in other languages are already natively supported in SCALA.

  • Functional

Even though its syntax is fairly conventional, Scala is also a full-blown functional language. Many of Scala's design decisions were inspired by criticism over the shortcomings of Java. Scala has full support for functional programming concepts such as currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.

  • Seamless Interoperability with Java

Scala source code is intended to be compiled to Java bytecode, so that the resulting executable code runs on a Java virtual machine. Java libraries may be used directly in Scala code, and vice versa.