Erlang: Software for a Concurrent world

1,088 views

Published on

Introduction to Erlang for the talk at the Programming Environments Meetup at the Centrum for Mathematics and Computer Science (CWI), December 14, 2012.

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,088
On SlideShare
0
From Embeds
0
Number of Embeds
127
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Erlang: Software for a Concurrent world

  1. 1. Erlang“Software for a concurrent world” CWI Amsterdam Arjan Scherpenisse 14 december 2012 arjan@miraclethings.nl
  2. 2. Agenda● Intro● Language essentials● Concurrency / failure● OTP● VM / GC / optimisations / pitfalls
  3. 3. Erlang Philosophy● The world is concurrent● Things in the world dont share data● Things communicate with messages● Things fail - Joe Armstrong
  4. 4. Language essentials
  5. 5. Data types● Integer / float● Atoms● Tuples● Lists● Binaries … so where are strings?
  6. 6. Datatypes (cont)● Functions● Pids● Ports
  7. 7. Concurrency / failure
  8. 8. Concurrency● spawn, spawn_link● !, receive
  9. 9. Fundamental pieces
  10. 10. OTP: Open Telecom Platform
  11. 11. OTP● application – Contains independent code, multiple applications per Erlang node● supervisor – Supervises worker processes and supervisors● gen_server – Basic work unit
  12. 12. GC / optimisation / pitfalls
  13. 13. Performance● Processes are cheap● Data copying is expensive● Handle much of request in single process● Cache locally in process dict● Reduce size of messages● Bigger binaries (> 64 bytes) are shared and reference counted, make use of them.● String processing is expensive● Keep eye on process inboxes
  14. 14. Garbage Collection● per process, no global gc sweep = no locking of vm● can specify per-process initial heap size● prevent big GCs ● keep big data outside process ● or in process dict ● large binaries = external, use refcounting
  15. 15. Common Pitfalls● Message inbox overflowing● Atom table injection / crash● VM tweaks needed for – nr of open file descriptors – nr of processes – heap size
  16. 16. Outro
  17. 17. What I mainly use it for● Full-stack web development – http://zotonic.com/● HA backend systemsPreventing stuff like this →:-)
  18. 18. Sources of Inspiration● Erlang - the ghetto● Intro to erlang (slideshare)● Erlang - message passing concurrency (slideshare)● Erlang concepts (slideshare)● Concurrency and Paralellism in Erlang (hopkins univ)
  19. 19. Thanks! Arjan Scherpenisse arjan@miraclethings.nlhttp://twitter.com/acscherp http://miraclethings.nl/

×