Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Functional Geekery for an Imperative Mind
Search
Rajeev Bharshetty
April 04, 2015
Programming
0
280
Functional Geekery for an Imperative Mind
Slides for the talk at RubyConf India 2015
Rajeev Bharshetty
April 04, 2015
Tweet
Share
More Decks by Rajeev Bharshetty
See All by Rajeev Bharshetty
SPDY : Let's Make the Web Faster
rshetty01
2
180
Other Decks in Programming
See All in Programming
オープンソースソフトウェアへの解像度🔬
utam0k
16
3k
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1k
Devoxx BE - Local Development in the AI Era
kdubois
0
130
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
180
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
560
株式会社 Sun terras カンパニーデック
sunterras
0
360
Software Architecture
hschwentner
6
2.3k
CSC305 Lecture 06
javiergs
PRO
0
250
Le côté obscur des IA génératives
pascallemerrer
0
150
Swift Concurrency - 状態監視の罠
objectiveaudio
2
550
Devoxx BE 2025 Loom lab
josepaumard
0
100
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
230
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Side Projects
sachag
455
43k
A better future with KSS
kneath
239
18k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
We Have a Design System, Now What?
morganepeng
53
7.8k
Into the Great Unknown - MozCon
thekraken
40
2.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
470
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
Transcript
FUNCTIONAL GEEKERY FOR AN IMPERATIVE MIND Rajeev N B
@rshetty on Github @rbharshetty on Twitter
None
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
None
None
It is the act of pipelining result of a function
into input of with another, creating a new function
None
None
None
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
None
None
CURRYING
Transforming function that takes multiple arguments into function that takes
single argument
None
None
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)
None
REFERENTIAL TRANSPARENCY 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
FUNCTIONAL THINKING
REFERENCES Haskell Wiki Learn You a Haskell Ruby Function Composition
Resurgence of Functional Programming Code samples
THANKS
QUESTIONS?