erlang is not a city in germany
DESCRIPTION
Short introduction to the programming language Erlang hold at the GeekGirlMeetup in Berlin 2012TRANSCRIPT
Used byCouchDB: NoSQL DB that uses JSON to store data
Facebook: For the chat backend
Wooga: Backend for Facebook games
Klarna: Electronic payment systems
Let it run!$ erlErlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)1> c(hello).{ok,hello}2> hello:world().Hello, world!ok
Expressions> Variable = “GeekGirls”.“GeekGirls”
> Variable = "are boring".** exception error: no match of right hand side value "are boring"
Pattern Matching> Tuple = { “Erlang”, “Joe A.”}.{ “Erlang”, “Joe A.”}.
> { Language, Inventor } = Tuple.{ “Erlang”, “Joe A.”}.
> Language.“Erlang”
Higher order functions> lists:foreach(fun(Word) ->! ! ! ! io:format("~p~n", [Word])! ! ! end,! ! ! ["Geek", "Girl", "Meetup"]! ! ).
“Geek”“Girl”“Meetup”
Receiving Messagesloop() -> receive { message, Content } -> io:format(“Content: ~p”, [Content]); loop(); Any -> io:format(“Received unexpected: ~p”, [Any]) end.
Spawning a processPID = spawn(fun loop/0).
PID ! {message, “GeekGirlMeetup”}.is_process_alive(PID).
true.PID ! stop.
is_process_alive(PID).false.
Monitor processesProcesses can be monitored.
EXIT signals with a reason will be received.
process_flag(trap_exit, true).{‘EXIT’, From, Reason}.