Sunday, December 25, 2016

What is Node.js?




  • Event-driven, non-blocking I/O model that makes it lightweight and efficient
  • Uses google's  Chrome's V8 JavaScript engine 
  • JavaScript which runs on your computer
  • Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world

Declarative vs imperative programming




Declarative :
  • Write code what you want but not  necessarily how to get it (Declare the desired results but not the step-by-step)
  • A style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow.
  • Minimize or eliminate the side effects by describing what program should accomplish 
  • How is left to the problem implementation
  • Only thing a function can do is calculate something and return it as a result.

   Declarative languages include, SQL, React, Functional programming like haskell

Functional Prgramming

  •  In purely functional programming you don't tell the computer what to do as such but rather you tell it what stuff is
  • if a function is called twice with the same parameters, it's guaranteed to return the same result. That's called referential transparency and not only does it allow the compiler to reason about the program's behavior, but it also allows you to easily deduce (and even prove) that a function is correct and then build more complex functions by gluing simple functions together


var results = collection.Where( num => num % 2 != 0);
Imperative :

  • Tell the compiler what you want to happen step by step
  • Java, C, C#  is imperative
  • Main method of computation is assignment variable
  • Implements algorithms in explicit steps.