$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Programação Funcional & Elixir
Search
Amanda
November 04, 2017
Technology
3
120
Programação Funcional & Elixir
Amanda
November 04, 2017
Tweet
Share
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
76
Aprendizados de um projeto Elixir OTP
amandasposito
4
580
SOLID - Dependency inversion principle
amandasposito
0
77
Como concorrência funciona em Elixir?
amandasposito
1
230
Ecto, você sabe o que é ?
amandasposito
4
240
Novidades no Rails 5
amandasposito
0
97
Rails Engines & RSpec
amandasposito
0
220
Elixir e Phoenix
amandasposito
3
570
Elixir em 5 minutos
amandasposito
1
92
Other Decks in Technology
See All in Technology
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
120
SSO方式とJumpアカウント方式の比較と設計方針
yuobayashi
7
680
2025年 開発生産「可能」性向上報告 サイロ解消からチームが能動性を獲得するまで/ 20251216 Naoki Takahashi
shift_evolve
PRO
1
150
寫了幾年 Code,然後呢?軟體工程師必須重新認識的 DevOps
cheng_wei_chen
1
1.4k
EM歴1年10ヶ月のぼくがぶち当たった苦悩とこれからへ向けて
maaaato
0
280
打 造 A I 驅 動 的 G i t H u b ⾃ 動 化 ⼯ 作 流 程
appleboy
0
340
【AWS re:Invent 2025速報】AIビルダー向けアップデートをまとめて解説!
minorun365
4
520
Sansanが実践する Platform EngineeringとSREの協創
sansantech
PRO
2
860
re:Inventで気になったサービスを10分でいけるところまでお話しします
yama3133
1
120
Database イノベーショントークを振り返る/reinvent-2025-database-innovation-talk-recap
emiki
0
180
regrowth_tokyo_2025_securityagent
hiashisan
0
240
意外とあった SQL Server 関連アップデート + Database Savings Plans
stknohg
PRO
0
320
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
2.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Designing for Performance
lara
610
69k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Site-Speed That Sticks
csswizardry
13
1k
How to Ace a Technical Interview
jacobian
280
24k
Transcript
Programação Funcional & Elixir
@amandasposito @amsposito @amandasposito
None
Falando um pouco de história
http://www.gotw.ca/publications/concurrency-ddj.htm
None
None
“Efficiency and performance optimization will get more, not less, important.”
“Applications will increasingly need to be concurrent if they want
to fully exploit continuing exponential CPU throughput gains.”
Por que isso afeta nossa aplicação?
None
Elixir criada por José Valim
Percebeu que as ferramentas que existiam não eram boas para
concorrência
None
Elixir roda em cima da maquina virtual do Erlang
Erlang é conhecido por rodar aplicações com latência baixa, distribuídas
ou tolerante a falhas
Escalabilidade Tolerância a falhas Compatível com Erlang Hot Code Swap
Linguagem Dinâmica Metaprogramação Polimorfismo Concorrência
Diferentes paradigmas
Paradigma Funcional
–Introduction to Functional Programming - Richard Bird Philip Wadler “Programming
in a functional language consists of building definitions and using the computer to evaluate expressions.”
Imutabilidade
Consistência de dados
Concorrência Capacidade de lidar com várias coisas ao mesmo tempo
https://blog.whatsapp.com/196/1-million-is-so-2011?
Vamos resolver um problema
None
None
switch = fn (bulb) -> ... end switch.(bulb)
defmodule LightBulb do def switch(human, bulb) do end end LightBulb.switch(bulb)
Pattern Matching
name = "Amanda"
Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h()
ENTER for help) iex(1)> name = "Amanda" "Amanda" iex(2)> "Amanda" = name "Amanda" iex(3)> "Amanda S" = name ** (MatchError) no match of right hand side value: "Amanda"
defmodule LightBulb do def switch(human = %Human{}, bulb = %Bulb{})
… end end
Function Arity
defmodule LightBulb do def switch(human, bulb) do ... end def
switch(_) do IO.puts "Precisamos de um humano e de uma escada." end end
Guards
defmodule LightBulb do def switch(human, bulb) when bulb.burned_out == true
do … end end
If and unless
defmodule LightBulb do def switch(human, bulb) when bulb.burned_out == true
do ladder = Ladder.get_average_height() if ladder.under do … end end end
Pipe Operator
new_bulb = Bulb.get_bulb() lader = Ladder.get_average_height() human = Human.climb(human, ladder)
human = Human.remove_bulb(human, bulb) human = Human.put_bulb(human, new_bulb)
Ladder.get_average_height() |> Human.climb(human) |> Human.remove_bulb(bulb) |> Human.put_bulb(new_bulb)
None
Recursão
numbers = 3; for(i = numbers; i > 0; i--)
{ console.log(i); }
None
defmodule NaturalNums do # Uma clausula para parar a recursão
def print(1), do: IO.puts(1) def print(n) do # Imprime o número" IO.puts(n) # Chama a si mesmo com um valor a menos print(n - 1) end end
iex(1)> NaturalNums.print(3) 3 2 1 :ok
None
None
https://www.codeschool.com/courses/try-elixir
https://www.dailydrip.com/topics/elixir https://github.com/dailydrip/firestorm
http://plataformatec.com.br/elixir-radar
None
Obrigada!
Referências • https://hipsters.tech/elixir-a-linguagem-hipster- hipsters-48/ • https://codewords.recurse.com/issues/one/an- introduction-to-functional-programming • http://theerlangelist.blogspot.com.br/2013/05/working- with-immutable-data.html