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
A Sneak Peek into Erlang
Search
Enrique Fernández
January 29, 2015
0
77
A Sneak Peek into Erlang
15 minutes introduction to Erlang preceding a ~45 minutes programming session.
Enrique Fernández
January 29, 2015
Tweet
Share
More Decks by Enrique Fernández
See All by Enrique Fernández
Metaprogramming in Erlang
efcasado
1
190
Deploying Erlang applications on the Cloud using Wombat
efcasado
0
380
Hands on OpenStack
efcasado
1
130
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Being A Developer After 40
akosma
89
590k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Transcript
Erlang Solutions Ltd. © 1999-2015 Erlang Solutions Ltd. A Sneak
Peek into Erlang Stockholm EUG, January 2015
© 1999-2015 Erlang Solutions Ltd. • Enrique Fernández - Software
Engineer - Working with Erlang since 2011 - MSc. Computer Science, URV, Spain - Research Associate, URV, Spain (~2.5 years) - Ericsson Research, Sweden (~1.5 years) - Erlang Solutions, Sweden (2+ years) • Contact:
[email protected]
Speaker 2
© 1999-2015 Erlang Solutions Ltd. You 3 • No Erlang
experience required • No Functional Programming experience required • Should have basic programming skills • Eager to learn some Erlang!
© 1999-2015 Erlang Solutions Ltd. Objectives • Get you started
with Erlang • Solve the first 10 exercises from “99 haskell problems” using Erlang • Have some fun 4
© 1999-2015 Erlang Solutions Ltd. Hello, Erlangers! -module(hello). -export([hello_world/1]). hello_world(X)
-> io:format(“Hello, ~s!~n”, [X]). 5 module name exported functions function definition File: src/hello.erl
© 1999-2015 Erlang Solutions Ltd. The Erlang Compiler (a.k.a. erlc)
6 erlc -o ebin src/hello.erl Erlang compiler Source file Compiler options http://www.erlang.org/doc/man/erlc.html
© 1999-2015 Erlang Solutions Ltd. The Erlang Emulator (a.k.a. erl)
7 erl -pa ebin Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.1 (abort with ^G) 1> hello:hello_world("Erlangers"). Hello, Erlangers! ok 2> Erlang emulator Emulator options http://www.erlang.org/doc/man/erl.html
© 1999-2015 Erlang Solutions Ltd. Concurrent Programming (in Erlang) 8
erl -S 1 Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [smp:1:1] [async- threads:10] [hipe] [kernel-poll:false] Eshell V6.1 (abort with ^G) 1> Loop = fun Loop(X) -> io:format("~p Says: ~p~n", [self(), X]), Loop(X) end. #Fun<erl_eval.30.90072148> 2> [spawn(fun() -> Loop(X) end) || X <- ["A", "B", "C", "D"]]. <0.49.0> Says: "A" <0.50.0> Says: "B" <0.51.0> Says: "C" <0.52.0> Says: "D"
© 1999-2015 Erlang Solutions Ltd. Concurrent Programming (in Erlang) 9
erl -S 2 Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [smp:2:2] [async- threads:10] [hipe] [kernel-poll:false] Eshell V6.1 (abort with ^G) 1> Loop = fun Loop(X) -> io:format("~p Says: ~p~n", [self(), X]), Loop(X) end. #Fun<erl_eval.30.90072148> 2> [spawn(fun() -> Loop(X) end) || X <- ["A", "B", "C", "D"]]. <0.49.0> Says: "A" <0.52.0> Says: "D" <0.50.0> Says: "B" <0.51.0> Says: "C"
© 1999-2015 Erlang Solutions Ltd. Concurrent Programming (in Erlang) 10
Erlang/OTP 17 [erts-6.1] [source-d2a4c20] [smp:8:8] [async- threads:10] [hipe] [kernel-poll:false] Eshell V6.1 (abort with ^G) 1> spawn(fun() -> receive {From, X} -> From ! lists:reverse(X) end end). <0.34.0> 2> pid(0,34,0) ! {self(), "Hello, Erlangers!”} {<0.32.>, "Hello, Erlangers!”} 3> flush(). Shell got "!sregnalrE ,olleH" ok
© 1999-2015 Erlang Solutions Ltd. Let’s Get Started 11 git
clone https://github.com/efcasado/EUGSTHLM-99erlproblems -b pt1 cd EUGSTHLM-99erlproblems make