Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Erlang: Software for a Concurrent world


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.

  • Be the first to comment

Erlang: Software for a Concurrent world

  1. 1. Erlang“Software for a concurrent world” CWI Amsterdam Arjan Scherpenisse 14 december 2012
  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 –● 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.nl