What is a monad? (Design Pattern)

  Рет қаралды 334,063

A Byte of Code

A Byte of Code

Күн бұрын

Пікірлер: 910
@AByteofCode
@AByteofCode 2 жыл бұрын
Hiya! It turns out that what is described in this video is the Functor and not the Monad. The difference between these two is quite minor so I'll leave it here. A monad is just a functor which has some extra property within the bind method. Functions being passed in bind calls must have as their return types an instance of the monad being used. The bind method of a monad would then need to "unwrap" that value.
@wanderingthewastes6159
@wanderingthewastes6159 2 жыл бұрын
Wait, so I’m using a monad everytime I call .unwrap() in Rust?
@AByteofCode
@AByteofCode 2 жыл бұрын
​@@wanderingthewastes6159 I would need to look into it but from the little I know, unwrap is a method of an Option type, which I believe is a monad. You would need to ask someone who knows more about rust than me, I've only seen like 2-3 No Boilerplate videos.
@felixnderitu1455
@felixnderitu1455 2 жыл бұрын
Hey can you do a full Video about Design patterns ?
@mskiptr
@mskiptr 2 жыл бұрын
No, no, no! What you described here *are* properties of a typical _monad_ (barring some technicalities). _Functors_ are things you can write a _map_ function for, such as _lists_ (applies the function to every element inside), but also _maybe_ (apply the function if there is something inside).
@nxone9903
@nxone9903 2 жыл бұрын
a monad is just a monoid in the category of endofunctors
@falkelh
@falkelh 2 жыл бұрын
I already know what a monad is: it's that thing that my annoying friend who's just learned Haskell won't stop talking about
@AByteofCode
@AByteofCode 2 жыл бұрын
Sounds about right :)
@andrasfogarasi5014
@andrasfogarasi5014 2 жыл бұрын
A monad is just a monoid in the category of endofunctors. I don't know what people don't get about that.
@AByteofCode
@AByteofCode 2 жыл бұрын
Hehe... Just wait a few weeks and I'll have a full video about that sentence (and all the CT necessary to understand it)
@oscareriksson9414
@oscareriksson9414 2 жыл бұрын
Yes. That is thing I understand.. endofunkting easy! 😁
@Brunoenribeiro
@Brunoenribeiro 2 жыл бұрын
"bart, say the line!"
@AByteofCode
@AByteofCode 2 жыл бұрын
@@Brunoenribeiro im tempted to ask stemg for his permission to use that clip in a video lmao
@arsnakehert
@arsnakehert 2 жыл бұрын
@@AByteofCode Subscribed to wait for it lol
@crabbyboi9127
@crabbyboi9127 2 жыл бұрын
I'm a big fan of the "fireship style" of videos and it's great to see more people creating high quality content like this
@AByteofCode
@AByteofCode 2 жыл бұрын
It's about time the style leaves web development and talks about other stuff :)
@yt-1337
@yt-1337 2 жыл бұрын
@@AByteofCode exactly
@4xmo
@4xmo 2 жыл бұрын
why is that in quotes lol
@dailyfunnytv358
@dailyfunnytv358 Жыл бұрын
@@4xmo because he's not the creator
@Yazan_Majdalawi
@Yazan_Majdalawi Жыл бұрын
This channel is much better at this "style" than fireship, this one is much clearer, fireship's vids are a mess
@tylerscott9277
@tylerscott9277 2 жыл бұрын
This 2 minute video is a better explanation of monads than some hour long lecture I've watched. Really good stuff!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words! Honestly those lectures are good but too long to focus on so they end up not being good. Lectures are also generally performed in front of a group of students with assumed knowledge basics. I wrote this video with no pre-requisites other than knowing a tiny bit of programming.
@samuelwaller4924
@samuelwaller4924 2 жыл бұрын
You may be very small now, but with this quality of content you will definitely be big one day!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words and optimism!
@9paradox
@9paradox 2 жыл бұрын
i approve this comment.
@hydralisk98
@hydralisk98 2 жыл бұрын
I approve this sentiment. The video content is high quality already and I support such efforts much. I can't wait to see what is next from "A Byte of Code", especially as a hobby programmer interested much in both past and future tech advances.
@AByteofCode
@AByteofCode 2 жыл бұрын
@@hydralisk98 Ever heard of JSF*ck? :p
@hydralisk98
@hydralisk98 2 жыл бұрын
@@AByteofCode You mean the JS implementation of Brainf*ck? Not the JS edition before this video but yes I am aware of it. I do am aware of much as far as my curiosity lead me to, both in esoteric prog langs and more serious ones like Common Lisp, C# and even exploring F#/F*. Hopefully as I dive into the history of web tech (going before even SGML & IBM's GML), we may collaborate on advanced programming functional structures soon. ^*^//
@tsyf1
@tsyf1 2 жыл бұрын
Fireship's influence shows. You're also just as talented at explaining complex things in a short time.
@AByteofCode
@AByteofCode 2 жыл бұрын
I started this channel in part to further the Fireship style to other realms of programming, so that is actually a great compliment, thank you!
@DavidSimonTetruashvili
@DavidSimonTetruashvili 2 жыл бұрын
And it's a great style. Imitating it, I think, will only bring good things as it mutates through creators picking it up. Also, refreshing to see this style without the usual inside jokes fireship includes in his fast-pace videos which can sometimes be misconstrued as facts...
@AByteofCode
@AByteofCode 2 жыл бұрын
@@DavidSimonTetruashvili I agree fireship has an amazing way of showcasing content and that its a good place to start out from and develop one's own style off of it. Was expecting to have more time to adapt but youtube's algorithm did not agree. I watch a lot of fireship but can't think of any of these inside jokes off the top of my head, would you have an example or two by any chance?
@tsyf1
@tsyf1 2 жыл бұрын
@@DavidSimonTetruashvili I was thinking the same thing. It'll be very interesting watching this style evolve.
@miquelvazquez4544
@miquelvazquez4544 2 жыл бұрын
@@AByteofCode he usually uses irony! stuff along the lines (off the top of my head, not exact quote) of: "we all love getting a new framework every month"
@gilmoretj
@gilmoretj Жыл бұрын
This has to be the best explanation of Monads I have found out of all the many, many, many videos I have watched, and definitely the most productive 2 minutes and 30 second - highly recommended. I suspect one of the major difficulties with explaining the concept are the different mindsets of the audience from the instructor. The vast majority of instructors will be from a declarative/Functional Programming background where solutions are defined in terms of what needs to be done. The audience will largely comprise developers from an imperative OOP/Procedural background where solutions are formed by defining the steps required to resolve the problem. Having an explanation in terms of how the monad resolves a problem by absorbing some of the steps is really easy to understand. The last 60 seconds of this video really hits that message home, but I would not go as far as to suggest watching the video in reverse.
@AByteofCode
@AByteofCode Жыл бұрын
Thank you!! The second paragraph is definitively key to what made this video work. When I made it, my understanding of functional programming was pretty mediocre, making it no more than an imperative programmer trying to explain monads to other imperative programmers. However I never actually realized what I had done until this comment, so thanks for pointing it out :)
@swankitydankity297
@swankitydankity297 2 жыл бұрын
I commend you for having so clearly and accessibly explained a notoriously difficult topic. I finally feel like I actually understand what these are now. Thanks!
@AByteofCode
@AByteofCode 2 жыл бұрын
Ayo glad to help!
@robinmoussu
@robinmoussu 2 жыл бұрын
That’s probably the best concise explanation of monad I’ve read so far!
@AByteofCode
@AByteofCode 2 жыл бұрын
I'm happy to hear that!
@benjaminshu4018
@benjaminshu4018 2 жыл бұрын
Great video±! You have enlightened my vision on computer science by finally explaining to me what a monad is dude.
@AByteofCode
@AByteofCode 2 жыл бұрын
lmao
@polycode2688
@polycode2688 2 жыл бұрын
These videos are well made, keep making them!
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad you like them, I definitively will continue!
@DanielRamBeats
@DanielRamBeats 2 жыл бұрын
There have been many attempts to explain monads and many have failed but your example makes it extremely clear, thank you
@AByteofCode
@AByteofCode 2 жыл бұрын
I'm happy to help :)
@AByteofCode
@AByteofCode 2 жыл бұрын
What can I do to make my future videos better? Any feedback (even negative) is much appreciated!
@brian-bed
@brian-bed 2 жыл бұрын
remember to pin your comments so i can see then at the top :)
@AByteofCode
@AByteofCode 2 жыл бұрын
@@brian-bed oh right yeah lol ty for pointing that out
@sharbelokzan9673
@sharbelokzan9673 2 жыл бұрын
I still don't understand monads 100%, But this video is where I can say I got the closest to understand them. And the most surprising thing is the video length! I have watched, before this, a lot of other videos about monads, and some of them were really long and thorough, but I consider this one is the best so far. I can't be sure whether it's the example you gave or the fact that I'm watching this after watching many similar videos, but this is defiantly QUALITY CONTENT, short, concise, holistic and well-narrate. Thankyou very much
@AByteofCode
@AByteofCode 2 жыл бұрын
This brings a smile to my face :) If you don't plan on going into functional programming, just think of monads as a smart box that does stuff to its contents for you. (Its more than that but the distinction doesn't matter outside of FP)
@sharbelokzan9673
@sharbelokzan9673 2 жыл бұрын
@@AByteofCode tnx!, yup I think the smart box analogy do it for me now
@AByteofCode
@AByteofCode 2 жыл бұрын
@@sharbelokzan9673 Ayy that's good to hear! Was considering using that analogy for the video itself but decided to avoid using metaphors
@taragnor
@taragnor Жыл бұрын
Yeah this is the most concise explanation of a monad I've seen and in a way that a regular programmer would understand.
@tantalus_complex
@tantalus_complex Жыл бұрын
​@@AByteofCode Question for you. I see the Maybe monad example in this video as a way of relocating many examples of a problematic procedural step ("procedural" in the normal English sense) down to a single isolated location. As a result, common problems stemming from that step (in this case, problems with function calls and property accessors) can be handled in common. I have an example which I think fits this pattern, and therefore might be a monad. Is there a term for a monad which relocates side effects, like state updates/assignment or DOM renders, in much the same way that you relocate function calls and property accessors?
@sanketower
@sanketower 2 жыл бұрын
The best Monad explanation I've seen so far.
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad to hear that!!!
@leshommesdupilly
@leshommesdupilly Жыл бұрын
Wow, that was a very clear explanation ! Now I know how useful monads are. Unfortunately, I already forgot what they are.
@uselessDev
@uselessDev 7 ай бұрын
Most clear and concise explanation of monads that I've seen - amazing stuff
@thorodinson3929
@thorodinson3929 2 жыл бұрын
To the point, concise and clear explanation. Just what a developer needs.
@charleshughes1417
@charleshughes1417 2 жыл бұрын
This is the most comprehensible explanation of monads I've come across. Thanks.
@AByteofCode
@AByteofCode 2 жыл бұрын
That is very nice to hear :) You're welcome!
@RamiGB
@RamiGB 2 жыл бұрын
Being a functor or a monad doesn't matter you've done a brilliant video in a beautiful way that would hopefully inspire newer developers to be better, respect to you
@AByteofCode
@AByteofCode 2 жыл бұрын
Reading this gives me the happy :) Thank you for the kind words!
@ElliottParkinson
@ElliottParkinson 2 жыл бұрын
Insane quality of content for a channel so small. You've earned my subscription
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you! I'm glad you enjoyed this video that was uploaded to a 30 sub channel :)
@babyboie20
@babyboie20 2 жыл бұрын
Holy crap, this is super useful and a way of thinking that I haven’t thought of before. Nice work!
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad I could be helpful! Thanks for the kind words :)
@txzk26
@txzk26 Жыл бұрын
This is the most clear and intuitive explanation of monad I ever had. Thanks
@sunofabeach9424
@sunofabeach9424 Жыл бұрын
I love how monads are explained with such example that fights JS absurdity
@hello-world1
@hello-world1 Жыл бұрын
what is wrong with JS? In fact, it is in JS that this problem can be solved with using optional chaining which keep the code readable and debuggable at the same time.
@sunofabeach9424
@sunofabeach9424 Жыл бұрын
@@hello-world1 chaining is doable in every language that supports OOP. And don't get me started with JS wrongs...
@hello-world1
@hello-world1 Жыл бұрын
@@sunofabeach9424 not chaining, optional chaining meaning that if you put .. then the program won't throw if the prop can't be accessed. ok get started let's hear.
@sunofabeach9424
@sunofabeach9424 Жыл бұрын
​@@hello-world1 ah, I checked what this "?." does. The one thing it can do is just short-circ evaluation. While it is useful at times, it does not let you bind a callback function or manipulate the object this callback is attached to. It is not nearly as powerful as a monad. It's funny that this "?." serves one purpose - to make null-checks more compact, while nulls shouldn't be a thing in the first place
@SirSidi
@SirSidi Жыл бұрын
I love you. I was referred to a 12 mins video about monads, I watched all of it and I swear I had no idea what it was talking about. I got the clear idea of what monads are in 2 short minutes.
@AByteofCode
@AByteofCode Жыл бұрын
Glad to hear that!
@erin1569
@erin1569 2 жыл бұрын
I didn't expect such quality from a ~350 sub channel The sound got much better compared to older videos (I think you got a little bit more confident) I'll make sure to share your channel with some of my friends to help you grow :)
@AByteofCode
@AByteofCode 2 жыл бұрын
Hehe and I had 30 subs when I posted that video :) Also thanks for the kind words and help, I appreciate it!
@proloycodes
@proloycodes 2 жыл бұрын
almost 3k subs in just 4 days, so yeah this channel is gonna blow up
@AByteofCode
@AByteofCode 2 жыл бұрын
​@@proloycodes That would be a certified pog moment :) If my current growth rate continues for a week I'll be at 10k. In any case, I have a couple of videos planned out that I suspect might check the same boxes as monads do so that might be helpful too. As someone who was hoping for 100 subs by the end of the summer, all of this is absolutely insane!
@torarinvik4920
@torarinvik4920 2 жыл бұрын
Hands down the best explanation of Monads I have seen on youtube.
@AByteofCode
@AByteofCode 2 жыл бұрын
Ty for the kind words!
@torarinvik4920
@torarinvik4920 2 жыл бұрын
@@AByteofCode my pleasure!
@Jordan4Ibanez
@Jordan4Ibanez 2 жыл бұрын
You're a gem, my friend. Keep up the great work!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words!
@brqnet
@brqnet 2 жыл бұрын
I am glad that I found this channel, I love to learn something new like algorithms and complex information rather than seeing basic stuff and useless tutorials,. Keep it up man
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words :)
@TheonlyNonlethalninja
@TheonlyNonlethalninja 2 жыл бұрын
Much has improved from the last video! Personally I think mellow background music would help relieve any pauses and there's a rlly quiet but somewhat noticeable static noise when you're talking
@AByteofCode
@AByteofCode 2 жыл бұрын
Ty! Audio is a sharp corner I never seem to get right but someday...
@TheonlyNonlethalninja
@TheonlyNonlethalninja 2 жыл бұрын
@@AByteofCode it is hard personally I just upgraded to the blue yeti x it's $170 but has its own processing software and it's a night and day difference if you watch my C video compared to wifi
@AByteofCode
@AByteofCode 2 жыл бұрын
@@TheonlyNonlethalninja Oh lol I have a blue yeti, i should probably look up how to make it do better audio
@TheonlyNonlethalninja
@TheonlyNonlethalninja 2 жыл бұрын
@@AByteofCode oh then something is off lol should be an easy fix if you're using the blue yeti software while recording
@AByteofCode
@AByteofCode 2 жыл бұрын
@@TheonlyNonlethalninja That would seem to be the part I'm missing! I'll look into getting the blue yeti software I was not aware existed.
@flippert0
@flippert0 Жыл бұрын
Whoa, sifted through a lot of Haskell literature and was none the wiser. Thanks for the succinct explanation.
@AByteofCode
@AByteofCode Жыл бұрын
Glad it was helpful!
@noodle-eater
@noodle-eater 2 жыл бұрын
This is interesting first time hearing about monad, pretty interesting to try
@AByteofCode
@AByteofCode 2 жыл бұрын
Good luck with that! I'm glad I saved someone from spending 12 hours watching random youtube videos trying to understand lol
@CyperN077
@CyperN077 2 жыл бұрын
I absolutely love that your video is very readable. A lot of content creators make content that's unwatchable unless you're a freakin' eagle.
@AByteofCode
@AByteofCode 2 жыл бұрын
The benefit of spending a whole month on a single video :)
@Jebusankel
@Jebusankel 2 жыл бұрын
Doesn't a Monad also need a flatmap to collapse your nested Maybes down to one level?
@AByteofCode
@AByteofCode 2 жыл бұрын
Usually, in list monads, the bind method is called flatMap. If you're planning on nesting Maybes than you could change the "extra logic" to take care of it. Having a flatMap isn't required so I omitted it to not overcomplicate anything
@mskiptr
@mskiptr 2 жыл бұрын
Well, you can already do that with just bind: flatten : Monad m => m (m a) -> m a flatten x = bind x id -- This is the type of bind I assumed here: -- bind : Monad m => m a -> (a -> m b) -> m b id : a -> a id x = x
@AByteofCode
@AByteofCode 2 жыл бұрын
@@mskiptr You have a problem. You try explaining it with haskell. Now you have two problems :p I think this guy does javascript and is used to the monadic "bind" for lists being called flatMap, whereas the functorial "bind" for lists is just map.
@mskiptr
@mskiptr 2 жыл бұрын
lol alright, I'll try to explain it in JavaScript. If you have an _Array_ of _Arrays,_ you can flatten it to just one level with only a clever use of bind (which is the same as flatMap in this case) - no need for a special un-nesting function: [[0,1],[2,3]].flatMap(x => x) = [0,1,2,3] And it works the exact same way with _Maybe,_ as well as with anything else that properly implements its bind function.
@nonadqs
@nonadqs 2 жыл бұрын
Yes! This guy described a functor, flatMap would usually just be ".bind(x => x)", but it always return a new instance of the value instead just returning the function. You can think of a Functor as anything that implements ".map", like arrays, and monads are anything that implement flatMap. The Maybe interface here isn't powerful enough for implementing flatMap (at least not the functional one, you can do a unsafe trick with the value property).
@hannaandersson4476
@hannaandersson4476 2 жыл бұрын
The best explanation I've seen so far, yet by far the shortest too. Great work!
@nkiett3805
@nkiett3805 2 жыл бұрын
A star is born! Great content mate, the quality, time, clarity, visualizing are just so right. I rarely subscribe after watching a few vids (but given that you only have 4 at the moment 😉), but you got my sub. Keep up the awesome work mate!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words! I'll try my best lol
@jeremiahreilly9739
@jeremiahreilly9739 Жыл бұрын
Thank you. I still don't understand monads, but this is the very first video which gives me hope that I might understand monads one day.
@AByteofCode
@AByteofCode Жыл бұрын
You can do it :)
@carlospedroza2604
@carlospedroza2604 2 жыл бұрын
Loving all your videos! I'd love more about functional programming!
@AByteofCode
@AByteofCode 2 жыл бұрын
omg ty! I have a few other FP videos planned so stay tuned for those :D
@champion3176
@champion3176 2 жыл бұрын
You are an excellent instructor. I will stick with you.
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you!
@o_enamuel
@o_enamuel 2 жыл бұрын
0:02 5x5 = 15
@AByteofCode
@AByteofCode 2 жыл бұрын
I really messed up something that simple lmfaoo Great catch tho!
@redsunschan5321
@redsunschan5321 2 жыл бұрын
This video is more like a text book to teach how to make people subscribe in 2.5mins Informative, clear, interactive expression Instant subscribed
@AByteofCode
@AByteofCode 2 жыл бұрын
This comment is music to my ears! And considering the view to sub conversion rate I think you're right :)
@rchaykovskiy
@rchaykovskiy 2 жыл бұрын
0:38 Usually you wouldn‘t do it that way, you used nested if-statements which is ugly, instead use unnested guard-clauses : if (userObject == null) return null; let userFriends = userObject.friends if (userFriends == null) return null; let firstFriend = userFriends.first() if (firstFriend == null) return null; Instead of returning null you can also throw or if we‘re talking about WebAPI then return a JSON object containing error message or something like that
@AByteofCode
@AByteofCode 2 жыл бұрын
Shhhhh totally wasn't taking the worst way to do something to prove a point lmao. I'd thought of putting it like that and honestly if you don't have monads that's a pretty good way of doing it.
@daleryanaldover6545
@daleryanaldover6545 2 жыл бұрын
your content is fresh and I don't see this type of content anywhere else, subbed!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words and the sub! I'll try my best to keep the content going :)
@PavltheRobot
@PavltheRobot 2 жыл бұрын
Very valuable tutorial, concise and clear.
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words!
@ky3ow
@ky3ow 2 жыл бұрын
Actually the most understandable explanation and nearly the fastest, didn't expect that from such small channel, keep it up)
@AByteofCode
@AByteofCode 2 жыл бұрын
Fun fact I had 30 subs when I posted that video :) Thanks for the kind words, I'll definitively keep it up!
@randomguy8647
@randomguy8647 2 жыл бұрын
You're very underrated
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words!
@proloycodes
@proloycodes 2 жыл бұрын
agree
@Euquila
@Euquila 2 жыл бұрын
After years of visiting this topic, I finally get it. Thanks!
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad it helped! :)
@arisweedler4703
@arisweedler4703 Жыл бұрын
This is so incredible. So simple understandable and clear. Well done!!
@AByteofCode
@AByteofCode Жыл бұрын
Thanks for the kind words :)
@badmanjones179
@badmanjones179 2 жыл бұрын
this video is so good that im pissed. this concept is literally so simple and yet all the "explanations" existing online are like "hey buddy youre gonna need a computer philosophy degree for this" and then explain nothing. but like this + your clarifying comment make crystal clear sense. im so pissed. great work
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you!! The way I see it, monads are SO simple that the phd nerds think that if you don't understand, you're an idiot and so they use complicated examples. Another common pitfall is the whole "explain it in haskell" thing, where if you can understand haskell, you probably know monads already.
@muhammademirsyah8037
@muhammademirsyah8037 2 жыл бұрын
Wow the quality of this content is just unbelievable, keep it going
@AByteofCode
@AByteofCode 2 жыл бұрын
That is music to my ears! Thanks for the kind words!
@nomoredarts8918
@nomoredarts8918 Жыл бұрын
In 2 minutes you explain concept that everyone else can't explain in 20 minutes or more!
@hpph1744
@hpph1744 2 жыл бұрын
Best explaining Monad ever.
@AByteofCode
@AByteofCode 2 жыл бұрын
:) Thanks for the kind words!
@5cover
@5cover Жыл бұрын
God-tier explanation, extremely concise and easy to understand. Thank you!
@AByteofCode
@AByteofCode Жыл бұрын
Thanks for the kind words!!
@possumkeys
@possumkeys Жыл бұрын
Wow, such a short video but better than the 10 to 14 minute videos I've watched. Well done.
@AByteofCode
@AByteofCode Жыл бұрын
Thank you!
@69k_gold
@69k_gold Жыл бұрын
Very short and sweet explanation! I like how you explained concisely the reason to use monads and how they basically work
@AByteofCode
@AByteofCode Жыл бұрын
Glad it was helpful!
@YashKumar-it5fr
@YashKumar-it5fr 2 жыл бұрын
first channel that i subscried after only wathing one video . Amazing content.
@AByteofCode
@AByteofCode 2 жыл бұрын
Ayyyy glad to hear that and thanks for the kind words!
@anandpbgupta
@anandpbgupta 2 жыл бұрын
This is best explanation ever I got about Monad or Functor for that matter!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words!
@3_14pie
@3_14pie 7 ай бұрын
After watching this video again after months and others of countless explanations + category theory, I think I'm finally beginning to get it
@AByteofCode
@AByteofCode 7 ай бұрын
Glad to hear that!
@DiamondSaberYT
@DiamondSaberYT 8 күн бұрын
That’s basically Optional in Java. Love it! :D Nice explanation
@darwinschuppan8624
@darwinschuppan8624 Жыл бұрын
Not even 3 minutes, straight to the point and had me saying "oooohhhhh, no f*cking way it was this simple" at the end. 10/10 video
@AByteofCode
@AByteofCode Жыл бұрын
Thanks for the kind words!
@rebeccakeller4666
@rebeccakeller4666 2 жыл бұрын
Amazing. Thank you for explaining, so simply and concisely, what many many other videos and blogs have failed to get into my head
@AByteofCode
@AByteofCode 2 жыл бұрын
:) I am very happy to have been able to help!
@ChocolateMilkCultLeader
@ChocolateMilkCultLeader 2 жыл бұрын
Amazing content. Will share this with my NL audience. I'm sure you will blow up
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you my man!
@eboubaker3722
@eboubaker3722 2 жыл бұрын
Finallyyy i understood it, computerphile video was complicated for me, your small example was really easy to understand
@AByteofCode
@AByteofCode 2 жыл бұрын
The computerphile video was the first one I saw while researching the topic. I'm gonna go rewatch it see if it makes more sense now. It's a shame that video appears first under the search term monad when all it does is complicate things
@a8lg6p
@a8lg6p Жыл бұрын
This is the first explanation I've heard that makes sense.
@AByteofCode
@AByteofCode Жыл бұрын
:)
@aidenlilley1319
@aidenlilley1319 2 жыл бұрын
This is the best explanation I have ever heard thank you
@AByteofCode
@AByteofCode 2 жыл бұрын
Your welcome and thanks for the kind words!
@Dht1kna
@Dht1kna 2 жыл бұрын
Finally understood why I would want a monad
@MightyElemental
@MightyElemental Жыл бұрын
I studied haskell during my computer science degree, but this is the first time I've actually understood what a monad is.
@sophieAutumnMay
@sophieAutumnMay 2 жыл бұрын
Very good video; all killer, no filler.
@AByteofCode
@AByteofCode 2 жыл бұрын
Hehe that's the goal! Thanks for the kind words :)
@asimssheikh
@asimssheikh 2 жыл бұрын
Wow. Finally understood this concept. You have talent. Keep going.
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad to hear that :)
@rituchandra6325
@rituchandra6325 2 жыл бұрын
Such a simple and precise explanation... wow, 100% immediate sub, please keep up the nice work!
@AByteofCode
@AByteofCode 2 жыл бұрын
Will do! Glad you enjoyed :)
@johnphillips4659
@johnphillips4659 2 жыл бұрын
Very cool, much impressed! Glad to have found your channel.
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you! I'm also glad you found my channel :)
@thanatosor
@thanatosor 2 жыл бұрын
I would prefer how F# or ML way to explain this as “function composition”, for chaining functions together in a correct types order like a factory. Just that simple. In Rust, it use Option so most of time you need to unwrap, but it also can help compose functions with “.” Operator. Which is very convenient and less confusing to people.
@AByteofCode
@AByteofCode 2 жыл бұрын
I think for OOP users, the dot operator would be quite confusing. There are many ways to explain and the idea of function composition is a pretty good alternative, I mean, I was thinking of using that for this video but thought the pipeline idea would be more intuitive for my target audience of OOP devs
@thanatosor
@thanatosor 2 жыл бұрын
@@AByteofCode would be great if you gather all those languages and compare them in doing this feature. Fsharp, Ocaml, Haskell, Rust, Ruby, even JS … ha ha
@AByteofCode
@AByteofCode 2 жыл бұрын
@@thanatosor Hmm. Not sure what point we'd be trying to prove there. Monads, outside of complex stuff like Promises, aren't really suitable for anything OOP. I just used javascript in this video because my focus was on people just knowing what the word meant and using a language which actually uses monads would have added too much obscurity to be understandable
@thanatosor
@thanatosor 2 жыл бұрын
@@AByteofCode to my latest comment, it’s just my idea, since I tend to make the same thing in different languages. Nothing more to prove I guess. Not a big fan of JS but I admit that it’s everywhere now.
@AByteofCode
@AByteofCode 2 жыл бұрын
@@thanatosor Yeah I'm not a big fan of JS (python supremacy) just forced into using it by circumstance (and in videos because everyone knows it so nothing to explain). I guess it could be interesting to have a repertoire of what certain patterns look like in different languages, you're right.
@massimo8408
@massimo8408 Жыл бұрын
Wow, I have been developing for 7 years, and I did not know about this, very cool!
@AByteofCode
@AByteofCode Жыл бұрын
Learn something every day!
@amerjabar7825
@amerjabar7825 2 жыл бұрын
A really great video! I hope your success as a KZbinr comes soon.
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the optimism!
@pro100tom
@pro100tom 2 жыл бұрын
Thank you very much for the explanation. I've got a question. At 1:20 should it return "Maybe: with a null value instead of "this"?
@AByteofCode
@AByteofCode 2 жыл бұрын
That would also work, but in functional programming, the only requirement is not modifying existing data, so returning the current instance of the monad complies with the rules of FP. When "return this" appears, you already know "this" contains a null.
@commissarsydian4125
@commissarsydian4125 2 жыл бұрын
Dude, that was amazing. I would only recommend saving for a better audio setup but I trust that is a long term goal.
@AByteofCode
@AByteofCode 2 жыл бұрын
A better audio setup is more of a short term goal :) I literally just got monetized a few minutes ago and all of the revenue from that is gonna be going towards improving audio quality, until people stop complaining about it xD
@wojciechwilimowski985
@wojciechwilimowski985 Жыл бұрын
I've spent a few hours reading Mark Seemann's blog to first understand the concept, turns out I could have just watched a 3 minute youtube video instead 😂 Excellent
@AByteofCode
@AByteofCode Жыл бұрын
:D
@leonardobagi9353
@leonardobagi9353 2 жыл бұрын
Now yes, a decent quality video. Keep up the good work man!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks, will do!
@kieronkoh4230
@kieronkoh4230 2 жыл бұрын
Bro u gonna be big one day. Can't wait for more of such videos
@AByteofCode
@AByteofCode 2 жыл бұрын
That would be very cool. If you have any specific topics you'd be interested in, don't hesitate to tell me!
@vicnicius2009
@vicnicius2009 2 жыл бұрын
That video is awesome, congrats for the great content!
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you for the kind words!
@lilshoe1000
@lilshoe1000 2 жыл бұрын
So excited to see what comes next with ur channel, keep up the great work :)
@AByteofCode
@AByteofCode 2 жыл бұрын
What an interesting coincidence, I'm also excited to see what comes next!
@glenospace
@glenospace 2 жыл бұрын
Pretty great explanation. Thanks. Would love the video to be longer with more examples.
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you!! I have a monad video planned about the category theory definition and a massive functional programming one which'll mention a multitude of monads. But considering the success of the topic, I could definitively see myself make a dedicated video about a ton of different monad types.
@SrIgort
@SrIgort 2 жыл бұрын
Please continue posting these "How do X work/What is X", it's very interesting! :D
@AByteofCode
@AByteofCode 2 жыл бұрын
Will absolutely do! Any specific X's you'd wanna hear about?
@samgarg5228
@samgarg5228 2 жыл бұрын
So much info in ~3 minutes, great 🔥
@AByteofCode
@AByteofCode 2 жыл бұрын
Eyyyy :D
@Ben-cq4db
@Ben-cq4db Жыл бұрын
Subscribed at 12.7k! See you at a million in just a bit.
@AByteofCode
@AByteofCode Жыл бұрын
Thanks for the kind words!
@th34lch3m1st
@th34lch3m1st 2 жыл бұрын
Devastating synthesis, straight to the point. Subscribed.
@AByteofCode
@AByteofCode 2 жыл бұрын
Hearing that gives me the happy :)
@Sam-pn6gb
@Sam-pn6gb 2 жыл бұрын
Next big programming channel 💪
@AByteofCode
@AByteofCode 2 жыл бұрын
:D That'd be cool ngl
@cccccc864
@cccccc864 2 жыл бұрын
Great video. Easy to follow with beautiful graphics. Thanks. :)
@AByteofCode
@AByteofCode 2 жыл бұрын
Thanks for the kind words :) Glad you enjoyed!
@thatsalot3577
@thatsalot3577 2 жыл бұрын
Finally an actual explanation of a monad.
@AByteofCode
@AByteofCode 2 жыл бұрын
The ironic thing is the video is technically inaccurate, it describes the Endofunctor. For it to be a Monad, the function passed into .bind would need to return an instance of the Monad in question. Although, if you're not a functional programmer, the difference doesn't really matter and since noone knows the nuance, you can still use endofunctors and claim it to be a monad :p
@thatsalot3577
@thatsalot3577 2 жыл бұрын
@@AByteofCode nah I really didn't know much about monads I'm just a simple webdev who makes games in part time But that pattern looked much familiar to promises
@AByteofCode
@AByteofCode 2 жыл бұрын
​@@thatsalot3577 Turns out Javascript promises ARE monads! They were designed like that I believe.
@ExylonBotOfficial
@ExylonBotOfficial 2 жыл бұрын
This is the best explanation ever
@AByteofCode
@AByteofCode 2 жыл бұрын
Aww thank you!
@streetchronicles5693
@streetchronicles5693 2 жыл бұрын
strong, powerful, simple, great video
@AByteofCode
@AByteofCode 2 жыл бұрын
Thank you!
@loctite417
@loctite417 2 жыл бұрын
Love that this video isnt a 2 second video saying "a monad is just a monoid in the category of endofunctors" and actually explains the concept in a practical way
@AByteofCode
@AByteofCode 2 жыл бұрын
I love that video "what is a monad" where its just a robot reading all the different dictionary definitions and none of them make any sense whatsoever (even talking about non programming uses of monad)
@willd4686
@willd4686 2 жыл бұрын
Can the return value of the function passed to bind be a different type than the original value?
@AByteofCode
@AByteofCode 2 жыл бұрын
As far as I know, of course! What matters is the type of the box, not its contents :) Some hardcore functional programming fanatics might disagree but do what you see fit with the patterns you have!
@willd4686
@willd4686 2 жыл бұрын
@@AByteofCode That makes sense, thanks for the video. Its really helped my understanding
@avi12
@avi12 2 жыл бұрын
You just described Promises without using the word Promise Nicely done
@AByteofCode
@AByteofCode 2 жыл бұрын
:) Hehe true, Promises are Monads
@jonathanlalande3090
@jonathanlalande3090 2 жыл бұрын
Really good explanation for a 2:30 minutes video!
@AByteofCode
@AByteofCode 2 жыл бұрын
Glad to hear that! (Or is it a good explanation _because_ its 2:30 long and thus without bloat?)
@DreySF
@DreySF 2 жыл бұрын
I can only support what others are saying. Good content. You have my sub 😁. I love the fireship style and target audience.
@AByteofCode
@AByteofCode 2 жыл бұрын
Ty :D I'm glad you enjoy!
@noelgomile3675
@noelgomile3675 6 ай бұрын
In your JavaScript example, why didn't you make use of the null aware operator to safely access potentially null properties?
@AByteofCode
@AByteofCode 5 ай бұрын
I put the code in javascript since its very readable even to non javascript programmers, but you are right in that the null safety operator is better for this specific use case :)
@MatteoAntonyMistretta
@MatteoAntonyMistretta 2 жыл бұрын
Good explanation, although wouldn't this particular use case be solved by just wrapping the whole code block in a try-catch statement?
@AByteofCode
@AByteofCode 2 жыл бұрын
Lol, Spoken like a true non FP dev! I mean yes, that would do the trick. Personally, I like to avoid try catches if there is any other way of doing it. Also, that would work to handle this specific case, but if your "extra processing" becomes something a bit more complex, there won't be any easy solution like that.
@MatteoAntonyMistretta
@MatteoAntonyMistretta 2 жыл бұрын
@@AByteofCode well I am a functional programmer but monads is where I draw the line. Between an async function and a Promise I prefer an async function whenever I can. Also, creating a Maybe class sounds even less functional to me
@adicardrz
@adicardrz 2 жыл бұрын
Easy, to the point explanation, subbed, looking forward to new videos!
@AByteofCode
@AByteofCode 2 жыл бұрын
Ay thanks! Any specific topics you'd be interested in?
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 675 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
Caleb Pressley Shows TSA How It’s Done
0:28
Barstool Sports
Рет қаралды 60 МЛН
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 901 М.
What is a Monad? - The Last Monad Intro You'll Ever Need
15:48
走歪的工程師James
Рет қаралды 25 М.
The purest coding style, where bugs are near impossible
10:25
Coderized
Рет қаралды 1 МЛН
What is a Monad? - Computerphile
21:50
Computerphile
Рет қаралды 611 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,8 МЛН
What the Heck Are Monads?!
21:08
ArjanCodes
Рет қаралды 76 М.
Never install locally
5:45
Coderized
Рет қаралды 1,9 МЛН
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,8 МЛН
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН