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
250
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
95
Workshop JSFP - SEMCOMP 2021
anabastos
0
280
Clojure é um Java melhor que Java - Codecon 2021
anabastos
0
150
Clojure 101 - Criciuma Dev
anabastos
0
320
TDC POA - GraphQL
anabastos
1
270
BackEndSP - GraphQL
anabastos
0
230
Git & Github - RLadies
anabastos
1
240
Programaria Summit - Performance FrontEnd
anabastos
1
220
Programaria Summit - Performance Front-end
anabastos
0
170
Other Decks in Programming
See All in Programming
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
140
dynamic!
moro
9
6.5k
Local Peer-to-Peer APIはどのように使われていくのか?
hal_spidernight
2
450
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
180
プログラミングどうやる? ~テスト駆動開発から学ぶ達人の型~
a_okui
0
190
AIで開発生産性を上げる個人とチームの取り組み
taniigo
0
130
CSC509 Lecture 06
javiergs
PRO
0
240
『毎日の移動』を支えるGoバックエンド内製開発
yutautsugi
2
180
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
180
iOS 17で追加されたSubscriptionStoreView を利用して5分でサブスク実装チャレンジ
natmark
0
580
CSC509 Lecture 05
javiergs
PRO
0
290
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
190
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
Unsuck your backbone
ammeep
671
58k
We Have a Design System, Now What?
morganepeng
53
7.8k
GraphQLとの向き合い方2022年版
quramy
49
14k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
GitHub's CSS Performance
jonrohan
1032
460k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
20k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
237
140k
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