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
TDC Porto Alegre 2019 - JS Funcional com Ramda
Search
Ana Luiza Portello
November 29, 2019
Programming
0
230
TDC Porto Alegre 2019 - JS Funcional com Ramda
Ana Luiza Portello
November 29, 2019
Tweet
Share
More Decks by Ana Luiza Portello
See All by Ana Luiza Portello
FRONTIN | Elas Programam - Programação Funcional no Front-end
anabastos
0
80
Workshop JSFP - SEMCOMP 2021
anabastos
0
250
Clojure é um Java melhor que Java - Codecon 2021
anabastos
0
140
Clojure 101 - Criciuma Dev
anabastos
0
300
TDC POA - GraphQL
anabastos
1
250
BackEndSP - GraphQL
anabastos
0
220
Git & Github - RLadies
anabastos
1
220
Programaria Summit - Performance FrontEnd
anabastos
1
210
Programaria Summit - Performance Front-end
anabastos
0
160
Other Decks in Programming
See All in Programming
AIコーディングの本質は“コード“ではなく“構造“だった / The essence of AI coding is not “code” but "structure
seike460
PRO
2
450
一緒に働きたくなるプログラマの思想 #QiitaConference
mu_zaru
82
21k
エンジニア向けCursor勉強会 @ SmartHR
yukisnow1823
3
12k
監視 やばい
syossan27
12
10k
Golangci-lint v2爆誕: 君たちはどうすべきか
logica0419
1
270
Cloudflare Workersで進めるリモートMCP活用
syumai
5
630
Носок на сок
bo0om
0
1.3k
オープンソースコントリビュート入門
_katsuma
0
130
リアーキテクチャの現場で向き合う 既存サービスの読み解きと設計判断
ymiyamu
0
120
KANNA Android の技術的課題と取り組み
watabee
1
520
プロダクトエンジニアのしごと 〜 受託 × 高難度を乗り越えるOptium開発 〜
algoartis
0
230
JAWS DAYS 2025 re_Cheers: WEB
komakichi
0
120
Featured
See All Featured
Designing for humans not robots
tammielis
253
25k
Done Done
chrislema
184
16k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Faster Mobile Websites
deanohume
307
31k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
570
BBQ
matthewcrist
88
9.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
Fireside Chat
paigeccino
37
3.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Transcript
JS FUNCIONAL COM RAMDA
Olar! Meu nome é Ana Bastos Sou engenheira de software
no Nubank e cientista da computação pela PUC-SP. 2 anabastos @naluhh @anapbastos
3
Apresentar uma nova forma de pensar em JS e uma
possível ferramenta utilitária.
Muito tempo atrás… Que na verdade não é tanto tempo
atrás assim...
IndexOf 2009(ES5)
ver se um elementos está dentro de uma lista 2009(ES5)
None
!!~arr.indexOf(x)
Includes 2016(ES7)
loops js
map filter reduce forEach every some find
ABSTRAÇÕES Provêm ferramental com melhor valor algorítmico que pode salvar
linhas de código, tempo e bugs além de deixar as coisas mais legíveis.
HELPERS
ES6 ES7 ES8 ES9 ??????
RAMDA LODASH/FP
Bibliotecas pensadas para tornar mais fácil o javascript funcional
JS vem aos poucos adotando elementos de linguagens funcionais
Partial Application Pipeline operator Pattern Matching Flatmap PROPOSALS
RAMDA É DIFERENTE
DAY 0
Te força implementar conceitos funcionais direito de forma bonita e
bem fundamentada
IMUTABILIDADE
Pequenas funções puras reusáveis com apenas uma responsabilidade
SÓ FUNÇÕES
None
• Lists(map, filter, reduce, contains, replace, passAll, crop, flatten, find)
• Maths(inc, add, mean, sum) • String(split, replace) • Logics(equals, cond, not) • Relations(intersection, clamp, gt, lt) • Functions(curry, pipe, compose, ifElse, etc)
PQ PODE SER UMA BOA IDEIA?
Evita caca(Pureza / Mutabilidade) É mais produtivo(reuso) Ajuda a ler
codigo Ajuda muito a testar Faz muito sentido no front-end
Lida com undefineds / nulls
doSomething(obj.prop)
None
None
O PULO DO GATO
CURRY
None
TODA FUNCAO UNÁRIA
TODAS AS FUNCÕES SÃO CURRIED
None
None
None
Aplica os parametros da esquerda pra direita quando você tem
eles
PROPOSAL PARTIAL APPLICATION https://github.com/tc39/proposal-partial-application
None
A ordem dos argumentos são para facilitar o dado a
ser operado mais na direita
None
Funções <= Dado =>
Cond(Pattern Matching) If () { If () { if() {
if() { } } } Else { If () { } } }
Cond(Pattern Matching)
Cond(Pattern Matching)
PATTERN MATCHING PROPOSAL https://github.com/tc39/proposal-pattern-matching
Como se modela coisas?
PIPES
PIPELINE OPERATOR PROPOSAL https://github.com/tc39/proposal-pipeline-operator
function 1 function 2 INPUT OUTPUT OUTPUT
None
Composed Function INPUT OUTPUT
[5, 5, 4, 6] Média com ponto de participação deve
ser maior ou igual a 5
None
POINT-FREE PROGRAMMING
None
None
PIPE COMPOSE
None
HOF (Recompose)
PIPEP / COMPOSEP
then(a) .then(b) .then(c) .then(d)
await a() await b() await c() await d()
None
BIBLIOTECA DO FUTURO DO JS
HIGHLIGHTS
Perguntei pra amigos meus o que eles usam e as
respostas foram bem diferentes
APLICAÇÃO PARCIAL EM TESTES
EVOLVE APPLYSPEC DIFFERENCE UNIQ PROP
LENSES(Lidar com estado) MEMOIZATION(Lidar com recursão)
None
WARNINGS / APRENDIZADOS
• Cuidado com o RamdaScript • Legibilidade do projeto •
Anti-OpenSource • Isole o RamdaFucks(ramdaUtils)
COOKBOOK
• Rambda - github.com/selfrefactor/rambda • Ramda-fantasy - github.com/ramda/ramda-fantasy • Ramda
React Redux Patterns - tommmyy.github.io/ramda-react-redux-patterns/ • Thinking Ramda - randycoulman.com/blog/2016/05/24/thinking-in-ramda-gett ing-started • Ramda - Derek Stavis(Pagar.me talks) • Hey Underscore, You’re doing it wrong - Brian Lonsdorf.
Obrigada! anabastos @naluhh @anapbastos 81 speakerdeck.com/anabastos