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
Programação Funcional & Elixir
Search
Amanda
November 04, 2017
Technology
3
110
Programação Funcional & Elixir
Amanda
November 04, 2017
Tweet
Share
More Decks by Amanda
See All by Amanda
Lessons Learned From an Elixir OTP Project
amandasposito
2
55
Aprendizados de um projeto Elixir OTP
amandasposito
4
490
SOLID - Dependency inversion principle
amandasposito
0
66
Como concorrência funciona em Elixir?
amandasposito
1
210
Ecto, você sabe o que é ?
amandasposito
4
230
Novidades no Rails 5
amandasposito
0
91
Rails Engines & RSpec
amandasposito
0
200
Elixir e Phoenix
amandasposito
3
540
Elixir em 5 minutos
amandasposito
1
83
Other Decks in Technology
See All in Technology
商品レコメンドでのexplicit negative feedbackの活用
alpicola
2
370
RubyでKubernetesプログラミング
sat
PRO
4
160
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
240
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
190
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.5k
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
KMP with Crashlytics
sansantech
PRO
0
240
月間60万ユーザーを抱える 個人開発サービス「Walica」の 技術スタック変遷
miyachin
1
140
カップ麺の待ち時間(3分)でわかるPartyRockアップデート
ryutakondo
0
140
シフトライトなテスト活動を適切に行うことで、無理な開発をせず、過剰にテストせず、顧客をビックリさせないプロダクトを作り上げているお話 #RSGT2025 / Shift Right
nihonbuson
3
2.2k
AWSマルチアカウント統制環境のすゝめ / 20250115 Mitsutoshi Matsuo
shift_evolve
0
120
新卒1年目、はじめてのアプリケーションサーバー【IBM WebSphere Liberty】
ktgrryt
0
130
Featured
See All Featured
Facilitating Awesome Meetings
lara
51
6.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Faster Mobile Websites
deanohume
305
30k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Writing Fast Ruby
sferik
628
61k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Building Applications with DynamoDB
mza
93
6.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Transcript
Programação Funcional & Elixir
@amandasposito @amsposito @amandasposito
None
Falando um pouco de história
http://www.gotw.ca/publications/concurrency-ddj.htm
None
None
“Efficiency and performance optimization will get more, not less, important.”
“Applications will increasingly need to be concurrent if they want
to fully exploit continuing exponential CPU throughput gains.”
Por que isso afeta nossa aplicação?
None
Elixir criada por José Valim
Percebeu que as ferramentas que existiam não eram boas para
concorrência
None
Elixir roda em cima da maquina virtual do Erlang
Erlang é conhecido por rodar aplicações com latência baixa, distribuídas
ou tolerante a falhas
Escalabilidade Tolerância a falhas Compatível com Erlang Hot Code Swap
Linguagem Dinâmica Metaprogramação Polimorfismo Concorrência
Diferentes paradigmas
Paradigma Funcional
–Introduction to Functional Programming - Richard Bird Philip Wadler “Programming
in a functional language consists of building definitions and using the computer to evaluate expressions.”
Imutabilidade
Consistência de dados
Concorrência Capacidade de lidar com várias coisas ao mesmo tempo
https://blog.whatsapp.com/196/1-million-is-so-2011?
Vamos resolver um problema
None
None
switch = fn (bulb) -> ... end switch.(bulb)
defmodule LightBulb do def switch(human, bulb) do end end LightBulb.switch(bulb)
Pattern Matching
name = "Amanda"
Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h()
ENTER for help) iex(1)> name = "Amanda" "Amanda" iex(2)> "Amanda" = name "Amanda" iex(3)> "Amanda S" = name ** (MatchError) no match of right hand side value: "Amanda"
defmodule LightBulb do def switch(human = %Human{}, bulb = %Bulb{})
… end end
Function Arity
defmodule LightBulb do def switch(human, bulb) do ... end def
switch(_) do IO.puts "Precisamos de um humano e de uma escada." end end
Guards
defmodule LightBulb do def switch(human, bulb) when bulb.burned_out == true
do … end end
If and unless
defmodule LightBulb do def switch(human, bulb) when bulb.burned_out == true
do ladder = Ladder.get_average_height() if ladder.under do … end end end
Pipe Operator
new_bulb = Bulb.get_bulb() lader = Ladder.get_average_height() human = Human.climb(human, ladder)
human = Human.remove_bulb(human, bulb) human = Human.put_bulb(human, new_bulb)
Ladder.get_average_height() |> Human.climb(human) |> Human.remove_bulb(bulb) |> Human.put_bulb(new_bulb)
None
Recursão
numbers = 3; for(i = numbers; i > 0; i--)
{ console.log(i); }
None
defmodule NaturalNums do # Uma clausula para parar a recursão
def print(1), do: IO.puts(1) def print(n) do # Imprime o número" IO.puts(n) # Chama a si mesmo com um valor a menos print(n - 1) end end
iex(1)> NaturalNums.print(3) 3 2 1 :ok
None
None
https://www.codeschool.com/courses/try-elixir
https://www.dailydrip.com/topics/elixir https://github.com/dailydrip/firestorm
http://plataformatec.com.br/elixir-radar
None
Obrigada!
Referências • https://hipsters.tech/elixir-a-linguagem-hipster- hipsters-48/ • https://codewords.recurse.com/issues/one/an- introduction-to-functional-programming • http://theerlangelist.blogspot.com.br/2013/05/working- with-immutable-data.html