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
Programação Funcional & Elixir
Search
Amanda
November 04, 2017
Technology
3
130
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
94
Aprendizados de um projeto Elixir OTP
amandasposito
4
600
SOLID - Dependency inversion principle
amandasposito
0
86
Como concorrência funciona em Elixir?
amandasposito
1
230
Ecto, você sabe o que é ?
amandasposito
4
240
Novidades no Rails 5
amandasposito
0
100
Rails Engines & RSpec
amandasposito
0
230
Elixir e Phoenix
amandasposito
3
580
Elixir em 5 minutos
amandasposito
1
97
Other Decks in Technology
See All in Technology
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
94k
生成AI素人でも玄人でもない私がセイセイAIチョットワカルために勉強したこと
wkm2
2
280
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
340
コンテナセキュリティの最新事情 ~ 2026年版 ~
kyohmizu
8
3k
22nd ACRi Webinar - 1Finity Tamura-san's slide
nao_sumikawa
0
130
横断SREがSRE社内留学制度 / Enablingになぜ踏み切ったのか
rvirus0817
0
280
既存のログ監視システムをクラウドっぽく実装してみた
tjmtrhs
0
110
30分でわかる「ネットワーク図の描き方入門」/infraengbooks56
corestate55
1
340
【Claude Code】Plugins作成から始まったファインディの開発フロー改革
starfish719
0
250
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
74k
Exadata Fleet Update
oracle4engineer
PRO
0
1.2k
Claude Code で画面の仕様書を作ろう
zozotech
PRO
0
300
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Prompt Engineering for Job Search
mfonobong
0
170
Designing for humans not robots
tammielis
254
26k
Building an army of robots
kneath
306
46k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Are puppies a ranking factor?
jonoalderson
1
3k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
First, design no harm
axbom
PRO
2
1.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
The Cult of Friendly URLs
andyhume
79
6.8k
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