Erlang is not a city in Germany

1,587 views
1,484 views

Published on

Short introduction to the programming language Erlang hold at the GeekGirlMeetup in Berlin 2012

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,587
On SlideShare
0
From Embeds
0
Number of Embeds
1,167
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Erlang is not a city in Germany

  1. 1. Erlang is not a city in Germany!
  2. 2. About me Monika Moser @momo13 Software Architect
  3. 3. Erlang is a general-purpose language and a runtime environment.
  4. 4. Language Functional. Strict evaluation. Single assignment. Dynamic typing.
  5. 5. Erlang has built in support for concurrency, distribution and fault tolerance.
  6. 6. Ericsson Language since 1986
  7. 7. Developed to build near-real-time fault tolerant distributed non-stop applications.
  8. 8. Used by CouchDB: NoSQL DB that uses JSON to store data Facebook: For the chat backend Wooga: Backend for Facebook games Klarna: Electronic payment systems
  9. 9. Functional -module(hello). -export([world/0]). world() -> io:format("Hello, world!~n", []).
  10. 10. 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
  11. 11. Expressions > % A comment > 1 + 3. 4 > “This is a string”. “This is a string”
  12. 12. Expressions > [1, 2, 3]. [1,2,3]. > [72, 101, 108, 108, 111, 33]. “Hello!”
  13. 13. Expressions > Variable = “GeekGirls”. “GeekGirls” > Variable = "are boring". ** exception error: no match of right hand side value "are boring"
  14. 14. Pattern Matching > Tuple = { “Erlang”, “Joe A.”}. { “Erlang”, “Joe A.”}. > { Language, Inventor } = Tuple. { “Erlang”, “Joe A.”}. > Language. “Erlang”
  15. 15. Recursion fac(0) -> 1; fac(N) when N > 0, is_integer(N) -> N*fac(N-1).
  16. 16. Higher order functions > lists:foreach(fun(Word) -> ! ! ! ! io:format("~p~n", [Word]) ! ! ! end, ! ! ! ["Geek", "Girl", "Meetup"] ! ! ). “Geek” “Girl” “Meetup”
  17. 17. Fun with Lists List comprehension: > [ X*X || X <- [2, 3, 4], X rem 2 == 0]. [4,16]
  18. 18. Concurrency Lightweight processes Message passing primitives
  19. 19. Sending Messages PID ! { message, “Content”}.
  20. 20. Receiving Messages loop() -> receive { message, Content } -> io:format(“Content: ~p”, [Content]); loop(); Any -> io:format(“Received unexpected: ~p”, [Any]) end.
  21. 21. Spawning a process PID = spawn(fun loop/0). PID ! {message, “GeekGirlMeetup”}. is_process_alive(PID). true. PID ! stop. is_process_alive(PID). false.
  22. 22. Monitor processes Processes can be monitored. EXIT signals with a reason will be received. process_flag(trap_exit, true). {‘EXIT’, From, Reason}.
  23. 23. Useful for Distributed, reliable, concurrent systems

×