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
Elixir: Programação Funcional e Pragmática @ 2º...
Search
Plataformatec
August 20, 2016
Programming
2
290
Elixir: Programação Funcional e Pragmática @ 2º Tech Day Curitiba
Plataformatec
August 20, 2016
Tweet
Share
More Decks by Plataformatec
See All by Plataformatec
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ Elixir Brasil 2019
plataformatec
5
980
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ QCon SP 2018
plataformatec
1
220
Elixir @ iMasters Intercon 2016
plataformatec
1
260
GenStage and Flow by @josevalim at ElixirConf
plataformatec
17
2.7k
Elixir: Programação Funcional e Pragmática @ Encontro Locaweb 2016
plataformatec
4
280
What's ahead for Elixir: v1.2 and GenRouter
plataformatec
15
2k
Arquiteturas Comuns de Apps Rails @ RubyConf BR 2015
plataformatec
6
370
Pirâmide de testes, escrevendo testes com qualidade @ RubyConf 2015
plataformatec
10
2.3k
Dogmatismo e Desenvolvimento de Software @ Rubyconf BR 2014
plataformatec
6
850
Other Decks in Programming
See All in Programming
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
860
Djangoにおける複数ユーザー種別認証の設計アプローチ@DjangoCongress JP 2025
delhi09
PRO
4
460
Datadog Workflow Automation で圧倒的価値提供
showwin
1
160
Jakarta EE meets AI
ivargrimstad
0
370
CloudNativePGを布教したい
nnaka2992
0
110
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
960
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
120
Introduction to kotlinx.rpc
arawn
0
760
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.2k
2025.2.14_Developers Summit 2025_登壇資料
0101unite
0
180
負債になりにくいCSSをデザイナとつくるには?
fsubal
10
2.6k
もう僕は OpenAPI を書きたくない
sgash708
5
1.9k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
51
7.4k
Side Projects
sachag
452
42k
Faster Mobile Websites
deanohume
306
31k
Producing Creativity
orderedlist
PRO
344
40k
It's Worth the Effort
3n
184
28k
What's in a price? How to price your products and services
michaelherold
244
12k
The Pragmatic Product Professional
lauravandoore
32
6.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
A Tale of Four Properties
chriscoyier
158
23k
Site-Speed That Sticks
csswizardry
4
410
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
GitHub's CSS Performance
jonrohan
1030
460k
Transcript
@georgeguimaraes / @plataformatec ELIXIR. PROGRAMAÇÃO FUNCIONAL E PRAGMÁTICA
GEORGE GUIMARÃES
consulting and software engineering
POLÊMICAS. QUEM NUNCA?
MICROSERVIÇOS != HTTP API REST.
INTEGRAÇÃO CONTÍNUA. Provavelmente vc não faz e provavelmente não deveria
estar fazendo mesmo.
MONOREPO. Repo consistente com a organização
None
None
NOSSA GERAÇÃO TEM UM PROBLEMA. Desenvolvedores web tem que lidar
com concorrência. Não há escapatória.
CONCORRÊNCIA. Capacidade de lidar com várias coisas (ao mesmo tempo,
ou serialmente).
PARALELISMO. Capacidade de fazer várias coisas ao mesmo tempo.
CONCORRÊNCIA. Websockets, HTTP2, Alta quantidade de requests, demanda instável.
None
None
THREADS E EVENT LOOP. Modelos primitivos para lidar com concorrência.
“what makes multithreaded programming difficult is not that writing it
is hard, but that testing it is hard. It’s not the pitfalls that you can fall into; it’s the fact that you don’t necessarily know whether you’ve fallen into one of them. ”
None
— ROBERT VIRDING “Any sufficiently complicated concurrent program in another
language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.”
PLATAFORMA ELIXIR. Erlang and OTP, now with modern tooling.
None
30 anos
None
None
Switch
Switch
Switch
Switch
Switch Switch
Switch Browser Endpoint Server
— ELIXIR DEVELOPER “We stand in the shoulders of giants”
# #MYELIXIRSTATUS
DOCUMENTAÇÃO DE ALTO NÍVEL. Documentação ruim é bug.
None
FERRAMENTAL EMBUTIDO. Hex, Mix, ExUnit.
None
None
LINGUAGEM FUNCIONAL.
IMUTABILIDADE. “Isso muda tudo”
user = %{name: "George", interests: ["Elixir", "Ruby", "Integração Discreta"]} Suggest.to_user(user)
Analytics.save_interests(user.interests) user # => %{name: "George", interests: ["Elixir", "Ruby", "Integração Discreta"]}
NÃO TENHO LOOPS!
defmodule Fibonacci do def calc(0), do: 0 def calc(1), do:
1 def calc(n), do: calc(n-1) + calc(n-2) end Fibonacci.calc(10) # => 55
MAS, E COMO FAZER UM CONTADOR? Não é possível mudar
o conteúdo de uma variável????
defmodule Counter do def start(value) do receive do :increment ->
start(value + 1) {:get, pid} -> send(pid, value) end end end
defmodule Counter do def start(value) do receive do :increment ->
start(value + 1) {:get, caller} -> send(caller, value) end end end pid = spawn(fn -> Counter.start(10) end) send(pid, :increment) send(pid, :increment) send(pid, :increment) send(pid, {:get, self}) flush # => 13
shell
shell Counter.start(10) spawn
shell 11 increment
shell 12 increment
shell 13 increment
shell 13 :get, self 13
defmodule Counter do def start(value) do receive do :increment ->
start(value + 1) {:get, caller} -> send(caller, value) end end end pid = spawn(fn -> Counter.start(10) end) send(pid, :increment) send(pid, :increment) send(pid, :increment) send(pid, {:get, self}) flush # => 13
ACTOR MODEL. 1. Enviar mensagens para outros atores; 2. Criar
novos atores; 3. Especificar o comportamento para as próximas mensagens.
Sequential code
Sequential code elixir
Sequential code elixir
elixir
elixir
None
None
FAULT-TOLERANT. DISTRIBUTED. O objetivo não era concorrência.
Switch Switch
CONCORRÊNCIA É UM CASO DE DISTRIBUIÇÃO. Tá distribuído, mas apenas
em uma máquina.
elixir
elixir
elixir
defmodule MyApp do use Application def start(_type, _args) do import
Supervisor.Spec, warn: false children = [ supervisor(Playfair.Repo, []), worker(Playfair.Mailer, []), worker(Playfair.FileWriter, []), ] opts = [strategy: :one_for_one, name: Playfair.Supervisor] Supervisor.start_link(children, opts) end end
None
ERROS ACONTECEM. Let it crash.
ESTADO CORRUPTO PODE OCORRER. Let it crash. O processo vai
voltar com um estado limpo.
MAS SERÁ QUE FUNCIONA MESMO?
http://blog.whatsapp.com/index.php/ 2012/01/1-million-is-so-2011/ 2 million connections on a single node
Intel Xeon CPU X5675 @ 3.07GHz 24 CPU - 96GB
Using 40% of CPU and Memory
None
None
None
None
None
MICROSERVIÇOS EM UM MUNDO ELIXIR. Precisamos sempre de APIs HTTP?
elixir
node@srv2 node@srv1 elixir
None
None
ONDE APRENDER?.
None
None
None
None
OBRIGADO!! @plataformatec @georgeguimaraes
@elixirlang / elixir-lang.org