CSC/ECE 517 Fall 2013/ch1 1w25 avam: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Replaced content with "Hi, Coming soon!")
No edit summary
Line 1: Line 1:
Hi, Coming soon!
Hi, Coming soon!
==Features of Functional Programming==
===Pure Functions===
OOP has pure functions and expressions. A function is said to be purely functional if it has no side effects with regards to memory or I/O. As a result, purely functional functions and expressions can be used for code optimization.
Following are some of the aspects of having purely functional functions:
* A pure expression can be removed without having any effect on other expressions, if the result of the pure expression is not used.
* The compiler has the freedom to reorder or combine the evaluations of expressions in a program.
* When a pure function is called with parameters that cause no side-effects, then on calling the same function with the same parameters, the same result is returned. This enables programmers to utilize caching optimizations, viz. memorization.
* The order of two pure expressions can be reversed if there is no data dependency between them. These expressions can also be performed in parallel without any interference with each other’s functioning. This property is also referred to as being thread-safe.
Following aspects of block structure are viewed in OOP languages:-
*'''Locality''':- The major advantage of block structure is locality. This makes it possible to restrict the existence of an object and its description to the environment where it has meaning.
*'''Scope Rule''' :- These are following aspects of scope rules for names declared within an object:
**They only exist when the object exist. This is a consequence of locality.
**Access to global names and re-declaration of names.
**Access to names within a block from “outside” the block may be restricted. Like in Simula language.

Revision as of 16:52, 14 September 2013

Hi, Coming soon!

Features of Functional Programming

Pure Functions

OOP has pure functions and expressions. A function is said to be purely functional if it has no side effects with regards to memory or I/O. As a result, purely functional functions and expressions can be used for code optimization.

Following are some of the aspects of having purely functional functions:

  • A pure expression can be removed without having any effect on other expressions, if the result of the pure expression is not used.
  • The compiler has the freedom to reorder or combine the evaluations of expressions in a program.
  • When a pure function is called with parameters that cause no side-effects, then on calling the same function with the same parameters, the same result is returned. This enables programmers to utilize caching optimizations, viz. memorization.
  • The order of two pure expressions can be reversed if there is no data dependency between them. These expressions can also be performed in parallel without any interference with each other’s functioning. This property is also referred to as being thread-safe.


Following aspects of block structure are viewed in OOP languages:-

  • Locality:- The major advantage of block structure is locality. This makes it possible to restrict the existence of an object and its description to the environment where it has meaning.
  • Scope Rule :- These are following aspects of scope rules for names declared within an object:
    • They only exist when the object exist. This is a consequence of locality.
    • Access to global names and re-declaration of names.
    • Access to names within a block from “outside” the block may be restricted. Like in Simula language.