Successfully reported this slideshow.
Upcoming SlideShare
×

Functional programing jargon

363 views

Published on

Introduction to the functional programing jargon with JavaScript examples

Published in: Software
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Functional programing jargon

1. 1. Functional Programming Jargon A DublinJS lighting talk by Remo H. Jansen
2. 2. The functional programming jargon is “scary”! ● Function arity ● Pure functions ● Referential transparency ● Side effects ● Partial application ● Currying ● Function Composition ● Lazy evaluation
3. 3. Fear not my friends! ● Encapsulation ● Class ● Property ● Method ● Object ● Inheritance ● Polymorphism Do you remember how you felt the first time you encountered the Object-oriented jargon?
4. 4. Pure Functions Purity (AKA referential transparency) means “every time you pass the same inputs, you always get the same outputs”. A pure function is free of side effects. A side effect refers simply to the modification of some kind of state. Any operation which modifies the state of the computer or which interacts with the outside world is said to have a side effect.
5. 5. Immutability An immutable object is an object whose state cannot be modified after it is created. In JavaScript objects are not immutable and our pure functions should avoid mutating its arguments (side effect). We can achieve this by using a library like immutable.js and avoiding the JavaScript mutator methods!
6. 6. Function Partial Application Partial application is the process of fixing a number of arguments to a function, producing another function of smaller arity. Arity refers to the number of arguments a function can accept. This might be none, one (unary), two (binary) or more (polyadic). You can also have functions that take a variable number of arguments, (variadic functions).
7. 7. Currying Currying is the process of taking a function that accepts N arguments and turning it into a chained series of N functions each taking 1 argument.
8. 8. Function Composition The act or mechanism of combining simple functions to build more complicated ones. Unary functions are easier to compose. Currying helps us to perform function composition. Functional programming manages complexity via composition as opposed to data encapsulation.
9. 9. How to learn more? Books: ● Functional Programming in JavaScript by Dan Mantyla ● Functional Programming in JavaScript by Luis Atencio ● Reactive Programming with RxJS by Sergi Mansilla Libraries: ● React & Redux ● Ramda ● RxJS ● Immutable ● Cycle
10. 10. Questions?
11. 11. Thanks!