Thursday, July 6, 2017

What is functional programming?

                                       Functional programming (FP)is one of the programming style like procedural or object oriented programming. It will follow Declarative programming paradigm in which, programming will be done using expressions instead of statements. Where as Imperative programming language uses statements(e.g C, Java). Below are the some of the functional programing concepts.
  • Pure functions
  • No Side effects
  • No shared state
  • No Mutating state
  • Function composition
Pure Functions: A pure function is a function which will return always same value for the same input. The result of a pure function is always depends on input values and its internal logic. Pure function will not read/write anything from outside of that function.  A pure function will eliminate side effects and maintains referential transparency. A pure function can be referential transparency if function call can be replaced with its result.  Below are some of the examples.
  • 'chandu'.length is always 6, so its pure function. And instead of 'chandu'.length, you can use 6 as well, so this is also a referential transparency.
  • Max(3,7) is always 7, so Max is a pure function
  • sqrt(9) is always 3, so its a pure function. 
No Side effects: As stated in pure functions, there will not be any out side change  due to a particular function call. Should avoid shared variables, global variables to eliminate side effects.

No Shared State: Shared state is sharing variable or object or memory location. In functional programming there will not be any shared variable or object. If shared state is there, it violates pure function definition as some other function may change shared object.  If we eliminate shared state, there wont be any change in the order of the function calls as well.

No Mutating state: A mutable object can be modifiable after its creation. In functional program, modification of an object is not allowed after its creation. So that there wont be any side effects. SO Immutability is the another feature of functional programming.

Function composition: Composition is a combination of two or more functions to make a new function. As stated earlier Functional programming is declarative language, so it uses expressions instead of statements. This function composition is very useful to make expressions using functions.

Functional programming languages are used mostly on mathematical calculations and pattern matching and AI. Haskell and Lisp are some of the FP languages. JavaScript and Python will follow some of the FP features.

Happy Learning!!                                                                                          References

Thursday, March 30, 2017

What is Apple file system(APFS)!!!


Apple announced its new file system called Apple File System(APFS) at WWDC2016. Lets see what are new features in APFS and why apple introduced this new file system.

Till now apple is using file HFS+(Hierarchal file system).  The problem with this file system is, it designed almost three decades back and it designed basing on the existing drives(HDD's, FlopDisks) on that time. Though HFS+ supports latest SSD, Flash drives, it is not efficient enough. To support all these, Apple introduced new file system called Apple File System. Below are the some of the key features of APFS.

  • To make single file system for all apple OS (macOS, iOS, watchOS and tvOS)
  • To support and take advantage of SDD and Flash memory disks
  • 64-bit support 
  • Encryption first
  • Space sharing- if partition the disk, this file system will automatically adjusts the memory if one partition has no space
  • Feel fast access by reducing the latency -  as SSD and flash disks wont have any spinning needle to read/write unlike HDD's.
  • Snap shot and clones - copying and moving files are quick
  • Less OS Space
This file system will be available from iOS 10.3, macOS 10.12.4. When users upgrades to 10.3 it version, it will automatically converts file system from existing HFS+ to new Apple File system. Though this conversion will not effect your data, its advised to take the back up before upgrading iOS 10.3 


Happy Upgrading!!!

Popular Posts