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
250
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
870
O case da Plataformatec com o Elixir - Como uma empresa brasileira criou uma linguagem que é usada no mundo inteiro @ QCon SP 2018
plataformatec
1
210
GenStage and Flow by @josevalim at ElixirConf
plataformatec
17
2.7k
Elixir: Programação Funcional e Pragmática @ 2º Tech Day Curitiba
plataformatec
2
270
Elixir: Programação Funcional e Pragmática @ Encontro Locaweb 2016
plataformatec
4
260
What's ahead for Elixir: v1.2 and GenRouter
plataformatec
15
1.9k
Arquiteturas Comuns de Apps Rails @ RubyConf BR 2015
plataformatec
6
360
Pirâmide de testes, escrevendo testes com qualidade @ RubyConf 2015
plataformatec
10
2.2k
Dogmatismo e Desenvolvimento de Software @ Rubyconf BR 2014
plataformatec
6
840
Other Decks in Technology
See All in Technology
Creative UIs with Compose: DroidKaigi 2024
chrishorner
1
580
フルカイテン株式会社 採用資料
fullkaiten
0
32k
Jetpack Compose Modifier 徹底解説 / Jetpack Compose Modifier
wiroha
0
200
Road to Single Activity
yurihondo
2
240
どこよりも遅めなWinActor Ver.7.5.0 新機能紹介
tamai_63
0
210
LLVM/ASMを使った有限体の高速実装
herumi
0
120
忙しい人のためのLangGraph概要まとめ
__ymgc__
1
190
Google CloudのLLM活用の選択肢を広げるVertex AIのパートナーモデル
nayuts
0
130
ナレッジグラフとLLMの相互利用
koujikozaki
0
420
チームビルディングは"感性"で向き合おう / Team Building with Awareness
kohzas
0
260
自作Cコンパイラ 8時間の奮闘
soukouki
0
850
React Aria で実現する次世代のアクセシビリティ
ryo_manba
4
1.2k
Featured
See All Featured
Fireside Chat
paigeccino
31
2.9k
Six Lessons from altMBA
skipperchong
26
3.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Designing for humans not robots
tammielis
248
25k
Building Applications with DynamoDB
mza
90
6k
Side Projects
sachag
451
42k
Building a Scalable Design System with Sketch
lauravandoore
459
32k
The Pragmatic Product Professional
lauravandoore
31
6.2k
Navigating Team Friction
lara
183
13k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
166
48k
RailsConf 2023
tenderlove
28
810
Clear Off the Table
cherdarchuk
91
320k
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