The Ultimate Guide to Gleam Concurrency

  Рет қаралды 24,505

Isaac Harris-Holt

Isaac Harris-Holt

Күн бұрын

Пікірлер: 93
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
ERRATA: 05:43 - The fan out line should read `|> list.map(fn(email) { task.async(send_email(email)) })`. It's missing the `task.await`! Thanks @josephlyons3393 for pointing this out
@jormarma1976
@jormarma1976 8 ай бұрын
Please! More Gleam content of this quality and clarity. It's awesome, thank you!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Absolutely! Working on it :)
@lpil
@lpil 8 ай бұрын
@@IsaacHarrisHolt I'm excited!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Lustre next! Hayleigh is gonna be very pleased
@HostilePride
@HostilePride 8 ай бұрын
Gleam has been my introduction to the BEAM and a lot of functional concepts, and video's like this help SO MUCH! Trying to see problems through a non-Object-Oriented lens has been interesting, and a lot of your videos have been very useful and easy to understand. Thanks for the time you put into making your content.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I'm just really glad I'm able to be helpful! Thanks so much :)
@Metruzanca
@Metruzanca 8 ай бұрын
Another great gleam video. Everytime, I wanna learn and use gleam more.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Do it! It's a great language. I'll be doing more Gleam tutorials in the future too :)
@danilodjokic5303
@danilodjokic5303 8 ай бұрын
Gleam is looking more and more like my next Advent of Code language
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Sounds good, but why wait until December 👀 and why not try it out on some real projects?
@danilodjokic5303
@danilodjokic5303 8 ай бұрын
@@IsaacHarrisHolt I'm currently doing a larger personal project in Go and I'm trying to actually get it done and avoid the shiny object syndrome. I'm still not sold on whether I should look into Gleam or Elixir next, but your videos are very clean and convincing
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Fair enough! Good luck with the project :)
@abuk95
@abuk95 4 ай бұрын
Why? You don't need more than one process for AoC
@danilodjokic5303
@danilodjokic5303 4 ай бұрын
@@abuk95 I just commented on this particular video. More so due to the syntax than the the concurrency model. But in AoC I did solve some problems with concurrency (probably should have used a better algorithm though)
@Mankepanke
@Mankepanke 8 ай бұрын
I think you need to slow down a bit because I can't keep up. I barely have time to read the code between each slide, and on top of that I need to also listen to what you are saying and then find the piece of the code you mean. It's interesting and all, but at some point I started to zone out because it just became a stream of words... "To start the supervisor call supervisor start and the supervisor starts and returns a supervisor subject that ..." I'll rewatch again later to see of it sticks better that time.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Understood! Thanks for the feedback
@sosquite8866
@sosquite8866 8 ай бұрын
I have the exact same issue, i think maybe keeping the whole block shown while just highlighting the part you are talking about might do the trick. And yes i guess slowing down a but may also decrease the "stream of words" effect
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I do try and highlight where possible! Sometimes that's more difficult though, but I'll do my best :)
@Mankepanke
@Mankepanke 8 ай бұрын
I hope it didn't come off as too harsh. I enjoyed the content, and your enthusiasm for the content really makes me want to learn too! I'm subscribed now and look forward to the next installment!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you! And not harsh at all, don't worry! It's fairly common feedback, but I also get a lot of feedback from people who find the quick pace refreshing
@lankymoose1831
@lankymoose1831 7 ай бұрын
"if the supervisor can't restart its child for whatever reason, it will kill its other children, and then itself" 🤣🤣
@IsaacHarrisHolt
@IsaacHarrisHolt 7 ай бұрын
Sounds like a, uh, pretty normal Sunday to me
@SnowDaemon
@SnowDaemon 8 ай бұрын
Another good Gleam video, Thanks Isaac
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you! I hope you found it helpful
@andredasilva6807
@andredasilva6807 8 ай бұрын
keep up thr amazing gleam videos. i started using gleam and its amazing. the lsp need some work, but its on its way to be a fantastic language
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you! I've got more in the works, don't worry
@josephlyons3393
@josephlyons3393 8 ай бұрын
Great video! I've been wanting a video on exactly this - thank you! Also, small thing, but at 5:51, you can shorten the code a tiny bit with `list.map(send_email)` and skip the anonymous function wrapper.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
You're right! But mostly because I actually made a mistake on that line and it should read `|> list.map(fn(email) { task.async(send_email(email)) })` (wrapped with `task.async`)
@Techonsapevole
@Techonsapevole 8 ай бұрын
Thanks the video I was wainting for
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I hope you found it helpful!
@aLfRemArShMeLlOw
@aLfRemArShMeLlOw 8 ай бұрын
Amazing video as usual.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you, thank you!
@AhmadVisuals
@AhmadVisuals 5 ай бұрын
This channel deserves a SUBSCRIBE!😉
@IsaacHarrisHolt
@IsaacHarrisHolt 5 ай бұрын
Thank you!
@lpil
@lpil 8 ай бұрын
Time to make Isaac head of GleamVideo
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I believe the official term is The Glambassador
@lpil
@lpil 8 ай бұрын
@@IsaacHarrisHolt I knew you were the right person for the job
@andredasilva6807
@andredasilva6807 8 ай бұрын
@lpil thanks for your hard work an this amazing language :)
@lpil
@lpil 8 ай бұрын
@@andredasilva6807 thank you!
@eidiazcas
@eidiazcas 5 ай бұрын
I really love gleam, the tasks to avoid function coloring *MUAH, beautiful
@IsaacHarrisHolt
@IsaacHarrisHolt 5 ай бұрын
Best feature of Gleam tbh
@jp2kk2
@jp2kk2 8 ай бұрын
man, i always loved erlang, its syntax, and its concurrency, but never used it on prod. This looks so promising!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
It's fun! And very easy to do, too
@ryzh6544
@ryzh6544 8 ай бұрын
Well, that's a tough one :) I'll come back after diving into the Learn OTP w/Gleam repo and the docs. p.s. why the code highlighting is so weak?. Just copy paste from the vscode and you'll get the colors!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Awesome! And the code highlighting isn't great because Gleam isn't supported by the library used yet. I use vim and copying the text from there doesn't copy the colours, so sadly that doesn't work!
@ryzh6544
@ryzh6544 8 ай бұрын
​@@IsaacHarrisHolt ​ hi! 7:33 - 8:12 I don't really understand why actor.call() works when we pass to it a record of "type Message" as a second argument, while the second argument of actor.call() must be a "fn(Subject(b)) -> a"... but it works and even can pass additional message record's arguments... p.s. record of the Message is treated as a function?.. still don't get it. p.s.s. Ok so we are using a function capture to capture the message constructor and if need we pass the additional arguments so the only thing to pass to a constructor left is a new subject which will be added automatically (so we write placeholder) and will be used to send the result to a client. And the result type is declared by the type of reply_with: Subject(***) field of the Message record. p.s.s.s hmmm seems I got it, don't I? brain hurts :()()()( Your video was really helpful to bring all the info about the actors together... I would like to believe :)
@ryzh6544
@ryzh6544 8 ай бұрын
​@@IsaacHarrisHolt Yo! As expected, your video was very useful. After and while reading the repo and the documentation, it helped a lot to understand what was going on. Especially in trying to understand how the whole actor loop works (Message type, handler, actor.send, actor.call). Thanks a lot!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
@@ryzh6544 nice one! I'm glad I was able to help
@rallokkcaz
@rallokkcaz 8 ай бұрын
Do you use GenServers in Gleam? I'd love to see a video on that.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
GenServers in Gleam are called actors! They're covered in detail here :)
@gro967
@gro967 4 ай бұрын
Gleam looks like a nice language to write some microservices in 👌
@IsaacHarrisHolt
@IsaacHarrisHolt 4 ай бұрын
What's nice about Gleam is that you don't really need microservices! Most of the benefits you get from them, like asynchronous operations and easy scaling, are already taken care of by the BEAM VM
@TheHTMLCode
@TheHTMLCode 8 ай бұрын
Awesome as always!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you!
@shivrajnag12
@shivrajnag12 8 ай бұрын
Hi Issac, would love to see a tutorial on REST API CRUD with authentication and SQL DB
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I'll be looking into this sort of thing with Wisp at some point in the future!
@MtthwBrwng
@MtthwBrwng 8 ай бұрын
Great Video!
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you!
@Michael-kw1zv
@Michael-kw1zv 8 ай бұрын
Nice video. I believe I understand the concurrency model from this and other content, but I struggle to find project ideas where I can make effective use of it. Any good ideas for putting these into action?
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
It'll depend on the project, but you can use tasks for asynchronously interacting with APIs or running other background jobs. Actors are good for queued work or holding shared state
@bcpeinhardt
@bcpeinhardt 8 ай бұрын
The build your own redis challenge is free this month on codecrafters in Gleam :) it uses the glisten tcp server, which is built on gleam_otp and uses gleam actors in it's APIs. It's a fun practical use case, plus because BEAM concurrency is really good you pass the first three stages just by setting up the server, it's pretty neat. If you get stuck, Louis (the gleam language author) streamed some videos doing the challenge on twitch and youtube.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Yes, this is a fantastic way to learn Gleam!
@costathoughts
@costathoughts 8 ай бұрын
this is really similar with Akka Actor Model Approach
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Interesting! I'm not a JVM person, but Akka looks cool
@devyb-cc
@devyb-cc 8 ай бұрын
this language is beautiful
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
I know, right!
@devyb-cc
@devyb-cc 8 ай бұрын
@@IsaacHarrisHolt i am also amazed by wathing louis pilfold 1hr video making backend with gleam, then your video dropped out at the perfect time lol. damn, the syntax is really neat 👌
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
@@devyb-cc awesome!
@logemii
@logemii 7 ай бұрын
god i love this
@IsaacHarrisHolt
@IsaacHarrisHolt 7 ай бұрын
Gleam is great!
@uchennaofoma4624
@uchennaofoma4624 8 ай бұрын
Amazing video
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Thank you! I hope you found it helpful :)
@lazyh0rse
@lazyh0rse 8 ай бұрын
Gleam seems promising, but honestly, these days I have been wondering, why people seem keen on performance? I don't get it. Even the most famous youtubers at most get 1000 views per second, which is much less than what python slowest framework can handle. You have caches, algorithms, etc... all of which could speed up the framework even more. So it's really pointless. I would use gleam only if there's a benefit that I don't get with python, otherwise, I won't jump ship.
@IsaacHarrisHolt
@IsaacHarrisHolt 8 ай бұрын
Gleam doesn't really give you much performance over Python. What it does give you is reliability. With Python, if one of those 1000 requests per second crashes (not with an exception, but properly crashes), every other request in flight being handled by that instance would fail. With Gleam and other BEAM languages, if one request crashes (e.g. with a panic, like in the video), only the process handling that request goes down. The rest of the application can continue. Also, the BEAM makes it nearly trivial to distribute across multiple machines in multiple regions, so you can easily keep serving traffic if a whole data centre goes down. Python and other languages need additional overheard like orchestration tools to make that happen.
@rumble1925
@rumble1925 8 ай бұрын
The beam vm allows you a completely different paradigm that is very suited to the web. Like OP says, you can crash a process without affecting everything else. Also from experience with elixir, you don't need to bring in extra libraries, servers and languages to do web things. You don't have to reach for redis, nginx, managing cron and bash scripts, crash recovery with upstart... you don't have to orchestrate all these things across many languages, it's all baked in with OTP.
@lazyh0rse
@lazyh0rse 8 ай бұрын
@@rumble1925 thanks, i think having all in one experience could justify using it.
@anotherelvis
@anotherelvis 6 ай бұрын
Great video, but please show the code snippets for a longer time before you switch to memes. The video is a little hard to follow at normal speed.
@IsaacHarrisHolt
@IsaacHarrisHolt 6 ай бұрын
Understood! I've started slowing things down in my more recent videos :)
@sunofabeach9424
@sunofabeach9424 7 ай бұрын
immutability and async just don't mix man. I want to mutate my state from 16 threads so much it's unreal
@IsaacHarrisHolt
@IsaacHarrisHolt 7 ай бұрын
I'm reeeally hoping this is sarcastic 😅
@sunofabeach9424
@sunofabeach9424 7 ай бұрын
@@IsaacHarrisHolt yeah it is... although lack of mutability isn't always a good thing
@IsaacHarrisHolt
@IsaacHarrisHolt 7 ай бұрын
@@sunofabeach9424 agreed. It depends what you're trying to achieve
@danser_theplayer01
@danser_theplayer01 14 күн бұрын
No threads in gleam? That's crazy, won't catch me doing this in javascript. "Effortless concurrency" hah.
@IsaacHarrisHolt
@IsaacHarrisHolt 14 күн бұрын
The BEAM VM (and therefore Gleam) uses 'processes' which are essentially green threads and can be thought of as analogous to Go's goroutines. The only difference really is the 'shared nothing' architecture whereby each process has its own memory and call stack.
@caju2991
@caju2991 4 ай бұрын
PLEASE, DON'T SELL AN GLEAM COURSE LIKE THE OTHERS, I'M NEED GET MY LUNCH. For a more democratic web with easy access to technology, that people can change their lives for the better.
@IsaacHarrisHolt
@IsaacHarrisHolt 4 ай бұрын
Don't worry! If I do ever make a Gleam course, it won't have any information that isn't available elsewhere on my channel - it'll just be more structured.
@caju2991
@caju2991 4 ай бұрын
@@IsaacHarrisHolt thanks a lot.
Gleam is not Rust
7:46
Isaac Harris-Holt
Рет қаралды 30 М.
Gleam for Impatient Devs
8:46
Isaac Harris-Holt
Рет қаралды 73 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Create Robust Web Apps with Gleam and Lustre
12:32
Isaac Harris-Holt
Рет қаралды 41 М.
🏆 Rust is CHANGING Python for the better
9:31
Bitswired
Рет қаралды 3,2 М.
Why Most Self-Taught Developers Never Land The Job
7:28
Travis Media
Рет қаралды 164 М.
From $erverless To Elixir | Prime Reacts
22:34
ThePrimeTime
Рет қаралды 123 М.
An Erlanger's encounter with Gleam | Bartek Gorny
31:55
Erlang Solutions
Рет қаралды 2,4 М.
Your backend is too complicated
9:47
Isaac Harris-Holt
Рет қаралды 97 М.
Gleam v1 HAS BEEN RELEASED
27:07
ThePrimeTime
Рет қаралды 170 М.
What Gear Shape Meshes With a Square?
31:17
Morphocular
Рет қаралды 749 М.
New Gleam Just Dropped
25:33
ThePrimeTime
Рет қаралды 89 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН