SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
FUNCTIONAL GEEKERY
FOR AN IMPERATIVE MIND
Rajeev N B
@rshetty on Github
@rbharshetty on Twitter
SIMON PEYTON JONES
NIRVANA
C, C++, Java,
Ruby ..
Haskell
Nirvana
Useful
Less
Useful
Unsafe Safe
IMPERATIVE VS FUNCTIONAL
PROPERTY IMPERATIVE FUNCTIONAL
FOCUS
Changing existing
values
Declaring new values
CONTROL FLOW
Loops, Conditionals
and Function calls
Functional calls
including Recursion
MANIPULATION
UNIT
Instances of classes
and structs
Functions and Data
Structures.
MENTAL MODEL
Algorithmic
Programming
Composing problems
with set of functions.
FUNCTIONAL PROGRAMMING?
– John Hughes
(Why Functional Programming Matters)
“Functional Programming is so called because a
program consists entirely of functions”
CONCEPTS
FUNCTION COMPOSITION
(F O G)
It is the act of pipelining result of a
function into input of another,
creating a new function
Function g(x)
x + 1
Function f(x)
x * x
x = 3
g(x)= 4
f(g(x))= 16
It is the act of pipelining result of a
function into input of with another,
creating a new function
LAZY EVALUATION
Evaluation of a expression is
deferred until the result is needed
by other computations
LAZY EVALUATION
Call by need
Infinite Data structures
Thunks
Performant
HIGHER ORDER FUNCTIONS
Functions which either take functions
as arguments or return functions as
return values
CURRYING
Transforming function that takes
multiple arguments into function that
takes single argument
PURE FUNCTION
Function that returns exactly the
same result every time it is called
with same set of arguments
Pure Function
f(x) =
Math.cos(x)
Pure Function ( No Side Effects )
x
f(x)
REFERENTIALTRANSPARENCY
Expression is referentially transparent if it can be replaced with
its value
Property of Pure functions
No side effects
Easier to reason about programs
WHY PURE FUNCTIONS?
Reproducible results
Memoization
Parallelization
IMMUTABILITY
Immutable object is an object whose
state cannot be modified after it is
created
IMMUTABLE DATA STRUCTURES
Data structure once created cannot be modified
Uses sophisticated structure sharing
WHY?
Concurrency
Security
FUNCTIONALTHINKING
REFERENCES
Haskell Wiki
LearnYou a Haskell
Ruby Function Composition
Resurgence of Functional Programming
Code samples
THANKS
QUESTIONS?

Weitere ähnliche Inhalte

Was ist angesagt?

Functional Swift
Functional SwiftFunctional Swift
Functional SwiftGeison Goes
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript FundamentalsSrdjan Strbanovic
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++Learn By Watch
 
CSEC Mathematics Review - Introduction To Functions & Relations
CSEC Mathematics Review - Introduction To Functions & RelationsCSEC Mathematics Review - Introduction To Functions & Relations
CSEC Mathematics Review - Introduction To Functions & RelationsKevin Small
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Omar Abdelhafith
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Ruby Functional Programming
Ruby Functional ProgrammingRuby Functional Programming
Ruby Functional ProgrammingGeison Goes
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Calvin Cheng
 
Functions in programming language
Functions in programming languageFunctions in programming language
Functions in programming languageSadhana Rai
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programmingKonrad Szydlo
 
Functional Programming In PHP I
Functional Programming In PHP IFunctional Programming In PHP I
Functional Programming In PHP IUmut IŞIK
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++Vraj Patel
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartChen Fisher
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programmingnewmedio
 

Was ist angesagt? (20)

Functional Swift
Functional SwiftFunctional Swift
Functional Swift
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript Fundamentals
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
 
CSEC Mathematics Review - Introduction To Functions & Relations
CSEC Mathematics Review - Introduction To Functions & RelationsCSEC Mathematics Review - Introduction To Functions & Relations
CSEC Mathematics Review - Introduction To Functions & Relations
 
JavaScript intro
JavaScript introJavaScript intro
JavaScript intro
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Ruby Functional Programming
Ruby Functional ProgrammingRuby Functional Programming
Ruby Functional Programming
 
Functional programming 101
Functional programming 101Functional programming 101
Functional programming 101
 
Functional programming java
Functional programming javaFunctional programming java
Functional programming java
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
 
Functions in programming language
Functions in programming languageFunctions in programming language
Functions in programming language
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
Functional Programming In PHP I
Functional Programming In PHP IFunctional Programming In PHP I
Functional Programming In PHP I
 
Why fp
Why fpWhy fp
Why fp
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programming
 

Ähnlich wie FunctionalGeekery-RubyConf

Python functional programming
Python functional programmingPython functional programming
Python functional programmingGeison Goes
 
PHP = PHunctional Programming
PHP = PHunctional ProgrammingPHP = PHunctional Programming
PHP = PHunctional ProgrammingLuis Atencio
 
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)Tech in Asia ID
 
introtofunctionalprogramming2-170301075633.pdf
introtofunctionalprogramming2-170301075633.pdfintrotofunctionalprogramming2-170301075633.pdf
introtofunctionalprogramming2-170301075633.pdfRodulfoGabrito
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in javaJason O'Regan
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppteShikshak
 
Dev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingDev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingSvetlin Nakov
 
FUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptxFUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptxSafnaSaff1
 
The Ring programming language version 1.10 book - Part 41 of 212
The Ring programming language version 1.10 book - Part 41 of 212The Ring programming language version 1.10 book - Part 41 of 212
The Ring programming language version 1.10 book - Part 41 of 212Mahmoud Samir Fayed
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScriptAung Baw
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingRichardWarburton
 
Functional Paradigm.pptx
Functional Paradigm.pptxFunctional Paradigm.pptx
Functional Paradigm.pptxFurretMaster
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in AngularMA Jiangfan
 
[2021] kotlin built-in higher-order functions
[2021] kotlin built-in higher-order functions[2021] kotlin built-in higher-order functions
[2021] kotlin built-in higher-order functionsWei-Shen Lu
 
Functional Objects in Ruby: new horizons – Valentine Ostakh
Functional Objects in Ruby: new horizons  – Valentine OstakhFunctional Objects in Ruby: new horizons  – Valentine Ostakh
Functional Objects in Ruby: new horizons – Valentine OstakhRuby Meditation
 

Ähnlich wie FunctionalGeekery-RubyConf (20)

Functional programming in python
Functional programming in pythonFunctional programming in python
Functional programming in python
 
Functional programming in python
Functional programming in pythonFunctional programming in python
Functional programming in python
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
 
PHP = PHunctional Programming
PHP = PHunctional ProgrammingPHP = PHunctional Programming
PHP = PHunctional Programming
 
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)
"Functional Programming in a Nutshell" by Adityo Pratomo (Froyo Framework)
 
introtofunctionalprogramming2-170301075633.pdf
introtofunctionalprogramming2-170301075633.pdfintrotofunctionalprogramming2-170301075633.pdf
introtofunctionalprogramming2-170301075633.pdf
 
Functional Go
Functional GoFunctional Go
Functional Go
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
Dev Concepts: Functional Programming
Dev Concepts: Functional ProgrammingDev Concepts: Functional Programming
Dev Concepts: Functional Programming
 
FUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptxFUNCTIONS IN R PROGRAMMING.pptx
FUNCTIONS IN R PROGRAMMING.pptx
 
The Ring programming language version 1.10 book - Part 41 of 212
The Ring programming language version 1.10 book - Part 41 of 212The Ring programming language version 1.10 book - Part 41 of 212
The Ring programming language version 1.10 book - Part 41 of 212
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
 
Functional Paradigm.pptx
Functional Paradigm.pptxFunctional Paradigm.pptx
Functional Paradigm.pptx
 
C function presentation
C function presentationC function presentation
C function presentation
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in Angular
 
Inroduction to r
Inroduction to rInroduction to r
Inroduction to r
 
[2021] kotlin built-in higher-order functions
[2021] kotlin built-in higher-order functions[2021] kotlin built-in higher-order functions
[2021] kotlin built-in higher-order functions
 
Functional Objects in Ruby: new horizons – Valentine Ostakh
Functional Objects in Ruby: new horizons  – Valentine OstakhFunctional Objects in Ruby: new horizons  – Valentine Ostakh
Functional Objects in Ruby: new horizons – Valentine Ostakh
 

Mehr von Rajeev Bharshetty

Mehr von Rajeev Bharshetty (6)

Production Ready Microservices at Scale
Production Ready Microservices at ScaleProduction Ready Microservices at Scale
Production Ready Microservices at Scale
 
Resiliency in Distributed Systems
Resiliency in Distributed SystemsResiliency in Distributed Systems
Resiliency in Distributed Systems
 
Redux - What is this fuss about ?
Redux - What is this fuss about ?Redux - What is this fuss about ?
Redux - What is this fuss about ?
 
Writing S.O.L.I.D Code
Writing S.O.L.I.D CodeWriting S.O.L.I.D Code
Writing S.O.L.I.D Code
 
SPDY
SPDY SPDY
SPDY
 
Queue
QueueQueue
Queue
 

FunctionalGeekery-RubyConf