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
790
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.6k
Elixir: Programação Funcional e Pragmática @ 2º Tech Day Curitiba
plataformatec
2
210
Elixir: Programação Funcional e Pragmática @ Encontro Locaweb 2016
plataformatec
4
230
What's ahead for Elixir: v1.2 and GenRouter
plataformatec
15
1.8k
Arquiteturas Comuns de Apps Rails @ RubyConf BR 2015
plataformatec
6
360
Pirâmide de testes, escrevendo testes com qualidade @ RubyConf 2015
plataformatec
10
2.1k
Dogmatismo e Desenvolvimento de Software @ Rubyconf BR 2014
plataformatec
6
840
Other Decks in Technology
See All in Technology
Azureの基本的な権限管理の勉強会
yhana
0
410
レガシーをぶっ壊せ。AEONで始めるDevRelの話 / Qiita Night 2024-2-22
aeonpeople
3
1.3k
20分で完全に理解するGrafanaダッシュボード
hamadakoji
3
590
TechFeed Experts Night#27 〜 フロントエンドフレームワーク最前線 (Svelte)
baseballyama
1
490
Meta Quest 3 で動く桜マシマシ WebXR アプリを IBM Cloud Code Engine と Babylon.js で作った話
1ftseabass
PRO
0
120
GraphQL 成熟度モデルの紹介と、プロダクトに当てはめた事例 / GraphQL maturity model
mh4gf
7
1.3k
Java EE/Jakarta EEの現状と将来―クラウドネイティブ時代にJava EEは対応できるのか?―
takakiyo
1
160
ここが嬉しいABAC ここが辛いよABAC #再解説+補足編
masahirokawahara
1
270
プロトタイピングによる不確実性の低減 / Reducing Uncertainty through Prototyping
ohbarye
5
380
Azure犬駆動開発の記録/GlobalAzureFukuoka2024_20240420
nina01
1
210
VSCodeの拡張機能を作っている話
ebarakazuhiro
1
390
生産性向上チームの紹介
cybozuinsideout
PRO
1
870
Featured
See All Featured
Teambox: Starting and Learning
jrom
128
8.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
Into the Great Unknown - MozCon
thekraken
10
990
In The Pink: A Labor of Love
frogandcode
138
21k
Agile that works and the tools we love
rasmusluckow
325
20k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Scaling GitHub
holman
457
140k
Faster Mobile Websites
deanohume
299
30k
The Invisible Customer
myddelton
114
12k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Debugging Ruby Performance
tmm1
70
11k
Build The Right Thing And Hit Your Dates
maggiecrowley
24
2k
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