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
Learning Functional Programming with JavaScript
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Anjana Sofia Vakil
April 24, 2016
Programming
870
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Learning Functional Programming with JavaScript
Given at JSUnconf 2016 (
http://2016.jsunconf.eu/
)
Anjana Sofia Vakil
April 24, 2016
More Decks by Anjana Sofia Vakil
See All by Anjana Sofia Vakil
The Art of Functional Programming
vakila
0
270
First Steps into Functional Programming
vakila
7
2.5k
The Language of Programming
vakila
4
730
Recursion, Iteration, & JavaScript: A love story
vakila
1
480
From Big Band Web App to Serverless Bebop
vakila
0
540
Embracing Constraints
vakila
1
240
Programming across paradigms
vakila
1
770
Immutable data structures for functional JavaScript
vakila
7
1.8k
Functional Programming: What? Why? How?
vakila
1
330
Other Decks in Programming
See All in Programming
AIで効率化できた業務・日常
ochtum
0
150
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
790
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
160
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
590
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
140
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
The NotImplementedError Problem in Ruby
koic
1
940
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
390
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
490
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
The Spectacular Lies of Maps
axbom
PRO
1
820
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
sira's awesome portfolio website redesign presentation
elsirapls
0
280
Paper Plane (Part 1)
katiecoart
PRO
0
9.2k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
55k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
450
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
400
Transcript
Learning Functional Programming with JS @AnjanaVakil
The Recurse Center https://www.recurse.com/
What is functional programming?
What is functional programming? a programming paradigm
What is functional programming? a coding style
What is functional programming? a mindset
What is functional programming? a sexy, buzz-wordy trend
Why functional JavaScript?
Why functional JavaScript? object-oriented JS gets tricky (prototypes? this?!?)
Why functional JavaScript? safer, easier to debug/maintain
Why functional JavaScript? established community
OK, let’s do it!
OK, let’s do it! ...how?
Do everything with functions input -> output
Not functional: var name = “Anjana”; var greeting = “Hi,
I’m ”; console.log(greeting + name); => “Hi, I’m Anjana”
Functional: function greet(name) { return “Hi, I’m ” + name;
} greet(“Anjana”); => “Hi, I’m Anjana”
Avoid side effects use “pure” functions
Not pure: var name = “Anjana”; function greet() { console.log(“Hi,
I’m ” + name); }
Pure: function greet(name) { return “Hi, I’m ” + name;
}
Use higher-order functions functions can be inputs/outputs
function makeAdjectifier(adjective) { return function (string) { return adjective +
“ ” + string; }; } var coolifier = makeAdjectifier(“cool”); coolifier(“conference”); => “cool conference”
Don’t iterate use map, reduce, filter
http://www.datasciencecentral.com/forum/topics/what-is-map-reduce
Avoid mutability use immutable data
Mutation (bad!): var rooms = [“H1”, “H2”, “H3”]; rooms[2] =
“H4”; rooms; => ["H1", "H2", "H4"]
No mutation (good!): var rooms = [“H1”, “H2”, “H3”]; Var
newRooms = rooms.map(function (rm) { if (rm == “H3”) { return “H4”; } else { return rm; } }); newRooms; => ["H1", "H2", "H4"] rooms; => ["H1", "H2", "H3"]
Persistent data structures for efficient immutability Mori, Immutable.js
Ready to try it out?
FP libraries for JS • Mori (http://swannodette.github.io/mori/) • Immutable.js (https://facebook.github.
io/immutable-js/) • Underscore (http://underscorejs.org/) • Lodash (https://lodash.com/) • Ramda (http://ramdajs.com/) • ...and more!
Want to learn more?
“An introduction to functional programming” by Mary Rose Cook https://codewords.recurse.com/issues/one/an-introduction-to-functional-programming
Thanks for listening! I’m @AnjanaVakil Huge thanks to: JSUnconf organizers
Diversity sponsors The Recurse Center & alums