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
Anjana Sofia Vakil
April 24, 2016
Programming
890
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
290
First Steps into Functional Programming
vakila
7
2.5k
The Language of Programming
vakila
4
740
Recursion, Iteration, & JavaScript: A love story
vakila
1
490
From Big Band Web App to Serverless Bebop
vakila
0
560
Embracing Constraints
vakila
1
250
Programming across paradigms
vakila
1
780
Immutable data structures for functional JavaScript
vakila
7
1.9k
Functional Programming: What? Why? How?
vakila
1
340
Other Decks in Programming
See All in Programming
What We Talk About When We Talk About XP
m_seki
2
350
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
高専、大学編入、そして未踏へ〜プロダクト開発とキャリアの歩み - Technical College, University Transfer, and On to “Mitou” / My Journey in Product Development and Career
pkmiya
0
140
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
140
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.7k
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
360
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
830
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.3k
Hono + Inertia + React で LP を構築した話
oukayuka
2
210
リアルな遅延を測る仕様
kota_yata
1
140
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
670
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
730
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
570
Raft: Consensus for Rubyists
vanstee
141
7.7k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
290
Design in an AI World
tapps
1
300
Practical Orchestrator
shlominoach
191
12k
Un-Boring Meetings
codingconduct
0
410
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
460
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
WENDY [Excerpt]
tessaabrams
12
39k
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
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