Take cooking a meal example. OOP: organize your task as an interaction between different objects (cookware, ingredients, the cook) Procedural: break down your task into steps and complete it one step at a time (just like following the recipe) Functional: organize your task as actions you should take - cleaning, cutting, washing, frying etc.
Well done, best way to learn ANYTHING is to see alterntives! There is lots of videos on youtube teaching OOP or FP, but this video shows big picture, show difference. Thank you for that.
I literally specifically searched for this video because I felt like when teaching OOP people were assuming I understood what that meant and what the other options were.
I've heard a lot of people say that the object oriented is closest to how we think about the physical world and thus easiest to grasp, which is interesting to me, because it's been the hardest paradigm for me to grasp. I started out doing procedural, then functional, then object oriented. Even after learning OOP I still prefer functional, with just a little bit of object orientation. I like to organize my logic into functions and store data in struct objects
I think thats also the best way. Stateless functions for computation and mathematical transformations are very reusable. Instead of methods filled with self. Objects methods are useful to keep internal logic of the object in check. But only internal logic. Imagine the internal structure of an object is a tree-like structure of dictionaries and you want to have access to sub child elements. Insead of writing a loop exploring the dictionaries every time you need to access anything a method is very suitable to do just that. It is not atomic and it is only relevant to the internal structure of the object. Thus a method, instead of an odly specific function that will only be used on a single object type ever.
To me, the problem with OOP being compared to how we think of the physical world, is that programming problems are rarely comparable to the physical world. Religious use of OOP can make just about any problem unnecessarily difficult.
36:06: Throwing exceptions is also a side-effect. You could return an error value, here instead, to be handled by the caller. Often, this value is encoded as an either/or type with two cases: one for success and one for failure. The success case would be the constructed user object. The failure case could be a list of validation errors.
Isn't that achievable with the Null Object Pattern as well? If there is an error, a regular object is returned anyway, but it's kind of a prebuilt/null version of it.
Reminded me of my personal experience (I unknowingly taught myself in functional style): First time encountering procedural: what the actual f* is this unreadable abomination? Starting to work in a project where source was mostly in OOP: Can't wrap my head around this. This weird. Disclaimer: I got used to OOP very quickly, but personally I still prefer functional whenever possible, and mix it with OOP only when OO is really needed (or required)
Its funny because i used functional style since years (without even knowing its a special thing)... then i tried to switch to oop because everyone recommends it. didnt work with my mindset and i would have needed way more code. so didnt really made sense to my. feels good to be not alone xD
@@Mokota87 As a functional programmer who moved to OOP, i still can't remove this sense of embarassment everytime I'd create similar methods/logic for the same classes. Even when I create classes, its almost entirely dependent on function methods than being entity container. I just cringe when I use like entity classes for data, and interacting with that entity using methods. I solved this by using JSON for data and again, functions to get those data.
@@mikkorajakangas5303 I agree! OOP has its place, but people think that to program in it you have to make everything a class even when it logically makes no sense, so then your are forced into convoluted solutions to problems. OOP should be used, but only when applicable. Functional programming is easier to read and flows better, but a mix of both when appropriate is best.
spent 2 days learning and reading about different paradigms and this one video cleared all my doubts , resources like these are rare. Keep up the good work guys !
Great video, Max. I really like this kind of content. I'd like to add, that functional programming or (to be precise) pure functions make the code a lot easier to unit-test especially in comparison to the procedural style due to the lack of side effects. This is one of the biggest advantages in my eyes.
39:22 I believe this code is still more procedural than functional style. The idea of splitting the code into smaller pieces (call them functions, procedures, routines, methods, whatever) dates back to the late 60s and is the foundation of procedural style, not functional. Functional style is not about splitting the code, it's about composing the code from functions by using higher order funcions like apply, map, reduce, filter, compose, lift, fold etc. A very good discussion can be found here: stackoverflow.com/questions/5226055/truly-understanding-the-difference-between-procedural-and-functional?noredirect=1&lq=1
Call me a newb, I am not very familiar with the functional paradigm. I usually use OOP (more so with PHP) and procedural (more so with JS). Correct or not, I like how Max has outlined it. I will admit that I have used compound "higher order" functions on several occasions, but in a procedural context, and I was very happy with the resulting code. However, going by your example - does functional programming create an unnecessary dependency on the built in functions of a given language, producing less "universal" code and increasing overhead? From the SO conversations in the link you posted, the code does seem much more compact, though less readable (possibly requiring more planning or refactoring digressions?) , BUT I am not savvy on the difference in overhead when using these higher order functions or if they are generally universal in most languages.
@@dmlamarre1 What do you mean not universal? The built in higher order functions aren't that special, you can make new higher order functions so long as you can pass a function as an argument to another function. So for example in python you can just pass the function name without any brackets and then call it with brackets later in the function. It gets even better when using lambda functions where you don't even need a named function just input and some code.
I was looking for this comment because I didn't want to be the only one to say "but that's not what functional programming means." I must admit I didn't watch the whole thing because I disagreed at the start about how he described procedural vs functional. Procedural programming still uses functions, often heavily. The functional programming paradigm is something quite different and is based on lambda calculus.
The best video illustrating the differences. Your approach was the best out there that I could find. You did a great job of not picking sides too. Side effects. Not having them. I think that goal of fp is mistated by that paradigm. The only actual reason we program is in order *to achieve* side-effects. But let's do it black box-like, dry principle-wise, as cleanly as we can. That darn ui notification is needed. That file needs data and some fn somewhere needs to write to it. Functions of related functionalities belong in a code module or static class. And so we cross the fence and rightly put one leg into the OO side of the fence. Functions exist to provide some service so yes let's let them be specialized and flexible/reusable. I agree that we can and should merge fp with OO where "is-a" and "has-a" relationships exist. For goodness sake, we don't write code so that it cannot interact with the outside world. I've seen samples of fp code go too far in trying to not have side effects. Those examples are the new "spaghetti code" taking part of the blame off of "goto".
This is the best video I have found that has been able to make the whole concept behind OOP to make sense to me, thank you very much!!. To think this was 4 years ago
So Happy I found this video, I think The Odin Project needs to link this video in their course because this made so many things so much more clear to me. I will definitely come back to watch this a few more times.
Congratulations! FINALLY I found comparative examples of the exact same functionality, which seems to be missing from every other comparison between procedural and OOP that I've seen. And OOP is finally begining to make sense. But only beginning
Thanks Max, you made it real clear. I seem to have been writing a mix of procedural and functional style. I always believed that functions should get input through parameters explicitly in order to prevent bugs, which means I naturally inclined towards functional programming even though I didn't quite know what it actually was.
I never fully understood how functional code was structured. the concepts were really helpful, aint a javascript person but concepts transcend language. thanks
Finally someone who says it. JavaScript is object oriented at its core. You can just do OOP in three different ways........ to organize your logic. I'd also like to put forth that adding the class keyword supports hierarchical dependencies, which is a strong form of coupling and bad to do. API's built on classes can be very brittle because of this and why, even in classical OOP language circles they say, "Always take composition over inheritance." JavaScript, before the class keyword, was built to sort of unconsciously push developers to the composition before inheritance thinking with the object oriented functional (or procedural) paradigms. The class keyword is ok, as long as you understand the disadvantages hierarchical relationships can have and avoid the need to use "new" too much in your APIs. It's the same as avoiding constructor functions too much in API design in the functional realm. And this is just me blabbering some basics a lot of developers don't get, but it's all very true and important to good programming, in any language or logic structuring paradigms, especially in JavaScript. :D
Crystal clear explanation!!! You have a gift my friend. Thank you so much for doing this video. I could literally feel the clarity land on me as I watched this!
Thank you so much! I’ve been trying to wrap my head around this for the last few days! This video is right on time for me! And you broke it down so well!
My first contact with programming was a version of C used on PIC microcontrollers, then i switched to arduino, always used fuctions and was very intuitive for me, now i'm full on learn python and was curious about this "OOP" that people talk about but watching this video i was completely lost until you touched functional programing and then i got it immediately, so i think i'll stick with functions bc that's what it apears to work for me.
Very helpful! Thanks a lot for showing the alternatives and pointing out the main differences without favoring one way over the other. Really helped me get some things straight :)
Killing information. Thanks, Max. I just started learning javascript and this is the best information I can use to master both functional and OOP terms.
Wonderful info! This helped me so much. I like the approach you took with this lesson (not pushing one style or another with bias). I completely agree that whatever style works for you is the best way. I keep seeing a lot of people crapping on OOP, and instead only swear by functional programming or vice versa. I guess if it works for them, that's great. I do think however, it's important to recognize what style you're working with so, that you can understand what the other programmers code style was/is.
25:22 is a bit misleading. In procedural style, done the right way, you'd have a separate `validate` procedure that you could reuse anytime you like by simply calling it. There are numerous advantages of OOP style as compared to procedural, but avoiding code copy-paste IS NOT one of them.
I think a lot of the time projects will be made up of multiple programming styles anyway. In the early days I remember functional style is preferred over procedural style to promote reusability and reduce lines of code. The example used in this video, although promoted reusability, the number of lines in the functional style is significantly larger than the procedural style. However, it is a very good example to show the differences between the three styles which is the main purpose of this video. Thank you very much for the explanation.
This is a difficult example application for illustrating FP, because it's so side effect-y, but most of the functions in the FP code are impure. I think the only possible exception is `validate`, although even that relies on the globals. Max, would it be ok if I submitted a PR to your repo, to propose an alternate FP example?
Amazing video. thanks. made my mind overheat at a few parts to take in what was shown (even if the app itself was incredibly simple) you explained this very well. well done.
Great video! At times a bit too quick to follow on first attempt, but I'll attribute that to me still being a novice in JS. :) But the example app and the accompanying code examples are spot-on to explain the differences. I found the video very helpful, precisely what I was looking for. Thanks!!
Understanding the different programming paradigm types is one thing, learning to think and code like this is something else entirely. Not sure if I can think like that.
Hey great video! FN programming it's nice because it is focused on creating small pieces of code that can be composed together to create a more complex functionality
😎 I was searching for this type of video and your video came to me at the right time. And specially the examples helped me a lot in understanding the difference.😊 Thank you for explaining us so well about all the three programming styles.🥰👍
There was a time (and thankfully this is changing a little now) where academia was putting out computer scientists and engineers who had been taught that OOP "should be used to the exclusion of all else." We would hire young programmers, fresh out of university, who had almost no experience in procedural or functional programming. It is not at all the case that my company is against using OPP, which is fantastic for a great many problems. The thing is that when OOP is imposed on a problem that lends itself to a procedural or a functional solution, the development time is extended with the resulting code often being awkwardly artificial, making it hard to enhance, maintain and debug. A great many problems simply lend themselves to a functional or a procedural solution. I find this is especially true for a lot of programming that manages or simulates real world processes in manufacturing and business. Why did this happen? Why did academia steer this course for so long? I think is has something to do with OOP having arisen out of academia. A lot of the revolutionary ideas and technology in computer science had previously arisen out of the corporate world: companies like IBM or AT&T's Bell Labs, for example. No doubt, OPP is a revolutionary, but it should have been considered another tool for the toolset, not a tool to end all tools.
I really like functioanl style it's really easy to came back and copy a portion of some known to work, documented and small chunk of function to use in other project. I'm actively avoiding the lazyness by hardcoding something in, because sometime you just know this function will never be used again isn't a good way to write it.
My view on this: An event handler OnButtonClick() is procedural. It changes state all over the place. A statement like A.transform(B) used to be ambiguous. What is being transformed, A or B, or both? In the current functional era, you would hope that transform() only changes A and not B. Put differently, towards A, transform() is object-oriented, towards B it behaves functional. Together with event-driven programming and model-view separation, I just pick-and-choose whatever seems fit for the task at hand. As opposed to religious, I call this the opportunistic approach.
If you're building wordpress sites for your bros, don't be afraid to use procedural. Its the quickest method thats usually sufficient for modest websites. Consider more careful paradigms when you can tell that your tasks are going to be intricate and need to be reusable, otherwise you're making your code more complex for no benefit. That being said, its so much more fun to refactor out of procedural. Even when it makes your contract take longer.
Does anyone know the best pure object oriented programming language to get started with. I understand the basic ideas behind OOP but i want to think like an Object Oriented programmer. I want to be a good Typescript developer.
Well, if you want OOP and Typescript, then you can just do OOP with Typescript. If you want a language that kind of forces you to use OOP, static types, interfaces etc then C# and Java are good candidates. You can for example do backend or mobile development to master these languages.
20:37 Now you have this strange hierarchy though. The Validator class has no purpose if there is no class that has input. Visually from a birdeye view, you wouldn't know that - and that's my problem with it. I want to know how it works without having to look too close. I'd put it in another file with other helper classes maybe.
This shows how easy it is to make easy things complex to write and understand using oop. With oop you can easily introduce so many useless abstractions without even thinking about it that will make your code a nightmare to understand very fast if you don't pay attention. In this example, not only is the oop code twice as long than the procedural code, but even in this trivial example the oo-code is far more complex to understand even for someone that fully understands oop... and thank god you didn't introduce inheritance, etc. Oop has its own use, but it is not always a good choice. Procedural and functional code, more often than not, are a far better choice. Even if you write oo-code you need to restrain yourself from introducing too many abstractions or you will soon find yourself with a code that will be hard to understand even for yourself, let alone for others. Usually, the less code you write, the less abstractions you introduce, the easier it is to understand and maintain. Try always to find ways to make your code shorter and cleaner. The less code you write, the easier it is to understand, and fewer chances you have to introduce bugs. In this example, the whole validator class is completely useless for instance, what was done in a very straightforward way (a couple of very easy to understand ifs) now requires you to understand how this class works, why it exists and how to use it. And this is a short example... there are plenty of examples online where you can find thousands of lines of oo-code that, if written procedurally, would decrease by half or more. Search here on UA-cam the videos of Brian Will on oop to have an indepth analysis of the problems that oop tends to needlessly create if not used carefully and with a grain of salt and only when it actually makes things easier to understand.
There is also object-based programming. Object-based programming is like object-oriented programming but without inheritance. I prefer object-based programming since I'm not a fan of inheritance (though interfaces can occasionally be useful).
What is the best practice to select the DOM elements? I mean should we select them at the top of our file, or inside constructor functions? Thank you Max,
Very Clear but an extremely superficial view of these paradigms. The main idea of procedures is the idea if calling procedures. Procedures are implemented as subroutines and functions. In the "Procedural Paradigm", subroutines don't have a return value (null) and Functions have a return value. Both accept parameters or arguments and both can code as mutable or immutable. Enjoyed your video, you have a gift for teaching and presenting.
In the procedural example using ifs you naturally were able to give a different and more specific alert for password errors vs username errors. This got lost in the abstraction to OOP., and remained forgotten in FP. Not hard to implement but sometimes the super direct and linear approach of Procedural makes it easier to focus on what the user will experience rather than how 'clean' the code looks, or how clever its abstractions are. Also, in this case I think the Procedural example was the shortest, no? I was surprised expecting FP to be the mose concise.
Great Video. Can we get a line count on each style? It looks like OOP has twice as many lines as the other two. I agree, it is more intuitive to think in terms of OOP, however Functional sure does lend itself to simple and solid testing.
Max, can you please create a full course on Functional Programming Paradigm and how to utilizes it into project or over object oriented programming. Of course, in JS ♥️
Take cooking a meal example.
OOP: organize your task as an interaction between different objects (cookware, ingredients, the cook)
Procedural: break down your task into steps and complete it one step at a time (just like following the recipe)
Functional: organize your task as actions you should take - cleaning, cutting, washing, frying etc.
Well done, best way to learn ANYTHING is to see alterntives! There is lots of videos on youtube teaching OOP or FP, but this video shows big picture, show difference. Thank you for that.
I literally specifically searched for this video because I felt like when teaching OOP people were assuming I understood what that meant and what the other options were.
5:22 Procedural
12:01 Object-oriented
26:19 Functional
I've heard a lot of people say that the object oriented is closest to how we think about the physical world and thus easiest to grasp, which is interesting to me, because it's been the hardest paradigm for me to grasp. I started out doing procedural, then functional, then object oriented. Even after learning OOP I still prefer functional, with just a little bit of object orientation. I like to organize my logic into functions and store data in struct objects
I think thats also the best way. Stateless functions for computation and mathematical transformations are very reusable. Instead of methods filled with self.
Objects methods are useful to keep internal logic of the object in check. But only internal logic.
Imagine the internal structure of an object is a tree-like structure of dictionaries and you want to have access to sub child elements. Insead of writing a loop exploring the dictionaries every time you need to access anything a method is very suitable to do just that. It is not atomic and it is only relevant to the internal structure of the object. Thus a method, instead of an odly specific function that will only be used on a single object type ever.
FPOOP baby! 😂
To me, the problem with OOP being compared to how we think of the physical world, is that programming problems are rarely comparable to the physical world. Religious use of OOP can make just about any problem unnecessarily difficult.
36:06: Throwing exceptions is also a side-effect. You could return an error value, here instead, to be handled by the caller. Often, this value is encoded as an either/or type with two cases: one for success and one for failure. The success case would be the constructed user object. The failure case could be a list of validation errors.
Isn't that achievable with the Null Object Pattern as well? If there is an error, a regular object is returned anyway, but it's kind of a prebuilt/null version of it.
but isn't it the same thing if exceptions are catchable?
@@ivan0kurnia the exception causes your program to jump to the catch block where as an error value allows the program to continue normally.
Is that a Monad?
object-oriented style : 12:36
functional style : 25:49
I loved the way this class was structured comparing different programming paradigm styles.
From personal experience over years:
Procedural to OOP: why didn't i know this earlier?
OOP to Functional: this is the best thing ever!
good summary
Reminded me of my personal experience (I unknowingly taught myself in functional style):
First time encountering procedural: what the actual f* is this unreadable abomination?
Starting to work in a project where source was mostly in OOP: Can't wrap my head around this. This weird.
Disclaimer: I got used to OOP very quickly, but personally I still prefer functional whenever possible, and mix it with OOP only when OO is really needed (or required)
Its funny because i used functional style since years (without even knowing its a special thing)... then i tried to switch to oop because everyone recommends it. didnt work with my mindset and i would have needed way more code. so didnt really made sense to my. feels good to be not alone xD
@@Mokota87 As a functional programmer who moved to OOP, i still can't remove this sense of embarassment everytime I'd create similar methods/logic for the same classes.
Even when I create classes, its almost entirely dependent on function methods than being entity container. I just cringe when I use like entity classes for data, and interacting with that entity using methods. I solved this by using JSON for data and again, functions to get those data.
@@mikkorajakangas5303 I agree! OOP has its place, but people think that to program in it you have to make everything a class even when it logically makes no sense, so then your are forced into convoluted solutions to problems. OOP should be used, but only when applicable. Functional programming is easier to read and flows better, but a mix of both when appropriate is best.
spent 2 days learning and reading about different paradigms and this one video cleared all my doubts , resources like these are rare. Keep up the good work guys !
Best part of the video : "The code is writing itself" :))
Thank you. Great Video
Great video, Max. I really like this kind of content.
I'd like to add, that functional programming or (to be precise) pure functions make the code a lot easier to unit-test especially in comparison to the procedural style due to the lack of side effects. This is one of the biggest advantages in my eyes.
A beauty of well organized explanation + clear on everything + good hands in programming style.
So you earned my subscription :)
Thanks so much Devendra, great to have you on board!
39:22 I believe this code is still more procedural than functional style. The idea of splitting the code into smaller pieces (call them functions, procedures, routines, methods, whatever) dates back to the late 60s and is the foundation of procedural style, not functional. Functional style is not about splitting the code, it's about composing the code from functions by using higher order funcions like apply, map, reduce, filter, compose, lift, fold etc. A very good discussion can be found here: stackoverflow.com/questions/5226055/truly-understanding-the-difference-between-procedural-and-functional?noredirect=1&lq=1
Call me a newb, I am not very familiar with the functional paradigm. I usually use OOP (more so with PHP) and procedural (more so with JS). Correct or not, I like how Max has outlined it. I will admit that I have used compound "higher order" functions on several occasions, but in a procedural context, and I was very happy with the resulting code. However, going by your example - does functional programming create an unnecessary dependency on the built in functions of a given language, producing less "universal" code and increasing overhead? From the SO conversations in the link you posted, the code does seem much more compact, though less readable (possibly requiring more planning or refactoring digressions?) , BUT I am not savvy on the difference in overhead when using these higher order functions or if they are generally universal in most languages.
@@dmlamarre1 What do you mean not universal? The built in higher order functions aren't that special, you can make new higher order functions so long as you can pass a function as an argument to another function. So for example in python you can just pass the function name without any brackets and then call it with brackets later in the function. It gets even better when using lambda functions where you don't even need a named function just input and some code.
I was looking for this comment because I didn't want to be the only one to say "but that's not what functional programming means." I must admit I didn't watch the whole thing because I disagreed at the start about how he described procedural vs functional. Procedural programming still uses functions, often heavily. The functional programming paradigm is something quite different and is based on lambda calculus.
The best video illustrating the differences. Your approach was the best out there that I could find. You did a great job of not picking sides too. Side effects. Not having them. I think that goal of fp is mistated by that paradigm. The only actual reason we program is in order *to achieve* side-effects. But let's do it black box-like, dry principle-wise, as cleanly as we can. That darn ui notification is needed. That file needs data and some fn somewhere needs to write to it. Functions of related functionalities belong in a code module or static class. And so we cross the fence and rightly put one leg into the OO side of the fence. Functions exist to provide some service so yes let's let them be specialized and flexible/reusable. I agree that we can and should merge fp with OO where "is-a" and "has-a" relationships exist. For goodness sake, we don't write code so that it cannot interact with the outside world. I've seen samples of fp code go too far in trying to not have side effects. Those examples are the new "spaghetti code" taking part of the blame off of "goto".
This is the best video I have found that has been able to make the whole concept behind OOP to make sense to me, thank you very much!!. To think this was 4 years ago
So Happy I found this video, I think The Odin Project needs to link this video in their course because this made so many things so much more clear to me. I will definitely come back to watch this a few more times.
This is the best video I've watched on this paradigm topic. Showing all 3 in the same application just lets it sink. Thank you, boss.
Dude I love the way you code.
All 3 ways or.....
I cant think of a better compliment for them
Finally a video that shows and compares the different paradigms with real code!
Congratulations! FINALLY I found comparative examples of the exact same functionality, which seems to be missing from every other comparison between procedural and OOP that I've seen. And OOP is finally begining to make sense. But only beginning
finally an intro that makes some sense of functional programming.good job. i can see now how it would be useful for larger structures
so i am doing functional programming and i didnt realize lol , everything makes more sense now thanks Max !
Thanks Max, you made it real clear. I seem to have been writing a mix of procedural and functional style. I always believed that functions should get input through parameters explicitly in order to prevent bugs, which means I naturally inclined towards functional programming even though I didn't quite know what it actually was.
I never fully understood how functional code was structured. the concepts were really helpful, aint a javascript person but concepts transcend language. thanks
Finally someone who says it. JavaScript is object oriented at its core. You can just do OOP in three different ways........ to organize your logic. I'd also like to put forth that adding the class keyword supports hierarchical dependencies, which is a strong form of coupling and bad to do. API's built on classes can be very brittle because of this and why, even in classical OOP language circles they say, "Always take composition over inheritance." JavaScript, before the class keyword, was built to sort of unconsciously push developers to the composition before inheritance thinking with the object oriented functional (or procedural) paradigms. The class keyword is ok, as long as you understand the disadvantages hierarchical relationships can have and avoid the need to use "new" too much in your APIs. It's the same as avoiding constructor functions too much in API design in the functional realm. And this is just me blabbering some basics a lot of developers don't get, but it's all very true and important to good programming, in any language or logic structuring paradigms, especially in JavaScript. :D
That was a really good introduction to functional programming in comparison with the more widely used oop and procedural approaches. Thank you Max!
Crystal clear explanation!!! You have a gift my friend. Thank you so much for doing this video. I could literally feel the clarity land on me as I watched this!
How to good to hear your voice again after countless of your Udemy courses. Great explanation as always.
Thank you so much! I’ve been trying to wrap my head around this for the last few days! This video is right on time for me! And you broke it down so well!
this is a good and simple description of functional, procedural, and oop programming. thank you.
Well done Max! This is some pure German efficient teaching right here.
Max, your way to explain things is awesome and i like to watch all your tutorials.
My first contact with programming was a version of C used on PIC microcontrollers, then i switched to arduino, always used fuctions and was very intuitive for me, now i'm full on learn python and was curious about this "OOP" that people talk about but watching this video i was completely lost until you touched functional programing and then i got it immediately, so i think i'll stick with functions bc that's what it apears to work for me.
I had an intern once and I showed him Maximilian's videos. He went with the flow and started learning on his own :)
That's awesome to read, thank you for sharing this!
When the LEGENDARY Maximilian speaks, all pple MUST carefully listen! You are the best tutor ever!
I didn't see a whole video yet, but from first steps - is awesome. Thanks, Max!
One of the best videos I've seen on the subject. Simple and easy to follow
There are many different styles. But I really favor one in particular - Academind's videos style. Love your style :)
Absolutely great!
I was wondering about this for awhile, and this cleared everything.
Thanks.
Oop: put everything in objects, Functional: put everything in functions. Makes sense I guess.
procedural: put everything in procedures, but also functions cos why not
Very helpful! Thanks a lot for showing the alternatives and pointing out the main differences without favoring one way over the other. Really helped me get some things straight :)
Finally. I found really programming example after 5 videos. This is superTutorial.
Killing information. Thanks, Max. I just started learning javascript and this is the best information I can use to master both functional and OOP terms.
I have been trying to figure this out for about a year. I finally understand the comparison thnx so much
Wonderful info! This helped me so much. I like the approach you took with this lesson (not pushing one style or another with bias). I completely agree that whatever style works for you is the best way. I keep seeing a lot of people crapping on OOP, and instead only swear by functional programming or vice versa. I guess if it works for them, that's great. I do think however, it's important to recognize what style you're working with so, that you can understand what the other programmers code style was/is.
25:22 is a bit misleading. In procedural style, done the right way, you'd have a separate `validate` procedure that you could reuse anytime you like by simply calling it. There are numerous advantages of OOP style as compared to procedural, but avoiding code copy-paste IS NOT one of them.
Well, that would be a bit of a Functional - Procedural mix, not 100% procedural... and the video is about sticking to a paradigm as much as possible
I think a lot of the time projects will be made up of multiple programming styles anyway. In the early days I remember functional style is preferred over procedural style to promote reusability and reduce lines of code. The example used in this video, although promoted reusability, the number of lines in the functional style is significantly larger than the procedural style. However, it is a very good example to show the differences between the three styles which is the main purpose of this video. Thank you very much for the explanation.
This is a difficult example application for illustrating FP, because it's so side effect-y, but most of the functions in the FP code are impure. I think the only possible exception is `validate`, although even that relies on the globals. Max, would it be ok if I submitted a PR to your repo, to propose an alternate FP example?
Another great tutorial video from Max! Very concise and easy to follow.
Shouldn't you also pass 'document' as an argument to the connectForm function to keep it pure?
Thank you very much for this great tutorial.
It is very useful to watch 3 approaches with the same code .
Amazing video. thanks. made my mind overheat at a few parts to take in what was shown (even if the app itself was incredibly simple) you explained this very well. well done.
I like the way you explain all the things... 👍 Inspiring me to create my own in Bahasa Indonesia 🇮🇩 thank you
Great video! At times a bit too quick to follow on first attempt, but I'll attribute that to me still being a novice in JS. :) But the example app and the accompanying code examples are spot-on to explain the differences. I found the video very helpful, precisely what I was looking for. Thanks!!
How good are you now at JS?
I just started and I need me some motivation
Wish you all the best this holiday season
and throughout the year,
Merry Christmas!
Thank you Ontario, I also wish you a Merry Christmas!
Understanding the different programming paradigm types is one thing, learning to think and code like this is something else entirely. Not sure if I can think like that.
I love this video. I realized I already have this course from many years ago on udemy.
Can we mix all three programming paradigm to create a good software @academind?
:)
function thankMax(thanksMsg) {
console.log(thanksMsg);
}
thankMax('Max, you are awesome ;)');
Very clear illustration, appreciate it.
Hey great video! FN programming it's nice because it is focused on creating small pieces of code that can be composed together to create a more complex functionality
FP is obviously the best
this was the best video to explain the differences
😎 I was searching for this type of video and your video came to me at the right time. And specially the examples helped me a lot in understanding the difference.😊
Thank you for explaining us so well about all the three programming styles.🥰👍
This is the video / topic I was looking for
You are a good teacher.merry Christmas sir.🎉🎉🎊🎄🎄🎄🎄🎗️🎁🎁🎀🎀
Thank you Allan, Merry Christmas also to you!
a million thanks, exactly what i was looking for👌👌👌👌👌
Thanks. Always wanted to understand these terms.
Excellent video. Thanks for this. Subscribed as I have come across you a few times and always helped. :)
Awesome, thank you!
Best explanation on the web.
There was a time (and thankfully this is changing a little now) where academia was putting out computer scientists and engineers who had been taught that OOP "should be used to the exclusion of all else." We would hire young programmers, fresh out of university, who had almost no experience in procedural or functional programming. It is not at all the case that my company is against using OPP, which is fantastic for a great many problems. The thing is that when OOP is imposed on a problem that lends itself to a procedural or a functional solution, the development time is extended with the resulting code often being awkwardly artificial, making it hard to enhance, maintain and debug. A great many problems simply lend themselves to a functional or a procedural solution. I find this is especially true for a lot of programming that manages or simulates real world processes in manufacturing and business. Why did this happen? Why did academia steer this course for so long? I think is has something to do with OOP having arisen out of academia. A lot of the revolutionary ideas and technology in computer science had previously arisen out of the corporate world: companies like IBM or AT&T's Bell Labs, for example. No doubt, OPP is a revolutionary, but it should have been considered another tool for the toolset, not a tool to end all tools.
I really like functioanl style it's really easy to came back and copy a portion of some known to work, documented and small chunk of function to use in other project. I'm actively avoiding the lazyness by hardcoding something in, because sometime you just know this function will never be used again isn't a good way to write it.
This was very helpful. Thank you, Max.
I'm just thinking about the thing that I spend at least an hour per day with you here on yt or udemy 🤣
My view on this:
An event handler OnButtonClick() is procedural. It changes state all over the place. A statement like A.transform(B) used to be ambiguous. What is being transformed, A or B, or both? In the current functional era, you would hope that transform() only changes A and not B. Put differently, towards A, transform() is object-oriented, towards B it behaves functional. Together with event-driven programming and model-view separation, I just pick-and-choose whatever seems fit for the task at hand.
As opposed to religious, I call this the opportunistic approach.
Thanks Maximillian, very clear explanation!
If you're building wordpress sites for your bros, don't be afraid to use procedural. Its the quickest method thats usually sufficient for modest websites. Consider more careful paradigms when you can tell that your tasks are going to be intricate and need to be reusable, otherwise you're making your code more complex for no benefit.
That being said, its so much more fun to refactor out of procedural. Even when it makes your contract take longer.
Does anyone know the best pure object oriented programming language to get started with. I understand the basic ideas behind OOP but i want to think like an Object Oriented programmer. I want to be a good Typescript developer.
Well, if you want OOP and Typescript, then you can just do OOP with Typescript. If you want a language that kind of forces you to use OOP, static types, interfaces etc then C# and Java are good candidates. You can for example do backend or mobile development to master these languages.
20:37 Now you have this strange hierarchy though. The Validator class has no purpose if there is no class that has input. Visually from a birdeye view, you wouldn't know that - and that's my problem with it. I want to know how it works without having to look too close.
I'd put it in another file with other helper classes maybe.
This shows how easy it is to make easy things complex to write and understand using oop. With oop you can easily introduce so many useless abstractions without even thinking about it that will make your code a nightmare to understand very fast if you don't pay attention.
In this example, not only is the oop code twice as long than the procedural code, but even in this trivial example the oo-code is far more complex to understand even for someone that fully understands oop... and thank god you didn't introduce inheritance, etc.
Oop has its own use, but it is not always a good choice. Procedural and functional code, more often than not, are a far better choice.
Even if you write oo-code you need to restrain yourself from introducing too many abstractions or you will soon find yourself with a code that will be hard to understand even for yourself, let alone for others.
Usually, the less code you write, the less abstractions you introduce, the easier it is to understand and maintain. Try always to find ways to make your code shorter and cleaner. The less code you write, the easier it is to understand, and fewer chances you have to introduce bugs.
In this example, the whole validator class is completely useless for instance, what was done in a very straightforward way (a couple of very easy to understand ifs) now requires you to understand how this class works, why it exists and how to use it.
And this is a short example... there are plenty of examples online where you can find thousands of lines of oo-code that, if written procedurally, would decrease by half or more.
Search here on UA-cam the videos of Brian Will on oop to have an indepth analysis of the problems that oop tends to needlessly create if not used carefully and with a grain of salt and only when it actually makes things easier to understand.
Happy Christmas in advance to all and to you max...
Thank you, we also wish you a Merry Christmas!
You never disappoint, this is great!
In the oop example is this correct to hard code id’s into constructor? Shouldn’t it be passed upon instancing an object?
There is also object-based programming. Object-based programming is like object-oriented programming but without inheritance. I prefer object-based programming since I'm not a fan of inheritance (though interfaces can occasionally be useful).
Amazing 🤩 best one out there. Thank you
What is the best practice to select the DOM elements?
I mean should we select them at the top of our file, or inside constructor functions?
Thank you Max,
Wow I didn't think I'll like functional programming but it seems more natural and elegant
Really good and informative video. Thank you.
Very Clear but an extremely superficial view of these paradigms.
The main idea of procedures is the idea if calling procedures. Procedures are implemented as subroutines and functions. In the "Procedural Paradigm", subroutines don't have a return value (null) and Functions have a return value. Both accept parameters or arguments and both can code as mutable or immutable.
Enjoyed your video, you have a gift for teaching and presenting.
Thanks for the explanation, Max.
In the procedural example using ifs you naturally were able to give a different and more specific alert for password errors vs username errors. This got lost in the abstraction to OOP., and remained forgotten in FP. Not hard to implement but sometimes the super direct and linear approach of Procedural makes it easier to focus on what the user will experience rather than how 'clean' the code looks, or how clever its abstractions are. Also, in this case I think the Procedural example was the shortest, no? I was surprised expecting FP to be the mose concise.
What font family are you using in vscode?
33:25 that would be an impure function because it uses data from outside of the function scope.
This was a great introduction of these styles of coding. I am curious which one do you prefer, functional or OOP?
2:17 anyone answer please how to determine whether an singular entity can be a class?( eg product entities, shopping carts)
any singular entity can be in a class..The purpose of class is just to provide a blueprint and code reuse for the object
something which deserve like for sure
Thanks a lot Max!!! Is there any particular reason you did not use fat arrow functions => for your functional example??
Is the audio also behind for everyone else? Makes it hard to follow along.
Great Video. Can we get a line count on each style? It looks like OOP has twice as many lines as the other two. I agree, it is more intuitive to think in terms of OOP, however Functional sure does lend itself to simple and solid testing.
I am also finding functional and procedural much more comfortable, can you tell is OOP worth learning in javascript especially?
So i'm guessing you don't have all the code in one js file? wonder what the file structure would look like for each coding style.
Max, can you please create a full course on Functional Programming Paradigm and how to utilizes it into project or over object oriented programming. Of course, in JS ♥️