Erlang in 100 Seconds

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
erlang a functional fault tolerant programming language and runtime famous for scaling up the entire telecommunications industry with its bare hands it was developed in 1986 at Swedish company Ericson where massive concurrent systems were needed to handle millions of phone calls in parallel early implementations were written in prologue but that was too slow and that led to the development of beam a virtual machine that compiles earling to bite code which is then executed in a threaded environment where millions of processes can run concurrently with very low overhead but when your code breaks a process the earling philosophy is to let it fail so the entire system doesn't come crashing down that process isolation is what makes it fall tolerant in addition this facilitates hot code swapping at runtime to perform software updates with zero downtime in the late 9s the llang ecosystem was open source as the open Telecom platform and the beam BM is still in use today by modern languages like elixir and gleam and beam has help messaging tools like rabit mq Discord and WhatsApp handle billions of messages every day and that's all thanks to a programming model based on message passing that works just like your mailbox to understand erl Lang's legendary concurrency model though we need to look at some code get started by installing it then create a file ending in Earl first declare a module then write a function that contains one or more Expressions separated by commas just like a sentence the function ends when you hit a period Then export the function from the module and notice this sl0 here that indicates the function takes zero arguments now open the terminal and run Earl C to compile this code in into a Beam file and now we can use Earl to open the llang shell and execute this code pretty cool but now let's run the same function a thousand times concurrently in this function we'll use spawn one of LL Lang's concurrency Primitives that executes each function independently on its own process and returns a process ID for each one of them the double bars here will map those IDs to a new list now when we execute this code we get a lot more hello worlds and an array of their process IDs where this concurrency model really shines though is with message passing in this example the start function spawns a new process then passes it to the sender function from there we can use a bang which is called the send operator to send a message to itself with self or some other process ID we can then handle that message in another function that implements a receive block which allows a process to suspend execution until a message is received in its mailbox it uses pattern matching to look for the process ID and message then executes code when the message is received conceptually receive is kind of like a weight in C or JavaScript however it blocks the entire process until a message is received therefore we might want to add an optional after Clause to run some code after a timeout this has been earling in 100 seconds let me know what you want to see next in the comments thanks for watching and I will see you in the next one
Info
Channel: Fireship
Views: 439,149
Rating: undefined out of 5
Keywords: webdev, app development, lesson, tutorial
Id: M7uo5jmFDUw
Channel Id: undefined
Length: 2min 44sec (164 seconds)
Published: Mon Mar 18 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.