Más contenido relacionado La actualidad más candente (20) Similar a Erlang/OTP for Rubyists (20) Erlang/OTP for Rubyists3. Erlang
Makes easy things possible
and impossible things trivial!
Orion Henry and Blake Mizerany
(Heroku)
4. What is Erlang?
•Language, Runtime and Libraries (OTP)
•Developed and maintained by Ericsson
•Started mid 1980s, open-sourced 1998
8. object object object
object object
object
object object
object object
object object
Object-oriented
object Programming object
object object
object object
object object
object
object
11. process process
process process
process
process process
process process
process
process process
Concurrency-oriented
process
Programming process
process process
process
process process
process
process process
24. Numbers
1
-1
2501
3.14
12345678987654321.987654321
25. Atoms
foo
type
true
false
‘EXIT’
26. Lists
[1,2,3]
[“dog”, “cat”, “fish”]
“hello, world”
27. Tuples
{name, “Sean”}
{address, “8700 State Line Rd”, “Leawood”,
“KS”}
{{line, 10},{column,30}}
{{2009,7,14},{19,0,0}}
28. Binaries
<<“chunk of bytes”>>
<<131,108,0,0,0,2,100,0,3,111,110,101,100
,0,3,116,119,111,
106>>
29. Some Weirdos
“abc” == [97,98,99]. % lists of bytes
true, false % atoms
$a == 97. % characters (ASCII)
P#person.name % compile-time struct
33. Pattern Matching
{Type, Value} = {username, “sean”}.
[{username, Value},
{orders, Orders}] = [{username, “sean”},
{orders, [1,2,3]}].
34. Single Assignment
Really, this is just pattern matching.
A = 5.
A = A + 1. % error: badmatch (5 = 6)
37. List Comprehensions
Think select/filter + map.
A = [1,2,3,4,5].
[X * 2 || X <- A]. % [2,4,6,8,10]
[X || X <- A, X rem 2 == 0]. % [2,4]
41. Anonymous Functions
like lambda/proc, block
Double = fun(X) -> 2*X end.
Double(2). % 4
lists:map(Double, [1,2,3,4,5]).
% [2,4,6,8,10]
49. Behaviors
“patterns”
•gen_server - client-server
•gen_fsm - state machine
•supervisor - fault-tolerance
50. How does it scale?
•Micro-benchmarks, arithmetic slow
•Best for network(ed) apps
•Campfire just as fast as C, ~ 2-4ms
•Near-linear speedup on multicores
•GC per-process, generational