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
SwiftUI Viewの責務分離
elmetal
PRO
1
240
CI改善もDatadogとともに
taumu
0
120
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
200
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
210
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
840
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
250
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
2
370
負債になりにくいCSSをデザイナとつくるには?
fsubal
10
2.4k
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
160
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
130
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Fireside Chat
paigeccino
34
3.2k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
For a Future-Friendly Web
brad_frost
176
9.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
50k
The Invisible Side of Design
smashingmag
299
50k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Building Applications with DynamoDB
mza
93
6.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
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