Fireship · @fireship

Erlang in 100 Seconds

Uploaded March 18, 2024 · Length 2:44

Erlang in 100 Seconds

Summary

erlang explained in 100 seconds, a functional programming language for fault-tolerant systems with concurrent execution and message passing.

  • erlang
  • functional programming
  • concurrency
  • message passing
  • fault tolerance

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    erlang a functional fault tolerant

  2. 0:02

    programming language and runtime famous

  3. 0:04

    for scaling up the entire

  4. 0:05

    telecommunications industry with its

  5. 0:07

    bare hands it was developed in 1986 at

  6. 0:10

    Swedish company Ericson where massive

  7. 0:12

    concurrent systems were needed to handle

  8. 0:14

    millions of phone calls in parallel

  9. 0:15

    early implementations were written in

  10. 0:17

    prologue but that was too slow and that

  11. 0:19

    led to the development of beam a virtual

  12. 0:21

    machine that compiles earling to bite

  13. 0:23

    code which is then executed in a

  14. 0:25

    threaded environment where millions of

  15. 0:27

    processes can run concurrently with very

  16. 0:29

    low overhead but when your code breaks a

  17. 0:31

    process the earling philosophy is to let

  18. 0:33

    it fail so the entire system doesn't

  19. 0:35

    come crashing down that process

  20. 0:37

    isolation is what makes it fall tolerant

  21. 0:39

    in addition this facilitates hot code

  22. 0:41

    swapping at runtime to perform software

  23. 0:43

    updates with zero downtime in the late

  24. 0:45

    9s the llang ecosystem was open source

  25. 0:48

    as the open Telecom platform and the

  26. 0:50

    beam BM is still in use today by modern

  27. 0:52

    languages like elixir and gleam and beam

  28. 0:54

    has help messaging tools like rabit mq

  29. 0:57

    Discord and WhatsApp handle billions of

  30. 0:59

    messages every day and that's all thanks

  31. 1:00

    to a programming model based on message

  32. 1:02

    passing that works just like your

  33. 1:04

    mailbox to understand erl Lang's

  34. 1:06

    legendary concurrency model though we

  35. 1:07

    need to look at some code get started by

  36. 1:09

    installing it then create a file ending

  37. 1:11

    in Earl first declare a module then

  38. 1:13

    write a function that contains one or

  39. 1:15

    more Expressions separated by commas

  40. 1:17

    just like a sentence the function ends

  41. 1:19

    when you hit a period Then export the

  42. 1:20

    function from the module and notice this

  43. 1:22

    sl0 here that indicates the function

  44. 1:25

    takes zero arguments now open the

  45. 1:27

    terminal and run Earl C to compile this

  46. 1:29

    code in into a Beam file and now we can

  47. 1:31

    use Earl to open the llang shell and

  48. 1:33

    execute this code pretty cool but now

  49. 1:35

    let's run the same function a thousand

  50. 1:37

    times concurrently in this function

  51. 1:39

    we'll use spawn one of LL Lang's

  52. 1:41

    concurrency Primitives that executes

  53. 1:42

    each function independently on its own

  54. 1:44

    process and returns a process ID for

  55. 1:47

    each one of them the double bars here

  56. 1:48

    will map those IDs to a new list now

  57. 1:51

    when we execute this code we get a lot

  58. 1:52

    more hello worlds and an array of their

  59. 1:55

    process IDs where this concurrency model

  60. 1:57

    really shines though is with message

  61. 1:58

    passing in this example the start