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 @ iMasters Intercon 2016
Search
Plataformatec
October 22, 2016
Technology
1
260
Elixir @ iMasters Intercon 2016
Elixir: a linguagem, sua concepção e a volta da computação funcional
-- George Guimarães
Plataformatec
October 22, 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
1k
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ QCon SP 2018
plataformatec
1
230
GenStage and Flow by @josevalim at ElixirConf
plataformatec
17
2.8k
Elixir: Programação Funcional e Pragmática @ 2º Tech Day Curitiba
plataformatec
2
300
Elixir: Programação Funcional e Pragmática @ Encontro Locaweb 2016
plataformatec
4
290
What's ahead for Elixir: v1.2 and GenRouter
plataformatec
15
2.1k
Arquiteturas Comuns de Apps Rails @ RubyConf BR 2015
plataformatec
6
380
Pirâmide de testes, escrevendo testes com qualidade @ RubyConf 2015
plataformatec
10
2.4k
Dogmatismo e Desenvolvimento de Software @ Rubyconf BR 2014
plataformatec
6
870
Other Decks in Technology
See All in Technology
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
770
TODAY 看世界(?) 是我們在看扣啦!
line_developers_tw
PRO
0
160
CI/CDとタスク共有で加速するVibe Coding
tnbe21
0
150
新卒3年目の後悔〜機械学習モデルジョブの運用を頑張った話〜
kameitomohiro
0
220
AIエージェントの継続的改善のためオブザーバビリティ
pharma_x_tech
6
1.1k
「実体」で築く共通認識: 開発現場のコミュニケーション最適化 / Let's Get on the Same Page with Concrete Artifacts: Optimization of Communication in dev teams
kazizi55
0
140
(非公式) AWS Summit Japan と 海浜幕張 の歩き方 2025年版
coosuke
PRO
1
230
Securing your Lambda 101
chillzprezi
0
270
Rubyで作る論理回路シミュレータの設計の話 - Kashiwa.rb #12
kozy4324
1
290
OpenTelemetry Collector internals
ymotongpoo
5
530
SFTPコンテナからファイルをダウンロードする
dip
0
180
Whats_new_in_Podman_and_CRI-O_2025-06
orimanabu
3
180
Featured
See All Featured
Site-Speed That Sticks
csswizardry
10
630
Thoughts on Productivity
jonyablonski
69
4.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
Raft: Consensus for Rubyists
vanstee
139
7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
52
2.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
690
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
GitHub's CSS Performance
jonrohan
1031
460k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Practical Orchestrator
shlominoach
188
11k
Transcript
@georgeguimaraes / @plataformatec ELIXIR. PROGRAMAÇÃO FUNCIONAL E PRAGMÁTICA
GEORGE GUIMARÃES
consulting and software engineering
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.
30 anos
Switch Switch
Switch Browser Endpoint Server
— ELIXIR DEVELOPER “We stand in the shoulders of giants”
DOCUMENTAÇÃO DE ALTO NÍVEL. Documentação ruim é bug.
None
FERRAMENTAL EMBUTIDO. Hex, Mix, ExUnit.
None
None
LINGUAGEM FUNCIONAL. Não temos classes nem objetos.
IMUTABILIDADE. “Isso muda tudo”
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
elixir
elixir
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
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.
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
USO EFICIENTE!. Usa todos os cores da máquina, não só
pra processar requests web, mas até pra rodar testes
None
None
None
None
None
MICROSERVIÇOS EM UM MUNDO ELIXIR. Precisamos sempre de APIs HTTP?
elixir
node@srv2 node@srv1 elixir
None
OUTRAS VANTAGENS. • Garbage Collector por processo • Latência previsível
• Separação de dados e comportamento (FP)
ONDE APRENDER?.
None
None
http://plataformatec.com.br/elixir-radar
https://elixirforum.com
OBRIGADO!! @plataformatec @georgeguimaraes
@elixirlang / elixir-lang.org