Object Oriented Programming vs Functional Programming

  Рет қаралды 764,457

Continuous Delivery

Continuous Delivery

Күн бұрын

Пікірлер
@mikefromwa
@mikefromwa 3 жыл бұрын
"Let's be clear, you can write crap code in any paradigm" I see you're familiar with my work...
@fleetingfootnotes9133
@fleetingfootnotes9133 3 жыл бұрын
...sounds like you're setting yourself up for a couple of copyright infringement lawsuits. :P
@Dschinny2004
@Dschinny2004 3 жыл бұрын
shut up both of you. he meant MY work!
@oldcountryman2795
@oldcountryman2795 3 жыл бұрын
The only thing that determines the “quality” of your code is how much you (or your employer 😉) can get paid for it.
@thegamingdemon4788
@thegamingdemon4788 3 жыл бұрын
Shut up all of you, he's talking about MINE.
@tommornini2470
@tommornini2470 3 жыл бұрын
I’ve been telling people for years that I want this written on my headstone: “It’s equally easy to write shitty code in all languages.” - Tom Mornini, 1999
@ke5uq1we8h
@ke5uq1we8h 3 жыл бұрын
"It's not about objects, it's about sending a message" :-)
@irok1
@irok1 3 жыл бұрын
Lol, nice
@badradish2116
@badradish2116 3 жыл бұрын
omfg winning
@cosmic53
@cosmic53 3 жыл бұрын
I think this is especially clear in Objective C. Messages are not method calls. The language is C with a smalltalkish layer upon, totally orthogonal to the language.
@edincanada
@edincanada 3 жыл бұрын
Understanding that OO is actually not about inheritance is an awesome moment of enlightenment I hope all programmers cherish reaching.
@ivanmoen9982
@ivanmoen9982 3 жыл бұрын
@@edincanada I don't have a lot of experience with OO programming(or programming in general), but for me using inheritance adds extra complexity for little to none benefit.. The way I see OO is kind of like c structs with methods that can act upon the data.. not sure if this is a reasonable approach, guess it depends on the language to use..
@travis1240
@travis1240 3 жыл бұрын
As for any dogmatic approach to software engineering, I'm over it. The best paradigm is what gets the job done with the least cognitive load. When you get too dogmatic about it you can pat yourself on the back but you will end up with less readable, less maintainable code and your successor will curse you.
@rameynoodles152
@rameynoodles152 3 жыл бұрын
Yeah, I mean, here's an idea that nobody seems to be having. Mix paradigms in your code, don't use just one, use them all when they make the most sense to use them. I dislike Java because it forces OOP. You don't need singletons in C++ because you can just "encapsulate" functions into a namespace, so it syntactically looks like OOP, but it's actually structured. EDIT: I meant to say procedural.
@ecpgieicg
@ecpgieicg 3 жыл бұрын
The best approach is the one that makes future usage, development, and identification of errors simple. Cognitive load on one day is nothing compared the long term cost arising from the unnecessary demand to reduce cognitive load on that day.
@pauligrossinoz
@pauligrossinoz 3 жыл бұрын
Yep! It's best to write your code while keeping in mind the effort required to understand it by the next person who has to read it. The first time I was told to rewrite code to make it simpler for the maintenance coders, I was pretty pissed because my code bloody worked! _Why should I rewrite something that works???_ 😮 But I was also very young and naive. Now, decades later, I'm totally on board with writing simple code to make the lives of the code maintenance staff easier. The simple fact is: If the maintenance coders can't reliably change the code, the system is never updated, and then it's pretty quickly replaced with something that they can actually handle.
@RBLevin
@RBLevin 3 жыл бұрын
Exactly.
@w41g87
@w41g87 3 жыл бұрын
But how do you decide which paradigm will induce less cognitive load beforehand?
@h4plugins334
@h4plugins334 3 жыл бұрын
"You can write crap code in ANY paradigm" - You been looking over my shoulder ? :)
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
🤣
@mike.hawk_
@mike.hawk_ 3 жыл бұрын
Non programmers: Oh programmers seem so smart, you have to be some kind of genius to understand code Programmers: Unga bunga OOP tribe sucks
@dexterantonio3070
@dexterantonio3070 3 жыл бұрын
Scala programmers: let’s make a functional programming language with four new styles of classes
@Megalomaniakaal
@Megalomaniakaal 3 жыл бұрын
@@dexterantonio3070 "Let us increase class struggle" Wait. Wrong topic, my bad...
@DudeWatIsThis
@DudeWatIsThis 3 жыл бұрын
Non-programmers: "I have 75 MBAs and get paid three billion dollars an hour. Scrum master, CEO, CEO, scrum master. What is a see-sharp? I am not concerned about the programming part, that gets itself done automatically. Sales are what matter." Programmers: "One more day driving to the office, where I will take it up the ass by someone with an IQ 20 points lower than myself, who gets paid 3 million times as much and takes my job for granted."
@janglestick
@janglestick 3 жыл бұрын
@@DudeWatIsThis C# is terrible only java is worse, but point taken
@janglestick
@janglestick 3 жыл бұрын
@@Megalomaniakaal lol Class struggle
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
It looks like I am going to have to fire my extensive team of copy editors 🤣 I am afraid that I made several typos in this video, and then missed them in my review before release. So here are the corrections, and I promise to try and do better in future. 4:09 It is "Edsger Dijkstra" not "Esgar" 4:25 "Constrains" not "Contrains" then I copy-pasted the same typo to 6:44, 7:09, 7:15 and then 7:48 - Doh! Last but not least (maybe not even last?) is the biggy, I mistyped the Scala code example! I usually prefer to copy a screen-snapshot of code to avoid this dumb kind of mistake, but thought that I would try something different for these simple examples - Lesson learned! 13:56 The Scala example should read: val x = someCollection.foldLeft(0)((y,c) => y + c.size) not val x = someCollection.foldLeft(0)(y,c) => c.size) No wonder it wasn't the clearer representation! Very sorry for these mistakes, but I hope that they don't detract too much from the ideas in the video.
@jalvrus
@jalvrus 3 жыл бұрын
I once gave a presentation on why copy-paste is evil, so seeing "contrains" pop up over and over made me chuckle.
@michaelmiller237
@michaelmiller237 3 жыл бұрын
Not typos, undocumented features.
@mayabartolabac
@mayabartolabac 3 жыл бұрын
Another correction: Haskell's sum function should be: sum :: [Int] -> Int sum [] = [] sum (n : ns) = n + sum ns
@dtkedtyjrtyj
@dtkedtyjrtyj 3 жыл бұрын
@@mayabartolabac That gives my brain a TypeError, shouldn't it be sum :: [Int] -> Int sum [] = 0 sum (n : ns) = n + sum ns ?
@mayabartolabac
@mayabartolabac 3 жыл бұрын
@@dtkedtyjrtyj ooooohhhhh right thanks for letting me know
@ducodarling
@ducodarling 3 жыл бұрын
I feel like I'm in programmer church, listening to a sermon
@TaylorIserman
@TaylorIserman 3 жыл бұрын
That’s super accurate actually
@davem.8681
@davem.8681 3 жыл бұрын
Duco Darling Speaking of sermons, I believe that object oriented programming is one of the great deceptions.
@vladimirljubopytnov5193
@vladimirljubopytnov5193 3 жыл бұрын
I felt a bit wtf when I heard the ironic "I rest my case" to that short, concise and totally beautiful sum definition :). How is FP bad for modelling here when most OO languages miss half of expressive power by not supporting union types? How are we not "guided in our analysis by the problem" in FP or how is this guidance only bestowed on OO guys? Recursion is very readable, because it closely models decomposition of a problem into smaller problems, thats why its in most books before any mention of OO. Moreover, it a bridge between FP and structured world. I don't think FP folks are motivated by some hatred of OO to point out its flaws, but I think it's no coincidence, that a lot of good practices in OO are also very much FP practices (composition over inheritance, SOLID). And I say that as an everyday java guy, so I'd like to stay out of any strict labelling.
@flightrisk7566
@flightrisk7566 3 жыл бұрын
@@vladimirljubopytnov5193 rebased edit: and f-pilled
@ironmagma
@ironmagma 3 жыл бұрын
@@flightrisk7566 f-pilled 😂😂😂😂😂😂 I'm going to start using that ASAP
@Mark73
@Mark73 3 жыл бұрын
"We've identified all the paradigms that there are to find" Reminds me of that legislator around 1900 that wanted to shut down the patent office because "everything has already been invented".
@dialecticalmonist3405
@dialecticalmonist3405 3 жыл бұрын
That's worse than saying, "We've identified all the patterns that there are to find." People don't give complexity enough credit.
@murraynatkie7490
@murraynatkie7490 3 жыл бұрын
That sounds like a story worth telling. Thanks for the rabbit hole. EDIT: oh, its a myth.
@ricosrealm
@ricosrealm 3 жыл бұрын
640kb is all the memory anyone would need
@imrematajz1624
@imrematajz1624 3 жыл бұрын
Good that they didn't, as Einstein would have not been hired and could have not been so bored that he started to wonder about why time was so relative...
@AtlantaTerry
@AtlantaTerry 3 жыл бұрын
@@imrematajz1624 Wrong patent office. Einstein worked in one in Europe. The one that was to be shut down was in Washington, DC.
@Pedro5antos_
@Pedro5antos_ 3 жыл бұрын
10:54 "let's be clear, you can write crap code in any paradigm!"
@aloisxyz
@aloisxyz 3 жыл бұрын
but particularly in oo
@axea4554
@axea4554 3 жыл бұрын
Nice, then I can just pick any paradigm
@jamesgg9950
@jamesgg9950 3 жыл бұрын
But the real question is: is the number of paradigms in which one can write crap code equal to the number of paradigms in which one can write good code? And is that question best phrased in OOP or functional code?
@lyingcat9022
@lyingcat9022 3 жыл бұрын
I can confirm this statement.
@neon13x
@neon13x 3 жыл бұрын
I write crap code and I can confirm this.
@ianollmann9393
@ianollmann9393 2 жыл бұрын
Appreciate the experienced perspective. For those of us who cut our teeth on “anything goes” languages, it is more intuitive that different approaches work better for different problems, and a one-constraint-fits-all design ties your hands unnecessarily in very painful and unconstructive ways at times that do not benefit the end product.
@sryx
@sryx 3 жыл бұрын
I wrote software for years before finally starting to actually study coding paradigms. The personal breakthroughs in my journey really began once I read The Little Schemer. It made me go back and see how much complexity I had created because I didn't understand recursion. It also radically changed the way I wrote code in all kinds of languages.
@pawel7196
@pawel7196 3 жыл бұрын
I think coding for so long gave you understanding so that you can see where you can improve. I started learning JS and a few weeks later been introduced to OOP not having a proper base knowledge. This lead to confusion and a year after I still don't know if I'm functional or OOP programmer which is embarrassing.
@lamcho00
@lamcho00 3 жыл бұрын
@@pawel7196 JS is a prototyping language. Only it's recent version started supporting Classes and even now those classes are really prototypes underneath. Prototypes are very similar to Classes and objects (in OOP), you should read more about it. That said I still don't like programming in JS. Unless you follow some unwritten rules, the code you write is very hard to read and understand afterwards.
@rubiskelter
@rubiskelter 3 жыл бұрын
@@pawel7196 Javascript is a weird language, very malleable but weird indeed . You should go with typescript. And, what do you mean you're a functional or OOP programmer? as Iamcho00 pointed out, you can use prototyping to maskerade as classes. But, you've definitely never programmed anything under the functional paradigm. You're confusing things, maybe you should read about it. Languages like Lisp and Haskell, are functional. Haskell has the pure implementation of functional paradigm, or almost pure, if you don't include IO. You can program following functional paradigm practices, using javascript, but i can guarantee you that you didn't do that. Functional programming is all about not using changing-state and mutable data, which most programmers do using imperative or OOP paradigms.
@pmarreck
@pmarreck 3 жыл бұрын
wait… You wrote software for years without understanding recursion? Yeesh
@caseyhawthorne7138
@caseyhawthorne7138 3 жыл бұрын
@@pmarreck That was a bit loopy 🖖
@user-hk3ej4hk7m
@user-hk3ej4hk7m 3 жыл бұрын
The thing I envy about fp languages is the expressiveness of their type system. Function composition, partial application, mappings are all impossible to implement without abusing the type system with most programming languages, even though using these constructs is extremely easy to do: f(g(x)), f(a, b, c), out[i]=f(in[i]). This lack of expressiveness is really what makes me think "I really wish I could write this in Haskell".
@evanwilliams2048
@evanwilliams2048 3 жыл бұрын
Yeah, the niceness is like an optimisation that is possible because of the lack of side effects.
@rhbvkleef
@rhbvkleef 3 жыл бұрын
You essentially described Erlang with that message passing example.
@gregbigwood4532
@gregbigwood4532 3 жыл бұрын
yeah its the Actor model which is a great way to code. can be hard to debug what happened in your system though the performance gains are great.
@nwoDekaTsyawlA
@nwoDekaTsyawlA 3 жыл бұрын
I only managed to write a "hello world" example in Erlang, but I definitely got that vibe too.
@HansTheGeek
@HansTheGeek 3 жыл бұрын
@@nwoDekaTsyawlA Try elixir it is a “modern” erlang and it is great
@JohnDavidDunlap
@JohnDavidDunlap 3 жыл бұрын
Erlang/Elixir also fit his criticism about copying values to maintain immutability. It's not that it's bad per say but it does come at a cost.
@HansTheGeek
@HansTheGeek 3 жыл бұрын
@@JohnDavidDunlap that’s right. On the other hand how should the suggested system work without copying?
@marcosdiez7263
@marcosdiez7263 2 жыл бұрын
I coordinated a public Logo workshop in the early 90's that ran for 4 years with about 30k attendants, in which we tried to verify Seymour Pappert's theoretical approach. Logo was devised as a learning system in which the screen were used to reflect the way we think about the world around us and the problems we try to model and solve, bringing awareness of Jean Piaget's genetic epistemology (the process that generates our knowledge). The language was devised as a way to implement this learning/researching system, and a key concept for this was the "sintonicity" property: the language should be as closest as possible as the way you express your thoughts to minimize the interference of the translation effort between your own natural language and the computational one, hence one of its features was that the primitive instructions were translated to the final user's language (you had Logo in English, in Swedish, in Spanish, we even contributed to translate it to Quechua). Logo was a functional language, initially a LISP shell (you had lists to manage data and it heavily resourced on recursion). As to be allowed to proof Pappert's ideas that challenged Piaget's ones regarding the immutability of the order of concepts children learns at early ages to understand spatial concepts, the turtle was used, either a robot able to move drawing lines like a kid does following instructions a kid can formulate (move forward 10 steps, turn right 90 degrees) and reproduce, or a triangle drawing in the screen. The thing is, Logo succeeded in this "sintonicity" property when drawing graphics for the programmer could do by themselves exactly the same the turtle would and understand where their ideas on how to solve a problem divert from the reality, but then failed misserabily to provide a similar sintonicity to manage pure abstract data because lists and its operators weren't a natural way to think and arrange data. Now, there's an article in Scientific American from 1971 that described Smalltalk as an attempt to address this very issue and find a more "sintonic" way to deal with the data. Back then the language didn't implement inheritance (it would appear in Smalltalk '80), but just the idea of messages being sent back and forth between entities that "learned to do things" by following the same principles from Logo. The entities were initially turtles instantiated and addressable by a given name, which could "learn" about data. So you'd create a turtle called Paul and tell it (sending a message) to learn that "age" was "12", you would teach the turtle (a new function or method) how to do some math, and you could ask for the "age" or to do the taught math and return the answer. Eventually you'd create another turtle Susan and would teach it how to ask Paul for the "age" or for it math to do something more complex and either return or act accordingly to the answer. Hence the name "small talk". The concept has proven so sintonic that it evolved into OOP paradigm as seen nowadays: having turtles that managed data but didn't appear on screen to draw stuff didn't make sense, and addressing every entity as a turtle got in the way of the sintonicity, hence in Smalltalk '80 inheritance appeared defining a basic object from which other entities inherited its "knowledge" (of how to answer to certain messages) and the turtles became objects specialized in drawing stuff on screen. Hence, there was a path connecting functional languages (LISP and Logo) to OO ones (Smalltalk) with the explicit goal of allowing us to represent our ideas of the world "sintonically", e.g in our own terms instead of the ones sufficing the computer requirements, which in turn determine how "expressive" a language is to model certain kinds of ideas.
@sunshinelizard1
@sunshinelizard1 3 жыл бұрын
One plus of functional programming is the ease of writing tests against the functions. Work in Clojure for a while honed my attention to the testability of any code I write, so I got better at writing smaller functions.
@D4no00
@D4no00 Жыл бұрын
@MP-mx9nf that is absolutely not true. Read about managed side effects feature that most of the functional languages and newer languages like rust have and you will understand why inherently writing tests in current OOP languages like java,c# will be harder and more error-prone.
@TinBryn
@TinBryn 3 жыл бұрын
That paradigm you explained at the end about multiple modules sending data between each other and otherwise being single threaded is pretty much exactly Communicating Sequential Processes (CSP) as described by Tony Hoare in 1978, and published in a book in 1985.
@AdobadoFantastico
@AdobadoFantastico 3 жыл бұрын
Nothing new under the sun! I'll have to add it to my reading list, sounds interesting.
@TigercatDesigns
@TigercatDesigns 2 жыл бұрын
That's pretty much exactly what I do with socketpair(), fork(), exec() and select() on Posix systems. I hate threads for anything other than, say, matrix manipulation or other such tasks where no signals need to be sent other than start_thread and thread_ended. So why has CSP never been widely implemented, while threads seem to be everwhere? IMO it's because the dominant OS, Windows, makes launching new processes painful and expensive, and has poor inter-process communications.
@benjaminscherrey2479
@benjaminscherrey2479 2 жыл бұрын
@@TigercatDesigns CSP is what go-lang uses. However, CSP is basically a somewhat broken version of the Actor model of concurrency. CSP is based on lambda calculus but Actor is based on physics in that it is capable of representing unbounded nondeterminism which lambda calculus cannot. Most famous example of the Actor model is Erlang which was designed to implement high availability high concurrency telephone switch operations. It's truly remarkable and about to undergo a Renaissance I think.
@TigercatDesigns
@TigercatDesigns 2 жыл бұрын
@@benjaminscherrey2479 Thanks for that! I've never come across the Actor model before in any of my design pattern books, although I have heard of Erlang. Looking at the Actor model stuff online, I agree it could/should undergo a Renaissance.
@fburton8
@fburton8 3 жыл бұрын
The mistake is to believe a single paradigm is the best approach to solving all problems.
@vitalyromas6752
@vitalyromas6752 3 жыл бұрын
@@LegendLength Scratch?
@eduarddumitru1
@eduarddumitru1 3 жыл бұрын
@@LegendLength i worry about dealing with merge conflicts / viewing a diff between version A of such a visual creation and version B
@berylliosis5250
@berylliosis5250 3 жыл бұрын
I strongly disagree with a notion of a perfect language. There's just too much complexity. It's impossible to get everything you might want in a single language - in some cases, it's mathematically impossible. Also, please don't let it be a visual language. Those have all the design problems of regular languages, plus a million more introduced by the difficulty of mapping things to visual elements. There's a reason all existing visual language are either incredibly simple or "regular programming but you use unwieldy blocks instead of easy typing"
@digitig
@digitig 3 жыл бұрын
@@LegendLength I don't think there's an "ultimate" programming language, because all languages involve tradeoffs and different tasks require different tradeoffs. A real-time safety-critical system needs a language that is highly amenable to verification and validation and that supports a time-deterministic runtime (so no automatic garbage collection - and possibly no dynamic heap storage to *need* garbage collection). I usually see that done in a subset of Ada. But the program I needed to parse texts marked up in XML to determine linguistic characteristics of the text (in an academic context) had no such constraints; it didn't matter if it took a couple of minutes to produce results, testing gave adequate-for-the-purpose confidence in correctness, but I needed it soon, and cheap (in terms of my own time) so I used Python. I don't see how a language can enforce the constraints of the former and still allow the flexibility of the latter.
@digitig
@digitig 3 жыл бұрын
@@LegendLength If you depend on different back ends for GC and non-gc, you're getting into a world of pain with libraries - do they depend on GC or not? does the compiler protect you from calling a GC library from non-GC code? And do you have to go through all the detail of smart pointers, if it's going to be garbage collected anyway? Does the compiler protect you from using simple pointers if there's no GC? And other differences I mentioned - there's a reason bondage-and-discipline languages are preferred for safety-critical systems, because they force progammers to express their intent in more detail, which is known to reduce bugs. Do we enforce that on non-critical scripts, or do we make it a language feature that can be turned on and off? Hmm, it's starting to look like multiple languages, isn't it?
@mattiasmartens9972
@mattiasmartens9972 3 жыл бұрын
I know that OOP encompasses a wide range of languages, so my initial reaction might be misplaced here. But you did mention Java, and it is striking to me just how much my experience with it was the opposite of "bringing me closer to the problem" as opposed to functional programming. The core idea of functional programming to me is composition. Because the functions are pure, you do not have to orchestrate them in a way that takes into account their side effects (as you would e.g. with imperatively creating a connection, imperatively committing it to a pool, imperatively checking if it is still open, imperatively disposing of it, etc). If a function does something in one context, you have a guarantee that it will do that exact same thing in any other context, which ultimately makes it cognitively cheaper to think on much higher levels of abstraction. Maybe Java wins in the loop-sum example, but looking at it gave me flashbacks to the nightmares I created in the early days, summing various quantities simultaneously in inner and outer loops and trying to keep them all in sync. The imperative approach is not clearer here. Had I learned to express what I was doing in a functional style, the odds are good that I would have escaped that quagmire much faster (and maybe even realized that what I was doing was not actually necessary for the program). I've heard it said before that object oriented programs let you use objects to model a problem. In my experience that has been a false promise. Objects create a layer in between you and the problem. Almost universally in programming, the problem is in the data: some input has to be turned into output. Functional programming is not short of ways to model that data and define transformations on it. What it avoids doing is handing the data off to a sovereign domain of control that might mutate it according to its own opaque rules. When functional programming works, it works because it links the program's input to its output in an unbroken chain. I have never seen anything comparable actually achieved in a Java program. When it comes to polymorphism, it seems like this potential strength of OOP is unavoidably tied to what I see as its greatest weakness, which is that objects are opaque to the caller of a method. If one is careful with side effects, I do see how polymorphism can help build reusable code. I'll just add that many functional programming languages use duck typing to accomplish the same thing. Instead of defining a class or interface that future implementations must extend, one defines the contract of a function in terms of what is true of its type. In this system, things can interoperate by virtue of their common traits, regardless of whether they share the same explicit interface or abstract class. Of course this idea does have its drawbacks as well.
@oliver_twistor
@oliver_twistor 3 жыл бұрын
Ideally, interfaces in OO languages such as Java shouldn't be huge lists of things that needs to be implemented. When I'm creating interfaces in Java, I try to make them as small as possible, preferably a single method. Since classes in Java can implement more than one interface, and by having very small interfaces, you can come close to duck typing. You don't have to worry that a particular interface is implemented together with 20 other interfaces in one class, you're only interested in a tiny portion of a class' implementation.
@thestemgamer3346
@thestemgamer3346 2 жыл бұрын
You don't need duck typing to achieve polymorphism. Just generics and typeclasses.
@gustavoandrade58
@gustavoandrade58 2 жыл бұрын
Oh man, this functional folks always use the bad examples of other things to show their point... It is PERFECTLY possible to work with composition using OO paradigm avoiding bloated inheritance. It is PERFECTLY possible to work with functional programming and OO at the same time. Just use the best of both worlds, it seems people have the NEED to be in a "club" and talk shit about other "clubs". I still remember the early Ruby days, where every Ruby programmer felt like they were in the higher ground, talking shit about java, php, etc... and that ruby was the best language. And now, is dying... Not because is bad but rather because competition is fierce and new generations have new tastes. So please, step down from that ivory tower because things change, and change fast.
@mattiasmartens9972
@mattiasmartens9972 2 жыл бұрын
@@gustavoandrade58 I am a Typescript programmer.
@simonpettersson6788
@simonpettersson6788 2 жыл бұрын
Polymorphism is widely used in functional languages too, i.e. type classes in Haskell and row polymorphism in Elm.
@magiclover9346
@magiclover9346 2 жыл бұрын
Even with a few errors a very articulate argument and well presented. I often find myself borrowing from both philosophies. Especially the immutability approach of functional when dealing with multi threaded or async systems. Following functional guidelines can also help when designing slim micro services, which in the current landscape of cloud focused computing is a bonus. However I also like the encapsulation and polymorphism concepts of OO. When it comes to data persistence I've always found it easier to think of it from an OO stand point.
@Aegon1995
@Aegon1995 Жыл бұрын
👍🏿
@hoi-polloi1863
@hoi-polloi1863 21 күн бұрын
Not sure this is germane, but I've found that when working OO I almost never use inheritance polymorphism anymore; it's almost always implementing interfaces.
@onthecodeagain
@onthecodeagain 3 жыл бұрын
Keeping code readable + maintainable to me is the hardest part no matter if you're using oop / functional paradigm. Good and bad code can be written in either they just help you out in different areas :)
@sipanmohammed
@sipanmohammed 2 жыл бұрын
there are many problems: dead line , time to market ...etc.
@claudiubele4892
@claudiubele4892 Жыл бұрын
the more you do the more you learn because you are the one writing your own projects
@jonbezeau3124
@jonbezeau3124 Жыл бұрын
Human readers are terrible code interpreters. They can only track about 7 items at a time, values and program flow can go out of scope for no reason, etc. So it helps for coding style to target the weakest architecture that will read it, other coders, in order to at least maintain correctness.
@paulkanja
@paulkanja Жыл бұрын
"...part oo, part functional, part structured..." JavaScript: "Someone said my name?"
@kikoyz
@kikoyz Жыл бұрын
@@paulkanja the only thing 'functional' about javascript is it uses functions. 😁
@nathanarnold7661
@nathanarnold7661 3 жыл бұрын
I write with a mix of paradigms these days, where the deciding factor is usually readability. Most of the time, that's functional. I don't think the FP examples in this video were fairly chosen. Good functional code does not need to be so cryptic, but I do agree that it requires understanding some different concepts. I'd like to share and resonate the point that you can obtain the benefits of either paradigm in any language (or almost any) with some discipline, and this is why it's a good idea to learn both. I'm sure this extends to other paradigms as well.
@markdewey6788
@markdewey6788 2 жыл бұрын
This is where I'm at as well. After spending the first half of my career deeply plumbing the depths of OOP and trying to be a purist there, I got a job where I spent a lot of time with Clojure. I can't overstate how much driving into the functional paradigm and writing with a functional language was a game changer. These days I mostly write in python where I do what Dave mentioned, I chose my constraints based on the problem. Some things are best done as objects, some in a functional style. Python lets me do both, but has more support for making classes and objects.
@breadman5048
@breadman5048 2 жыл бұрын
@@markdewey6788 how long did it take for you to learn FP? And how long to really appreciate the concepts
@markdewey6788
@markdewey6788 2 жыл бұрын
@@breadman5048 6 months to a year? It's not that different from learning a new language. You get proficient in just a few months of study and practice, then keep ramping up as you go.
@jeremiroivas1628
@jeremiroivas1628 Жыл бұрын
I find oo much easier to read, compnentdidmount is easier understand than usereffect... componentdidunmount is way easier to read than another usereffect... To me only more readable in functional is this. -writes. In functional you dont need to refer this.variable or function. How ever setting state is much more readable just write inside class: state = {yourAge: 36, yourStyle: blonde} where in functional you have to define each states by separate assignments. OO is way easier to read. Another topic is OO constructor but there is a way to simulate constructor in functional but again it looks like HACK and way much more harder to read.
@tullochgorum6323
@tullochgorum6323 Жыл бұрын
In particular I'd dispute his point that functional programming isn't suited to intuitive modelling. Reading Scott Wlaschin's excellent book Domain Driven Modelling Made Functional opened my eyes to the potential of powerful FP type systems for expressing practical line-of-business domains.
@rcrawford42
@rcrawford42 3 жыл бұрын
The hardest part of reactive programming is convincing management, especially those who were once developers.
@ZigzauerLT
@ZigzauerLT 3 жыл бұрын
and they are not always wrong :)
@parlor3115
@parlor3115 3 жыл бұрын
@@ZigzauerLT Management who were once developers are actually the worse because they think they know sh*t. Often times they weren't even good developers and even if they were, most of their knowledge is now outdated and/or misplaced.
@chudchadanstud
@chudchadanstud 3 жыл бұрын
@@parlor3115 lol but they're not wrong. You're young and have no experience. When I grew in my experience I'm discovering that they're more right than wrong.
@nikitaproit
@nikitaproit 3 жыл бұрын
on the frontend, the hardest part is convincing people that reactivity isn't always good =)
@brooksfire9580
@brooksfire9580 3 жыл бұрын
​@@parlor3115 You're a very naive grasshopper. Programming concepts have not changed much over the past 30 years. The names of things have changed, and many things have come full-circle. Functional programming was around long before OO. Kubernetes/Containers were around long ago, Agile programming books were around 25 years ago. A manager that still subscribes to the waterfall method has always been outdated and misplaced.
@williamheymann8180
@williamheymann8180 3 жыл бұрын
Overall I prefer a Hybrid approach. In some things I just find that OO maps really well to a problem I am solving and in other parts I find that functional maps really well. Most languages commonly used today can freely switch between the two styles as needed. You can even use purely imperative approaches for some types of problem where you need mutable state for really high performance.
@AdobadoFantastico
@AdobadoFantastico 3 жыл бұрын
I just wish there was more info on FP. I am self taught and found that at least the problems I was dealing with were often better handled through FP. I had complained to some programmer friends that OOP is weirdly obtuse for the stuff I was doing and they kind of made me feel like I was a dumbass until I found that there's another paradigm. It made for TONS of friction and stress on my learning path. Even when I learned there was this FP thing it took me a while to grok anything about applying it because all the conversation is so saturated by ppl being dogmatic.
@V000idZer000
@V000idZer000 Жыл бұрын
I think, depending on the kind of the problem you are solving you need 90-99.9% FP and 10-0.1% OOP, most of which can be handled relatively well in pure FP languages too (monads, IO-functions, etc), but there is a small remainder, which is so much harder to do well in pure FP languages, still tend to stick with basically programing FP as much as possible inside OOP language and use the freedom to mutate exclusively where it really helps performance or simplicity against correctness. In simple cases that never change even inheritance can be the simplest and best solution. You need lots of discipline to do it right, but it pays off and rewards good things of both worlds.
@TheRealisticNihilist
@TheRealisticNihilist 3 жыл бұрын
@13:55 How is whether or not something is "more readable" or "clearer" not simply an artifact of education? I don't speak Chinese. To me, no different combinations of the symbols are going to make sense. Is Chinese therefore "unreadable?" "Unclear?"
@llpBR
@llpBR 3 жыл бұрын
I do agree about everything said here. My only complain nowadays is the overcomplicated codes I find in OO around. Things you could easily solve with a script or a sql procedure are solved using a huge amount of things, using a lot of memory and processing.
@madhupramod
@madhupramod 3 жыл бұрын
Why don’t you like async await? I’d love to hear more of your thoughts on that
@KangJangkrik
@KangJangkrik 3 жыл бұрын
Yeah I want to know too! To be honest it's better than Kotlin's coroutine in term of syntax length
@AntonMochalin
@AntonMochalin 3 жыл бұрын
I think he meant that async/await ruins that constraint he was proposing - you write async code as synchronized with async/await and that's what he would like to avoid. Which means you basically hide concurrency from yourself by doing async/await. Good when there's no actual concurrency (e.g. when you await for database to return a query result), bad when there's actual concurrency happening. Not sure that "asynchronous only" constraint would lead to more readable code though. But definitely would make developers think about possible concurrency issues.
@gedw99
@gedw99 3 жыл бұрын
@@AntonMochalin I think the key was threading And him saying messaging passing by it’s nature does not rely on cpu tricks hiding the apparent multi threading from you like asynchronere wait. I agree with him and use events and message passing between modules . If you need to scale just start up many of the same modules and use a queue group to load balance each being given work to do . You can do this pattern inside a single binary of many processes or servers with no code change if you use good message passing patterns
@airman122469
@airman122469 3 жыл бұрын
Because it’s not deterministic, and can be memory unsafe.
@norpriest521
@norpriest521 3 жыл бұрын
@@airman122469 What the hell are you guys talking about? 😂 And why Arts student like me is in here?😂
@foxoninetails_
@foxoninetails_ 3 жыл бұрын
I think you've hit the nail on the head with your constraint-based definitions. In my experience, the thing that a lot of "paradigm essentialists" (if you will) miss most often is that these paradigms are most powerful, and most useful, when you mix them. Over-applying any one constraint to your entire system leads to all sorts of workarounds, messiness, and general nonsense, as you try to fill the holes created by using that paradigm outside of its comfort zone. It's when you apply constraints carefully and thoughtfully in the places they're most needed that they really shine. For example, I tend to structure most of my programs with an object-oriented interface - anyone interacting with my code from the outside, myself included, will typically see it as a collection of objects and structures that offer specific sets of functionality for different use cases. Using that constraint helps me keep my code organized and modular, by allowing me to encapsulate specific concepts as "entities" within my system, and define rules about how they interact, as well as making it easy for others to conceptualize and understand at a high level. But a lot of my internal code, the implementation behind how those objects interact, is based on functional principles - breaking their operation down into pure or semi-pure functions, and reducing the code space to stringing together well known high-level operations. Using that constraint helps me ensure that I can quickly and easily reason about how things are functioning internally, and be confident that the smaller building blocks I've created work properly as I string them together into larger and more complex pieces. By mixing the two constraints to fulfill different needs, rather than sticking religiously to only one or the other, I achieve a greater whole in the long run. That view of mixing paradigms reflects how I try to treat everything in programming - as a tool. Far too many people seem to get religiously attached to an idea, a paradigm, a framework, a formatting style, what have you, rather than seeing each individual piece as a means to an end. They get too attached to their hammer, and everything starts to look like a nail. It's when you take a step back, let go of those attachments, and pick the right tools for the job that you can really start to do great work.
@leftaroundabout
@leftaroundabout 3 жыл бұрын
True. On the other hand, a certain amount of _consistency_ is definitely needed for all the paradigms, to actually reap the benefits. No doubt one of the reasons for Java's success is that it was the first mainstream language which had enough OO-constraining built in _enforced_ so even teams of largely unexperienced programmers would produce quite robust applications in it. (That is, what-Java-calls-OO constraining.) I personally find that quite annoying when I have to write Java - but then again, you can of course employ other paradigms in it, only, this can require some verbose wrappers which make it obvious. That has the downside of feeling slow & clunky to develop compared with, say, Python, but the advantage that it's less likely that the project will devolve into a mess of incompatible conventions. Likewise, even though Haskell is purely functional, it is quite possible to write imperative code in it - really imperative with in-place memory updates! - it just needs to be made explicit with a suitable monad. That way, you can again mix paradigms, but avoid bugs where one developer expects foo to be purely functional, but another decides to give it a side-effect that was not considered and breaks code elsewhere.
@livb4139
@livb4139 3 жыл бұрын
Word
@klausehrhardt4481
@klausehrhardt4481 2 жыл бұрын
Sounds good, specially if you work solo on projects, like I do. MCU firmware programer here - I know only the native assembler of two midrange family of MCU and a couple of directives native to vendor compilers mainly used to control data and code allocation. What I would like to know: is this war on paradigms not a direct result of a clash of diferent company cultures inherited by programers working for them? I feel it is. And that is why I liked the vid above and your remarks so much. Most people working in institutions have their mindset made up by those same institutions. The bigger, the stronger. They seem not to have the freedom to try a new thing. As a final sociological remark: people in big institutions seldom know the ends they work towards. The means they are allowed to come by seem also over-normalised. Megachurch stuff, I bet. Let me know your remarks.
@foxoninetails_
@foxoninetails_ 2 жыл бұрын
​@@SimonWoodburyForget I think our disagreement here can be summed up quite succinctly around your assertion that "the larger number of paradigms you follow, the higher the complexity of your code base". In general, this is true; it's easy to go too far in the other direction and jump between paradigms too much, creating issues and mess for yourself and your coworkers. However, you miss a key bit of nuance in that statement - there are times when forcing yourself to stick to the same paradigm, even in the face of a problem which that paradigm does not solve well, increases complexity as well. Not everything is easiest to think about in the same way! Switching paradigms is a tradeoff to be considered, not a sin to be avoided at all costs. Take Haskell, for example. Haskell is _excellent_ at creating and connecting tiny functional building blocks that can be easily reasoned about in isolation, so you can build a larger whole more easily. It's terrible, however, at anything outside of that specific focus area - any time you need to touch the outside world of messy IO and unpredictable inputs, it becomes an absolute nightmare. The language restricts you, quite forcibly, to a single paradigm, and while that is in many respects a benefit, it is also a detriment in others. Were you able to switch paradigms away from that strict, purely functional dogma and the hacks and workarounds needed to break outside of it and do real work, in favor of a paradigm better suited for that environment, your code would benefit greatly from momentarily stepping beyond a restriction that, while beneficial in other areas, is doing you no favors in that one. Programming is not a religious endeavor. There is no benefit to sticking so closely to a specific dogma that you refuse to part from it even for a moment. It's about _solving problems_, and preferably in a way that you can understand, replicate, extend, and maintain easily. When switching tools, like paradigms for example, makes things work more smoothly, the only thing you gain by refusing to do so is frustration.
@foxoninetails_
@foxoninetails_ 2 жыл бұрын
@@klausehrhardt4481 I agree in general, though I think the heat of the discussion is exacerbated by internet outrage culture even more so than insular company cultures. People stick to the ideas and technologies that they know, and many people - especially in a culture that either reflects back those ideas as an echo chamber or screams at them that they're idiots for having those ideas - refuse to broaden their perspective beyond their first impressions.
@pedrobotsaris2036
@pedrobotsaris2036 3 жыл бұрын
In the end off the video you got close to describing Erlang which is a functional language
@TomislavJakopanec
@TomislavJakopanec 3 жыл бұрын
Was just thinking that also :-P
@JustHeathen
@JustHeathen 3 жыл бұрын
Exactly, Erlang and/or Elixir, pretty close description :)
@AustinSalonen
@AustinSalonen 3 жыл бұрын
Combined with OTP, which is a lot like Alan Kay's vision of OOP, you get a very powerful system (and one that's very fun to code in).
@gedw99
@gedw99 3 жыл бұрын
I used erlang but now use golang with nats . Very similar patterns
@HansTheGeek
@HansTheGeek 3 жыл бұрын
What makes elixir so flexible are macros. That’s another dimension not mentioned in the Video. Code that generates code.
@TheIst0NE
@TheIst0NE 3 жыл бұрын
Watched this a few weeks ago, and let it sink. Then watched it again now, paused at many points and took some notes. Organised the arguments and key points, wrote them down in an .md file and put it among my personal notes and studies. This is a brilliantly formatted line of thoughts one can bring up on a lecture, interview, or in a pub! Thank you very much, 10/10, would watch again, will seek out your other videos as well!
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thanks, I am pleased that you liked it.
@simonr7097
@simonr7097 3 жыл бұрын
For anyone interested in this discussion, I suggest reading the paper "Why functional programming matters" by John Hughes, who takes the view that we shouldn't focus on what FP *doesn't* allow (no side effects, no flow of control) but what it does enable (modularity, through higher-order functions and lazy evaluation).
@xenopheliac7202
@xenopheliac7202 3 жыл бұрын
As a fulltime C# developer, and spare-time Haskell developer, I must say, that the absolute elegance of 'sum = foldl (+) 0' was what won me over! There is a reason that mathematical notation is the way it is, and not like English. Once you know the symbols, it becomes hugely expressive.
@totalermist
@totalermist 3 жыл бұрын
Uh. Bad example. There is no such thing as standard mathematical notation. Maths papers usually carefully define the particular notation used throughout the paper for that reason. Without proper context, a mathematical statement can mean pretty much anything: |A| can be the magnitude of a vector A, or the determinant of a matrix A, or the absolute value of an integer A, or the absolute value (aka modulus, aka magnitude) a complex value A... C++ is guilty of this - an expression like auto x = y() tells you _nothing_ about the type of x or y and the operation performed. Could be anything from a ctor call, to a function call, to an operator call on a class instance. Horrible. It gets even worse if you add initializer lists when expressions like f({1, 2}) become impossible to decode without tooling or context ({1, 2} could be an initializer list, an implicit tuple, a std::pair, a ctor call to a class that accepts two arguments that can be implicitly converted from ints, etc.)... I don't want my programming language to be like that. IMHO, expressiveness is overrated. A developer spends far more time reading and contemplating code than writing code and clear code is always better than clever code when it comes to understanding.
@leandrog2785
@leandrog2785 3 жыл бұрын
Mathematical notation is a language. If you're not fluent in it at all, functional programming is hard. If you are, it's intuitive. Unfortunately, almost no one is fluent in it. Most people don't even realize there is something to be fluent in.
@oShinobu
@oShinobu 3 жыл бұрын
@@totalermist I agree with your last argument that clear code is better than clever code. However, I don't think code needs tons of boilerplate to be clear - in fact, I think boilerplate reduces the readability massively. In functional programming languages like Haskell, there are also clear ways vs. clever ways to implement something. I think the example he gave with "sum" is very clear to someone who is familiar with FP. It basically comes down to this: Do we want something that is accessible or something that is elegant? I for one do not want to settle for the lowest common denominator. But that's just my take.
@totalermist
@totalermist 3 жыл бұрын
@@oShinobu Clear code doesn't have to mean lots of boilerplate either. There are quite a few languages that strike a nice balance, such as Python, C# (though that suffered from feature creep as well), F#, Swift and even TypeScript or Ruby and Kotlin. It's nice that you personally don't want to settle for less, but the vast majority of developers deal with rather mundane tasks and line of business apps. Employers want to be able to hire staff that don't have a Master's degree or a PhD and would get bored rather quickly with LOB apps, UIs for interfacing databases and maintaining vast existing code bases written in "boring" languages like Java. That's why Go was created and its success seems to support this observation. (not that I personally like or endorse Go, but I understand why it exists)
@teeesen
@teeesen 3 жыл бұрын
@@totalermist He did say “mathematical notation” rather than “standard mathematical notation” . Haskell has its own standard and any Haskell programmer will roughly know what foldl means. If they don’t, this definition of sum is a good motivation to learn. But I think foldl is a good example of where Haskell takes good ideas too far. The default definition of foldl is ` foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z`, where t is some foldable object. This is not easy for beginners to grasp and leads to some really confusing error messages when you make a type error. The good idea is type classes. It’s a wonderful idea. The problem is it’s such a good idea that there is no clear line which should not be crossed in applying it. I think they crossed a line, but I’m not sure where. Perhaps `foldl f z t = foldl f z . toList t` would have been a better default. Who’s to say?
@mc.ivanov
@mc.ivanov 3 жыл бұрын
I think most programmers find functional programming because they never had to deal with it's constraints. Their brains are wired to write a different kind of code and that's why it looks harder. If you want to compare the sum example, I think a better comparison would be a "map" vs a "for". Which one will be easier for someone that has never coded before? Regarding the asynchronous modules that send messages to one another, that's what Erlang and Elixir do for many years and yes, this is really powerful and for me it seemed a lot easier to understand in a shorter amount of time than Python, JavaScript and C++ code in a professional setting.
@dojohansen123
@dojohansen123 Жыл бұрын
Agreed, except I would say that is why it *is* harder - when you're used to a different paradigm. It's not about it being __inherently__ more difficult. Then again, many people say math is hard, and I think that too is mostly a misunderstanding. (Although there is very advanced mathematics that truly is hard, but I think this is true of basically any subject that has been studied much by mankind...)
@D4no00
@D4no00 Жыл бұрын
This is absolutely true, I have worked with elixir in the professional scene for about 6 years now. If we talk about developer efficiency, maintenance and overall product quality, beating elixir or erlang in the field of distributed, highly concurrent applications is something you will not be able to do with one of the alternative languages currently on the market be it go,java or python. Immutable code is easier to reason about, is thread safe by design, pure functions are easy to reason about in a big and complex codebase, easy to test and debug and inherently have less bugs by design. It is argued that you can write functional code in most languages however that is not entirely true, languages like java were not designed for optimization of immutable structures, can't handle concurrency race-free on immutable structures, there are no managed side-effects. These things cannot be implemented as libraries, they need to be at the core of the language and runtime and impact directly the performance of the designed system. The way concurrency and OO concepts were implemented in erlang are superior by years to any languages I've seen nowadays. I could literally show you 45 minute presentation on how concurrency works in the runtime and even a kid will understand it, as it doesn't involve any low-level crap like mutexes, threads, race conditions, locks as the runtime and language abstracts everything for you, providing you great abstractions to get things done, not to reinvent the wheel on how to handle concurrency. I've not even mentioned to this point about fault-tolerance, a killer feature exclusive to erlang, that takes the combination of all these concepts to the next level and allows parts of the system to fail and self-heal with zero downtimes.
@adrianperez8695
@adrianperez8695 3 жыл бұрын
I think one of the strengths of an imperative style is also it's weakness. I can look at an imperative block of code and navigate through it, line by line "executing" it in my mind to figure out what it does. It allows me to figure things out bit by bit. This is also a weakness though; if I don't execute the code with different inputs, and if I don't execute it completely (i.e. I just skim through the code) I won't truly understand this. Never mind the fact that any time there is a branching statement, I have more execution paths to consider. More functional code allows me to abstract away imperative logic to somewhere else. A sub-procedure means I don't have to concern myself with the details of a procedure, just what it's arguments are and it's return. In a pure functional style, I can rest assured that even if I don't understand the function fully, it won't mess with the state of anything else so I am less likely to get strange behavior in other parts of my program. However, and I think this is to your point, I NEED to understand whatever my function is doing right up front. I cannot execute and reason my way through the code. I either know what a "map().filter().reduce()" does, or I don't. Given the nature of how abstract those functions are, it can also be difficult as a beginner to fully grasp. As a side note, I slightly disagree that the core concept of OO paradigms are polymorphism. Or rather I should say, I think a MORE core concept of OO is encapsulation. I often find closures and dynamic typing to be much more polymorphic than what the more strict OO languages provide.
@Christobanistan
@Christobanistan 3 жыл бұрын
The strength of the imperative style is that it's close to the hardware.
@sandipanumbc
@sandipanumbc 3 жыл бұрын
I think it's about the trade-off between the specification and the execution gaps of a programming language... Closer to hardware meaning easier to translate the program to machine-executable instructions hence lesser execution gap, whereas ease of translating a problem to a program in the language refers to the specification gap
@tobiasbergkvist4520
@tobiasbergkvist4520 3 жыл бұрын
Meaning that any language that allows for inheritance is not really a true OO-language, since inheritance also makes you inherit all the private fields/internal data. Inheritance as a concept is more similar to using patch-files to describe modifications of code than anything else. Rust is a more object-oriented language than Java, because it uses traits (which actually preserves encapsulation) and doesn't allow inheritance.
@Christobanistan
@Christobanistan 3 жыл бұрын
@@tobiasbergkvist4520 That's nonsense. You inherit an implementation, but you don't inherit the private data unless you use reflection to poke at them, which you explicitly aren't supposed to do.
@tobiasbergkvist4520
@tobiasbergkvist4520 3 жыл бұрын
@@Christobanistan What I mean is that you inherit the knowledge that these private fields exist, and get the ability to modify them. This means that it can be dangerous to change the implementation details of a class in the future, in case someone that inherited from it relies on something that is not part of the public interface.
@dm9910
@dm9910 Жыл бұрын
I tried out functional programming but I think I like it more for what it taught me than for what it actually offered. The theory behind functional programming, particularly the idea of pure methods, has definitely made me think differently about the way I write OO code. But in the end, I still find it quicker and easier to read and write code in C#.
@hardryv3719
@hardryv3719 Жыл бұрын
Look to SOLID
@V000idZer000
@V000idZer000 Жыл бұрын
I think this is the best way to deal with it too. My two cents: OOP languages are still better supported all over the board and have more/better libraries and allow sometimes more control, even if doing the right thing requires a lot more discipline and some more code in most cases. I would always keep things as pure as possible and leave the part that needs mutability/IO centralized on the outside of the application (debug/log code is an exception here), but have the ability open the Pandora's box in these rare cases where it makes sense, eg. to use purpose specific pooling and custom memory/resource management. But if so, then only with a lot of care and caution taken. The little extra time invested to build such architecture, very soon starts to save time over the entire lifecycle.
@I_am_Raziel
@I_am_Raziel Жыл бұрын
I really really dislike OOP. It makes things so much more complicated. Without any necessity. In over 14 years of programming I needed inheritence exactly ONE time. You can do almost everything with functions. Use OOP only where it makes sense, everywhere else, use functions.
@mattrenyard8712
@mattrenyard8712 4 ай бұрын
@@I_am_Raziel did you watch the video..? Maybe try to understand the bit around OO is really about the flexibility in messaging leveraging polymorphism not inheritance. It's a real shame how some see OO as inheritance and forget encapsulation and polymorphism as the benefit to building complex systems.
@I_am_Raziel
@I_am_Raziel 4 ай бұрын
@@mattrenyard8712 Encapsulation is one of the features of OOO that I often use. Nevertheless it has been one more year since I wrote the initial message and still the same applies: you can do almost everything with functions. Most of the time (>98%) OOP in all of its complexity is not necessary.
@apestogetherstrong341
@apestogetherstrong341 2 ай бұрын
Functional programming has polymorphism much more powerful than OO.
@royfu4971
@royfu4971 3 жыл бұрын
Awesome talk. The last piece in this talk on the "pure message sending" idea, actually reminds me more about Erlang&OTP rather than smaltalk or ruby.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thanks, yes, it is very like Erlang.
@TheDerwisch77
@TheDerwisch77 3 жыл бұрын
@@ContinuousDelivery Or if you want to go more mainstream with java or its more functional sister scala, you get this using akka. It's heavily inspired by Erlang and OTP.
@nerophon
@nerophon 3 жыл бұрын
Yes, I worked in Erlang for quite a while and I was thinking the same thing. It really does make coding complex distributed systems a lot easier. A feel that Go is a promising candidate for a fairly contemporary language which can do this, and also ticks a lot of other boxes in terms of the good parts of OO and functional.
@reilithion
@reilithion 3 жыл бұрын
It sounds to me very much like pi calculus. It's a bit like lambda calculus in how it's a mathematical model that keeps itself very simple in concept. But everything is passing messages. Computation itself is passing messages.
@wtrmute
@wtrmute 3 жыл бұрын
As far as I understood what he meant, I think he's talking about C. A. R. Hoare's [Communicating Sequential Processes](ora.ox.ac.uk/objects/uuid:e0143106-e414-4f02-bd3d-3f3f8db34e88/download_file?safe_filename=H77%252520-%252520Communicating.pdf&file_format=application%2Fpdf&type_of_work=General+item). And while I do agree with him that we are unlikely to have seen every programming paradigm that can ever be, we have certainly seen this one.
@willful759
@willful759 3 жыл бұрын
"... functional is the new kid in the block" considering that lisp is inspired by lambda calculus, which is equivalent and contemporary to turing machines, the basis of computing, you can argue that in some sense functional programming came _before_ computers and programming, so yeah, thinking about functional as the new kid in the block is quite a mistake
@javierflores09
@javierflores09 3 жыл бұрын
how did we go from "we can argue that" to "you're wrong"? I think it isn't wrong to think of functional programming as rather new considering its popularity among new languages in the recent years, sure, it may have existed before but it was never a standard in the programming world as OO is, until now.
@JohnJohnson-ox3uc
@JohnJohnson-ox3uc 3 жыл бұрын
Fun fact: Lisp influenced the first OO languages.
@willful759
@willful759 3 жыл бұрын
@ཀཱ yeah, I didn't mean to say he was wrong, I was just adding to that statement
@PanduPoluan
@PanduPoluan 3 жыл бұрын
I do agree with the sentiment that "paradigms" are just "tools" to "help" programmers make good, maintainable code. Good habits learnt during mastery of a paradigm is actually applicable across lots of programming languages.
@pm1783
@pm1783 3 жыл бұрын
Why the quotes?? Lol…
@thefakepie1126
@thefakepie1126 3 жыл бұрын
your quotes makes it sound like an inuendo, yeah those """paradigms""" really are just """"tools"""" to really """""help""""" programmers
@AdobadoFantastico
@AdobadoFantastico 3 жыл бұрын
@@thefakepie1126 maybe they're instructions for an esoteric language like RockstarLang, but you code everything through ambiguous sarcasm.
@imadetheuniverse4fun
@imadetheuniverse4fun 3 жыл бұрын
My introduction to programming in Python was mostly using the numpy library, so I inadvertently learned to code in more of a "functional paradigm" than not. When I started to look into Haskell I was struggling to find the difference between how to code in Haskell and how I was already coding in Python, funnily enough. Thankfully I think I learned in a way that exposed me to the best and the worst of both paradigms at the same time. It's really nice not having to subscribe to one "side" or the other, just use whatever makes the most sense for that use-case.
@Twisol
@Twisol 3 жыл бұрын
Dave, as someone who strongly prefers functional programming, I really appreciate your balanced perspective here. I am curious if you're familiar with material on modeling in FP, such as Scott Wlaschin's "Domain Modeling Made Functional" -- I feel that I model early and deeply in FP, so it's a little hard to agree that OO is "more" focused on modeling; it seems orthogonal to choice of paradigm. That said, I mix and match OO and FP based on need (inasmuch as I try to limit and centralize mutable state as much as I can), so maybe I'm an outlier?
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thanks, I tend to use a mix of OO and FP too, though mine is certainly OO with bits of FP rather than the other way around. I was trying to play this with a straight bat. I try to highlight the points where I am aware that my own prejudice may be involved. Thanks for the reference to the Domain Modeling in FP stuff, that sounds like something I will enjoy.
@code_report
@code_report 3 жыл бұрын
13:58 is an unfair comparison. FP solution should be: val x = someCollection.map(_.size).sum
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, sorry for the typo there is a correction pinned in the comments now. The code wasn't really original to me, I took if from an example FP program.
@bigpod
@bigpod 3 жыл бұрын
@@fredrik751 well how do you sum numbers in your head you make a for loop or foreach loop you take first number you add second then third then forth that is basicly a loop
@MaxHaydenChiz
@MaxHaydenChiz 3 жыл бұрын
Several of things: 1. In my experience, the breakdown between functional vs OO is a matter of the problem domains a developer is used to dealing with. Some domains map more naturally to one or the other. If you haven't worked on a problem where the paradigm you like *doesn't* work, then you don't really understand the paradigm. And it seems like you just haven't had occasion to work on a problem where OO was a horrible fit and FP just flowed naturally. 2. What counts as "OO" differs widely depending on whether you are talking to someone who works in Java or Python or C++. You have a similar thing on the functional side between dynamically vs statically typed. But the difference is that the functional people have come up with a lot of careful terminology to communicate the specific intent behind the exact version of the paradigm they are using in any given library or system. I'm unaware of any comparably rigorous terminology on the OO side of the equation. 3. As others have mentioned, what you are talking about at the end is Erlang. What they left out is that this is how most soft-realtime systems are designed in practice regardless of language. For our purposes however, the important thing is that this design choice *forces* Erlang to be a dynamically typed pure functional language. That's the relevant mapping of the problem it is dealing with. 4. In any event, thinking in terms of paradigms obscures the real issue. A professional is going to use the paradigm that best fits the problem. But, however you are designing your code, the goal is do it in a way that lets your tooling automate as much of the work as possible and allows you to systematically rule out categories of behavior so that you can reduce your cognitive burden for the code you do have to write by hand. You *can* use any paradigm in any language, but what matters is the level of support you get from the language in actually doing it. It's a matter of "which tool is the best fit for my problem domain". The business case needs to be about productivity and cost, not about ideology and fads. We've been doing this long enough that we should be able to attach hard numbers to this stuff. The people in the comments complaining about managers not understanding need to learn how to make a business case for their preferences. Communicating effectively is at least half the job. 5. Math isn't exclusive to FP. Plenty of OO devs use dependently typed proof systems to validate their API designs before transcribing the proven code into a normal language as the basis for their API. You can do some amazingly advanced refactorings this way. 6. Finally, when it comes to the ease of understanding imperative vs functional code, you are just factually wrong. We've both been programming long enough that the imperative code *seems* natural to us. But we suffer from the curse of knowledge. People have done studies on what non-programmers find easier to understand and and experiments on what students find easier to learn. The evidence is very strongly in favor of functional code, to the point that the 2nd edition of _How to Design Programs_ dropped the chapter on imperative programming entirely (with the expectation that a subsequent class on OO would deal with it). Beyond that research, there are lots of additional intuitive data points. The most widely used programming language on the planet is Microsoft Excel -- a functional reactive programming system. Similarly, functional programming languages are overwhelmingly popular in cases where you have a design requirement that managers with no programming background must be able to do code review and audits. Non-programmers (and less experienced developers) do find functional code to be easier to understand. That doesn't mean it's the right approach for any given problem. But it does mean that experienced devs like you and I have a blind spot to this design consideration that we need to be aware of and factor into our decision making.
@Orlandofurioso95
@Orlandofurioso95 3 жыл бұрын
A well-thought, well-written, relevant comment that offers valuable insight and provides a counterpoint to the video? What has happened to the KZbin I know?
@jakistam1000
@jakistam1000 3 жыл бұрын
@@Orlandofurioso95 (Serious answer to non-serious question) Actually, that's not really an exception anymore, on educational channels. A lot od intelligent and qualified people write resopnses and additions inder well-made videos like this one. You can actually learn a lot from YT comments - though I still would only treat it as a tarting point, not real source.
@jakistam1000
@jakistam1000 3 жыл бұрын
@Max Hayden Chiz What fraction of people using Excel actually use it as a programming language? In my experience, it's almost always just adding columns together, if that. And yeah, maybe you could say that's programming... but I'm sceptical. But I don't really have any data, that's why I'm asking.
@Orlandofurioso95
@Orlandofurioso95 3 жыл бұрын
@@jakistam1000 I am currently writing my thesis for a Mathematics degree, and despite knowing C, Python, Zig, F#, Haskell and Matlab, half of my work is done in OpenOffice - it's just faster to shuffle data around and debug. Only the more hardcore computations are done in Matlab, where I have 100 lines of code to import a couple CSV exports of the Excel files, and three lines to solve a couple linear systems.
@woobilicious.
@woobilicious. 3 жыл бұрын
The holy grail is a typed Excel (And I kinda wish I was joking), it would definitely solve the MARCH1 issue.
@tommornini2470
@tommornini2470 3 жыл бұрын
The methodology described at the end of asynchronous message passing between modules is very nicely implemented in go(lang). Alan Kay’s description of object orientation was very much described as asynchronous objects that process messages received and likely generate new asynchronous messages of their own. His objects were much closer to Actors in today’s parlance: objects that do things rather than objects that are things…
@deathx0r
@deathx0r Жыл бұрын
Also in OTP directly from erlang or through elixir.
@MoldovaStandsWithUkraine
@MoldovaStandsWithUkraine Жыл бұрын
Thanks I am attending a Functional Programming course after a Object Oriented one And your comparison and explanations widen my understanding of the basic concepts behind them
@ContinuousDelivery
@ContinuousDelivery Жыл бұрын
Glad it was helpful!
@petebrown6356
@petebrown6356 Жыл бұрын
Typing the fewest characters should not be a goal. It reduces readability and reduces the pool of developers that will correctly interpret the code.
@JeffreyRennie
@JeffreyRennie 3 жыл бұрын
Erlang very closely matches what you described in your reactive manifesto.
@mananananananan
@mananananananan 3 жыл бұрын
Yeap! And I was thinking of Elixir.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, it does.
@openroomxyz
@openroomxyz 3 жыл бұрын
Do you know any source where I could learn how to make the thing in C#?
@insertoyouroemail
@insertoyouroemail 3 жыл бұрын
@@openroomxyz you can do erlang style programming in C# with Akka.NET and reactive programming with Rx.NET
@Qrzychu92
@Qrzychu92 3 жыл бұрын
@@mananananananan but Elixir sucks because it is dynamicaly typed...
@austinabro2027
@austinabro2027 3 жыл бұрын
You should definitely go more in depth on your idea at the end in future videos!
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Will do, thanks.
@blitzkr1egg
@blitzkr1egg 3 жыл бұрын
Maybe something about Sending async messages = actors
@viniciusgarcia3452
@viniciusgarcia3452 3 жыл бұрын
Also maybe worth mentioning is that there are at least two languages that I know of that are working with interesting paradigms for sending messages between asynchronous modules: Golang and Elixir
@viniciusgarcia3452
@viniciusgarcia3452 3 жыл бұрын
And about this same subject of concurrency and paradigms, there is one very interest article I read recently that compares the conditions that lead to the advent structured programming with the current way we work with concurrency. And proposes an interesting way of restricting the creation of new threads in order to make the code more predictable and provable: vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
@davefarley77
@davefarley77 3 жыл бұрын
@@viniciusgarcia3452 yes, and Erlang, though that is nearly the same thing as Elixir as I understand it.
@ajibolaoki5064
@ajibolaoki5064 3 жыл бұрын
only just realised I'm a functional programmer after watching this video. Keep it up!
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thanks
@dmitryplatonov
@dmitryplatonov 3 жыл бұрын
Prevalence of OO thinking is by large the marketing Sun did with Java. It pushed it hard, schools and universities adopted it, and we are having what we are having now.
@acasualviewer5861
@acasualviewer5861 2 жыл бұрын
I think you're too young then. We were pushed OO in the early 90s with C++. Late 80s Objective-C came out as well with NextStep (now known as MacOS). OO was a huge push in things like CORBA. Java just came along and simplified it.
@sis1296
@sis1296 2 жыл бұрын
Did C++ way before Java/C# came along.
@dmitryplatonov
@dmitryplatonov 2 жыл бұрын
@@sis1296 yes, but that time it was not prevalent paradigm.
@acasualviewer5861
@acasualviewer5861 2 жыл бұрын
@@dmitryplatonov of course it was.. back then Windows programming was the big thing and C++ was the language to use for it along with the MFC framework.
@dmitryplatonov
@dmitryplatonov 2 жыл бұрын
@@acasualviewer5861 well, it was major paradigm for UI. But I feel that Java did try to cram everything, business logic specifically, into class hierarchy model. And they sponsored teaching generation of programmers how to do so.
@nicholasweiland5553
@nicholasweiland5553 3 жыл бұрын
15:20 “Yes the code is shorter, but that compromises its readability”. Completely disagree with this premise. Shorter but conceptually dense code becomes much quicker to parse than more verbose code built on simpler concepts. The idea is you learn an abstraction once and waste far less time reading the same boiler plate crap over and over. Readability to someone who’s never read code is a silly metric simply because it’s irrelevant in the real world.
@j-r-hill
@j-r-hill 3 жыл бұрын
I find your last points about OO being about modeling and FP being more mathy interesting. I've definitely done more OO than FP for work, but I find the FP paradigm far more intuitive, and to lead to better modeling than OO tends to. Yes in the trivial cases, OO makes for a nice `new Dog.bark()` experience, but anything complex leads to Factories and Providers and "Utility classes." I don't think those are good ways to model problems. We just need to get someone that can come up with better names and explanations for Monads and Functors and Applicatives etc. They are "mathy" in name, but I don't think they are in practice
@insertoyouroemail
@insertoyouroemail 3 жыл бұрын
Interesting. You may be right. What's really neat about a "semigroup" or a "functor" for example is that it's unambigous what laws it must obey. It's just a word at the end of the day. I think a lot of programmers (including me) get insecure and intimidated when we hear strange terms. As someone who doesn't like naming variables and procedures and systems and even hates discussion around naming, I celebrate the opportunity to expand my vocabulary with exact definitions.
@j-r-hill
@j-r-hill 3 жыл бұрын
There also just is not material out there to help an average programmer be successful in Haskell (for example). You have to have time to focus, and either know enough math jargon to digest academic literature, or be obsessively motivated. Compared to the wealth of accessible literature you can find on Java, Python, JavaScript, etc., there's almost nothing for functional languages
@insertoyouroemail
@insertoyouroemail 3 жыл бұрын
@@j-r-hill yes, you are completely right about that
@____uncompetative
@____uncompetative 3 жыл бұрын
Every single paradigm is wrong.
@larryculver4375
@larryculver4375 3 жыл бұрын
In college I spent some time learning how to unfold recursion. Now we are trying to fold it back together again.
@maddmethod5880
@maddmethod5880 3 жыл бұрын
The "limiting synchronicity" idea you described sounds a lot like Observables in the rxjs world. what would be interesting is if that were more common in desktop use cases, and if an observable response could be sent along a separate thread than it was initiated from
@jameslecka8085
@jameslecka8085 2 жыл бұрын
This is intended as helpful criticism. 1) good job on the introductory history 2) each programmers mind works a bit differently. OOP works well for some, FUNCTIONAL for others. So what is the ratio? 3) if in paid employment, the choice of paradigm usually not an individual programmers. Just follow orders: you are being paid. 4) trade-offs: Which costs more to create? Which costs more to maintain. How big is the local pool of each type of programmer? Which generates higher performance? Which tends to have the fewest bugs? Which are easiest to train people in?
@sourestcake
@sourestcake 3 жыл бұрын
I write in C, and i've also started thinking more in terms of limiting side-effects of procedures, after learning of functional programming. This is a very good video. Thanks.
@supercheetah778
@supercheetah778 3 жыл бұрын
I'd be interested to get your take on Rust that takes little bits of inspiration from all different kinds paradigms, including both OO and functional, but eschews embracing any particular one wholly, such as implementing polymorphism, closures, and immutability by default, but purposefully leaving out inheritance.
@meanmole3212
@meanmole3212 Жыл бұрын
Rust is my number one programming language to develop with at the moment, but I wish they'd add an option for strict aliased types. The reason being that the borrow restriction almost always leads to structuring and manipulating your data by having bunch of structs inside a vector and another vector of usize values that has index values pointing to the real data vector. When your algorithms grow more complex, it becomes hard to make sense which usize value points to which vector of data. With strict aliased types you could alias the usize to have specific label for each specific data vector, and while doing so the compiler would prohibit you from using the wrong aliased type at wrong context. At the moment if you make a function that accepts aliased usize as its argument, you can pass any aliased usize type to that function as well as a regular usize value. There should be way to make this more strict. You can achieve this in theory by creating a new struct that has only 1 usize member, but it adds too much friction since you need to name that usize and access it every time with the dot operator.
@acobster
@acobster 3 жыл бұрын
9:41 polymorphism is not an exclusively OO idea. Most OO (in the "Object" sense) languages just happen to conflate polymorphism with inheritance, which is exclusive to that style.
@Gnidel
@Gnidel 3 жыл бұрын
You can do polymorphism without inheritance. Reflection is using that.
@fat_pigeon
@fat_pigeon 3 жыл бұрын
For example, Haskell implements polymorphism using type classes, which constitute a very different approach from OO.
@tomcowell9653
@tomcowell9653 3 жыл бұрын
Thank you for this. I haven't done much software development, but I have done an awful lot of maintenance, mainly of a complex C++ project started in the 90s by some Fortran programmers who got to page of 4 of their C++ book and said "well, we don't know what we're trying to achieve, but we definitely need a big ol' class hierarchy". Later, when I had a medium-sized project of my very own, I went for: A lean class hierarchy, concise interfaces, minimal use of new, passing by const reference wherever possible, and RAII wherever appropriate. And it worked pretty well. After watching this video, I think that perhaps I had faint notions of a functional programming style. Which is nice.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
I love your description of "well, we don't know what we're trying to achieve, but we definitely need a big ol' class hierarchy" that resonates 🤣
@andrew_ray
@andrew_ray 3 жыл бұрын
While it is true that Edsger Dijkstra wrote an article in 1986 called "GOTO Considered Harmful," it was an editor who gave it that title, which Dijkstra later said misrepresented the point he was trying to make.
@h4plugins334
@h4plugins334 3 жыл бұрын
Wow, I'm glad I warched to the end, the "message-passing" style is something I have just spent 3 months back-porting to my opus magnum (General-pupose all-singing ESP8266 / ESP32 asynchronous programming frame work - 10,000 lines C/C++) I call them "events" but thats EXACTLY how they work to overcome the sync / async timing boundary. The first training example app is called "EverythingIsAnEvent" to coax users gently into eaccepting that their own code becomes little more than a switch statement and a handful of small callbacks. I thought I had invented something quite clever ....after watching your vid, it turns out I have! It made my day :) PS Internally to that its a mix of 50/50 ish OO and functional, I use a LOT of C++ lambdas :)
@peterpodgorski
@peterpodgorski 3 жыл бұрын
Great and informative as always! What I find funny is that while I'm not a functional programmer by any stretch, I do try to write my code as declarative as possible and actually find the functional examples in the video *a lot* easier to read :)
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, I was surprised by some of them, though many examples that I looked through took a while to pore over to unpick. Good code is readable whatever the paradigm and bad code is not.
@DavidAguileraMoncusi
@DavidAguileraMoncusi 3 жыл бұрын
@@ContinuousDelivery Functional programming can be extremely abstract, but a "basic" example is actually easier to understand for a beginner who doesn't know anything about any programming language. Consider your "sum" example. In functional programming, the code is pretty close to natural language: if there aren't any numbers, the sum is 0. If there are, the sum is the first number plus the sum of the rest. In imperative programming, the code is more complicated. First you declare a counter and set it to zero, because you haven't added anything yet. Then, using a "for" loop, you need a counter to keep track of the index of the element you need to add next (it starts in zero, it's valid until you reach the number of elements in the array, and you add 1 to this index counter at each step). Think of it as your "finger" pointing to the list. Wow, okay... Then you need to access the value that it's in the list using its index and accumulate said value to the result counter you first initialized. Then return the value. Sure, the imperative approach improves massively if you use a "foreach" loop, and it also resembles natural language: foreach element in the list, add it to the accumulator. So what about sorting a list? Haskell's approach to this problem always blows my mind :-)
@darrengrant8598
@darrengrant8598 3 жыл бұрын
@@ContinuousDelivery One thing I am periodically and unexpectedly sidelined by is how what is readable changes, especially when working on teams with members who span generations or disciplines. I have had project managers be surprised when explaining that, no, just because we are all programmers doesn't mean we can somehow understand each other automatically.
@Diginegi
@Diginegi 3 жыл бұрын
To me the biggest difference is that functional programming is much more implicit. In non-functional code you need to state everything step by step resulting in longer but simpler code, which may result in more repetition and bugs. Functional code tends to be shorter and less error prone, but every line may require much deeper knowledge of underlying principles because of which understanding or modifying of existing code may be a bigger challenge.
@gustavoandrade58
@gustavoandrade58 2 жыл бұрын
You are comparing functional programming with imperative programming when its perfectly possible and reasonable to work with OO systems in a more declarative and less imperative way. Stop treating this problem with these false dicotomies. We all agree that imperative programming is bad (good in some contexts but bad for bigger and more complex problems), but, not everything that is not functional MUST be imperative. That is wrong and rather foolish.
@prod42
@prod42 2 жыл бұрын
@@gustavoandrade58 absolutely right!!!!
@johnbrazil7
@johnbrazil7 3 жыл бұрын
The functional code at 14:00 is not correct. The parameter y isn't being used.
@johnbrazil7
@johnbrazil7 3 жыл бұрын
The implementation at 14:45 also is not correct. The second line should be `sum [ ] = 0`. Otherwise it is not equivalent to the definition given later.
@johnbrazil7
@johnbrazil7 3 жыл бұрын
However I understant that's not the point of the video. As far as I understood, you claimed that OOP is easier to learn. A counter-argument from the community is that it's easier to learn program design in functional programming: kzbin.info/www/bejne/i4SbgnpvfpaLjZI I appreciate how you gave attention to asynchronous messages and message-oriented programming. +1
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, thank you, I have pinned a correction for the typo in these comments.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
​@@johnbrazil7 Thanks for the link I will take a look. I'd love to see an example of, ideally children, learning functional vs other programming styles from scractch. I think that would tell us something about our preconceptions about how aligned these paradigms are with regular human thinking. They are all going to be weird to start with. I guess that when I say that I think that "Humans are natural classifiers", meaning that that means that OO is a more natural way of tackling a complex problem, then that is becuase it resonated with me that way when I learned it. But I was already infected with programming ideas by then.
@quentincrain1472
@quentincrain1472 3 жыл бұрын
@@ContinuousDelivery and are humans good classifiers? might be a good thing to constrain ...
@TheEvertw
@TheEvertw Жыл бұрын
"Functional Programmers think of Programming as Maths" I think most functional programmers think of program as a series of data transformations. I that is what you mean with "maths", then you are correct. I also think that most OO programmers think of a program as a collection of entities that "exist" and share state with each other. Both have merit, though the functional paradigm has the advantage of being composable, a very nice attribute that makes testing and re-use relatively easy. You can glue functional code together to create a new function, much easier than you can glue objects together. For me, functional programming is an acquired taste, that I have learned to appreciate!
@lepidoptera9337
@lepidoptera9337 Жыл бұрын
Your CPU doesn't think either way. It thinks of the world as a series of logic, arithmetic, branch and subroutine call instructions. And if you don't understand that, then you are a lousy programmer who will deliver lousy software. ;-)
@amigalemming
@amigalemming 2 жыл бұрын
Object orientation and functional programming do not exclude each other. There are object oriented functional programming languages like OCaml and OHaskell. Object orientation is a type system feature and functional programming is a control flow paradigm. Opposites would be object orientation vs. Hindley-Milner and functional vs. imperative programming.
@dan9948
@dan9948 3 жыл бұрын
The argument about constraints is a nice refreshing view!
@StefaanHimpe
@StefaanHimpe 3 жыл бұрын
A very interesting book in this context (in my opinion) is "Concepts, techniques, and models of computer programming" by Peter Van Roy.
@danieljensen2626
@danieljensen2626 3 жыл бұрын
I like the idea of taking the best bits from each, I think that probably makes more sense than going completely one way or the other.
@L1da77
@L1da77 3 жыл бұрын
I love these kind of discussions. Not only claiming which is better but actually comparing and pointing at good and bad. Love it!
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thanks for the positive feedback!
@psgouros
@psgouros 5 ай бұрын
whichever system groups that which needs to be grouped, and separates that which needs to be separated in order to make maintenance and modification easier is the preferred system for certain things that's OOP, for others it's functional, for some it's AOP. for others, something else. whichever one satisfies the stated condition that makes the maintenance and modification easy is the right one for that project.
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
The hardest part of programming... A good idea, elegance and knowing when to stop.
@brandonhale7574
@brandonhale7574 3 жыл бұрын
Wait, I need this feature! Just one more!
@NimhLabs
@NimhLabs 3 жыл бұрын
Didn't Alan Turing say knowing when to stop was impossible?
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
@@NimhLabs wait... if I answer you, then... D'oh!
@NimhLabs
@NimhLabs 3 жыл бұрын
@@jonathanmoore5619 I may or may not have been purposely misconstruing The Halting Problem for the purpose of being funny
@jonathanmoore5619
@jonathanmoore5619 3 жыл бұрын
@@NimhLabs stop... Just stop... :)
@ubercorey
@ubercorey 3 жыл бұрын
Good lord, this is the most cogent explanation of programming ive heard since ive been learning the subject the last 6 months.
@vicsteiner
@vicsteiner 2 жыл бұрын
I like the focus on constraints. In a sense it is close to a way of thinking mathematically. I just think that computer science is beautiful and I simply enjoy learning it and working with it. I do feel sometimes people dislike something because you can not understand it immediately or without using more maths or logic. But many times once you learnt those things they become pretty simple and obvious (and readable!).
@prometheus9096
@prometheus9096 Жыл бұрын
To be hones't i think people have a hard time understanding functional is just because they mostly started learning in oop. I teached programming to a few people (with python) and introducing them to oop concepts was the last thing i did. They mostly where more confused by oop than by functional programming. All the side effects, encapsulation, inheritances etc. was overwhelming to them. While functional is relatively straight forward, there is your "box" -> "data" goes in -> new "data" comes out.
@mtnygard
@mtnygard 3 жыл бұрын
Dave, the framing around paradigms as constraint is really good. Regarding constraining synchronicity, your description sounded close to the actor model.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes it is very close, if not the same, as actor.
@manuel-rubio
@manuel-rubio 3 жыл бұрын
I completely agree when you say it's a fashion. Both have their pros and cons and both are useful. Even, when you show the code: var x = 0; for (c size(elements, 0) size([_|elements], x) -> size(elements, x+1) size([], x) -> x But as I said, both are great. You only need to write to make sense and it works as expected.
@cornelmasson4610
@cornelmasson4610 3 жыл бұрын
From another grey-headed programmer, well done. There is no silver bullet, just pragmatics.
@davidjohnston4240
@davidjohnston4240 3 жыл бұрын
The primary idea of OO being primarily about messaging was exactly how it was taught to me in college circa 1990.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, I did something early in my career thayt deeply ingrained that idea. I was involved in build a system that was deeply OO, but not at the language level, it was very enlightening.
@Christobanistan
@Christobanistan 3 жыл бұрын
OOP is not about messaging. That came from Smalltalk and it's just not how people understand and use OOP today.
@warferton6429
@warferton6429 3 жыл бұрын
@@Christobanistan The butchered understanding of OOP today and what OOP was intended to be are two almost completely different things
@Christobanistan
@Christobanistan 3 жыл бұрын
@@warferton6429 It's not "butchered," it makes complete sense.
@dorcohen3522
@dorcohen3522 3 жыл бұрын
@@Christobanistan 7 levels of inheritance in some Java modules makes sense to no one.
@felixlipski3956
@felixlipski3956 3 жыл бұрын
14:00 - FP looks convoluted in an OO language with functional features tacked on, what a surprise. 14:45 - you missed a " :: " between the name and the type signature. Were any functional programmers even involved in making this video?
@kcabra115
@kcabra115 3 жыл бұрын
clearly, no.
@PierredeCur
@PierredeCur 3 жыл бұрын
As a retired programmer who has gone trailblazing through all these paradigms - beginning with assembler too -, I completely agree with you about the *constraints* and their vital importance. Not only that, but, being also a poet of the kind who writes mainly sonnets in alexandrines according to the rule of classical poetry (in French), it's also under the strictest constraints that the best verses have been made. In C, I always worked under a shell of constraints, some general, but most built ad hoc for each project, that took me so much time that it was often criticized because I would never be on time, but I never failed a deadline and my team always ended its job before the rest.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes I think in very open languages like assembler and C, we invented our own constraints from self-defense. I certainly had common approaches in both for certain types of problems.
@PierredeCur
@PierredeCur 3 жыл бұрын
@@ContinuousDelivery it's funny how I often receive as a poet the same kind of criticism as a coder, be it for the "freedom" of the free verses or of the goto... :-) But I see the constraints of my code as I see those of the sonnets and alexandrines, not as chains that limit me, but like a frame, a foundation on which to pose my words or code. :-)
@arbdistress5592
@arbdistress5592 3 жыл бұрын
Of all those pros and cons mentioned, the ability to naturally run functional programs in parallel is the unique key reason that it became more popular than before. Functional languages existed long long ago but they were never been mainstream like those procedural / OO paradigm back then during the days most of our machines cpu were just single core. Many of these older FP languages like Scheme were more like a computer science / AI research language where you can auto generate programs genetically by view FP as trees and crossover with their nodes.
@skurella
@skurella 3 жыл бұрын
What on earth is the listing at 14:42 supposed to be? It's missing a double semicolon before the type signature, the first case is wrong (the argument should be a list and is an element), the case of an empty list as input is completely ignored. 1 bug / LOC. I'm afraid this gentleman has little credibility when it comes to functional programming.
@caseyhawthorne7138
@caseyhawthorne7138 3 жыл бұрын
Yes, you can write good code in any language The issue is, whether others can READ your code 🖖
@wusheeify
@wusheeify 3 жыл бұрын
This video provides a good overview, I specifically enjoyed the brief history lesson at the start. However, I disagree with some points. I don't fully buy the "functional programming = math" premise, and the "therefore, OO is easier to understand" argument. I consider it a straw man. I am not a mathematician, nor am I thinking like one, yet I am perfectly able to understand FP. I don't agree that OO is better suited to modeling a problem domain. I can recommend the talk "domain modeling made functional" by Scott Wlaschin, and his book of a similar name. He demonstrates, how modeling a problem domain is very well suited to the functional paradigm. See the talk here: kzbin.info/www/bejne/hn2pnWxrmJJ8n7c Similarly, the comprehensibility examples are less "functional vs not functional", more "declarative vs imperative implementation". But that doesn't matter. What counts is the "public interface" (so to speak) of a function. All the examples are "pure" (as in: effect-free), and can be considered functional. In fact, the Java example is a pure function, who cares about the internal implementation details? Overall, the issues expressed in this video with functional programming come from a place of inexperience with the paradigm, I believe. That being said, FP does have many issues. Off the top of my head: 1. I recommend "The Death of Tagless Final" by John A. De Goes, who goes deep into issues with abstraction on the higher end of functional programming. 2. A high learning curve, especially for (arguably) necessary abstractions to build entire systems in FP. 3. Requires lots of support from the runtime or libraries to be efficient (e.g. persistent data structures, tail call optimization, etc.).
@mennekamminga600
@mennekamminga600 3 жыл бұрын
I am currently writing a game: I have this class representing the game's state. It has a method "advance" that takes user input as parameter and returns a new state. the method is marked const, so that I never accidentally change the previous state... The whole thing uses polymorphism extensively, and blends in the functional ideas of limited assignment. (Language: C++) Having access to both the previous state and a new state means I can do things like delta compression and recording of gameplay demo's.
@sauravthegreat
@sauravthegreat 3 ай бұрын
"OO programmers think of programming as modelling, Functional programmers think of programming as mathematics " I think the spanner in the works is that new age databases are shaping up to do the modelling part inside of them,leaving the mathematical part to the program running outside of it
@konstantingavrilov7748
@konstantingavrilov7748 3 жыл бұрын
You’ve just described Erlang and Elixir at the end. And I’m sure, sir, you’re very familiar with them :)
@AlexandreZandaoDrummond
@AlexandreZandaoDrummond 3 жыл бұрын
He describes the Actor Model, which applies to the BEAM vm (Elixir, Erlang), but also to the Actor Model implementation to the JVM called Akka, and many other implementations
@rickwalters8553
@rickwalters8553 3 жыл бұрын
Hadn’t heard of Akka… thanks for that!
@kguentube
@kguentube 3 жыл бұрын
great video! alternative paradigm mentioned on last minutes sounds me like erlang/elixir :)
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes I think that it is at least very similar. It is a form of Actor model, when my team 'invented' a version of it for the exchange that we built, we did this at an architectural level, rather than a language level, but the ideas certainly hold. The other system that is like this is Akka from Lightbend.
@kguentube
@kguentube 3 жыл бұрын
@@ContinuousDelivery Don't you think that, in a way, actor models or erlang are closer to Alan Kay's OO than Java or C++ ?
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
@@kguentube Yes, I think that they might be.
@isaacamezcua2315
@isaacamezcua2315 3 жыл бұрын
Excellent video! I personally prefer languages that mixes both, OO and FP such as Scala. I am feeling that the more I gain expertise from each paradigm, the better I am coding using both approaches at the same time.
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Yes, I agree, this shouldn't be about waring camps, ultimately it is about haveing access to a selection of tools that we can apply, as appropriate, to the job in-hand.
@teeesen
@teeesen 3 жыл бұрын
More and more I’m doing OO with immutable objects. Scala is perfect for this, but it can be done in any OO language.
@defeqel6537
@defeqel6537 3 жыл бұрын
@@teeesen my dearest hope is for C/C++ compatible language which would basically be C++, but with better defaults (e.g. mutable instead of const, for both variables and methods, and for both definitions and call sites)
@teeesen
@teeesen 3 жыл бұрын
@@defeqel6537 One of Ric Holt’s language design principles is “usage shortens form”; for example in Turing it is easier to write an output statement that puts an newline at the end than one that doesn’t because the former is the more commonly used case. But there is a related principle “shortness forms usage”; make it easier to write correct code than incorrect.
@fat_pigeon
@fat_pigeon 3 жыл бұрын
@@defeqel6537 The problem is that C++ has deeper design flaws that can't be fixed by flipping defaults and similar superficial changes. For example, argument-dependent lookup is an incoherent hack, but enough of the rest of language depends on it that replacing it with sane namespace semantics would break compatibility.
@rumble1925
@rumble1925 3 жыл бұрын
The haskell sum can be expressed in javascript as const sum = (list) => list.reduce(add, 0); I think this concept is definitely more readable when you use a familiar syntax
@gilbertleblanc9358
@gilbertleblanc9358 3 жыл бұрын
I spent most of my career as a COBOL developer doing data processing, starting in 1977. Every shop I worked in had a style guide to constrain us and allow us to focus on solving the problem. We were able to take entire COBOL programs, change a few variable names to protect the innocent, and create new programs in a manner of hours or days. I spent a few years as a Java Swing developer, and it took me almost a year of Java development before I really understood objects and object orientation. A COBOL coworker used to joke that Java development was just knowing which JVM classes and methods to assemble into an application. He encountered a rude awakening when he tried to create a simple Java Swing application to manage the COBOL systems error log.
@DeanPickersgill
@DeanPickersgill 3 жыл бұрын
Excellent lecture, I'll show this to my students as a way of backing up my 'chaotic paradigm switching' theories - I always tell 'em to switch freely and happily between the methods that work best.
@VuDangNgoc
@VuDangNgoc 3 жыл бұрын
Languages are tools to translate your mindset to compiled code
@umr3179
@umr3179 3 жыл бұрын
like ruby, a crap language like Japanese
@cuineform3708
@cuineform3708 3 жыл бұрын
Functional programming for me is a different way of thinking. I learnt Haskell recently and I think one of its strongest points is it's recursion. The easy functions in OO don't look easy in Haskell as you showed. However the easy recursive functions in Haskell look hard in OO. I also think that programming constantly in OO makes you forget what can be very confusing. Like the standard for loop in java takes a while to get what is actually going on. Like the standard function in Haskell takes a while to understand.
@pee-buddy
@pee-buddy 3 жыл бұрын
Every one can throw the word easy around until you give a total novice, someone without any programming background the task of understanding the different code styles. Then the truly easier solution will come to light.
@jakobstengard3672
@jakobstengard3672 2 жыл бұрын
What you lose when you do asynchronous communication between your modules is something that we all love: - The call stack Now it becomes diffucult to have a callstack, and that is what async/await solves. But instead you can start building process managers, agents or actors, what ever you want to call them. State machines that deal with state in absense of a stack. However, debugging and reasoning about such systems is hard.
@bappaichotu
@bappaichotu 3 жыл бұрын
after many years of programming (26 ) to be exact I have seen sbdy really speaking of the programming language design. This is really beautiful.
@DimageSapelkin
@DimageSapelkin 3 жыл бұрын
I think the functional style is completely misrepresented here. Reducing functional style to just immutability is not a correct description. What you call polymorphism is an inherent trait of pretty much all functional languages, and is typically declared and used in a simpler way in these languages than typical OO languages. "Closer to the natural way of thinking" depends on how you were taught to think. I'd argue that functional way is closer to the natural way of thinking, at least because it's declarative, not imperative
@zellthatsme
@zellthatsme 3 жыл бұрын
I agree. From my perspective, working across both paradigms, the key difference is the separation of data (state) from functions. Even haskell has mutable data structures if you need them. Immutability and functional pureness just provide a lot of benefits when combined with a function approach e.g. Infallible tests and natural parallelization.
@finnianreilly1831
@finnianreilly1831 3 жыл бұрын
"How can you have a conversation about programming constraints without mentioning design by contract?", says an Eiffel programmer. Eiffel of course, is the great exemplar of this innovation.
@tullochgorum6323
@tullochgorum6323 3 жыл бұрын
Ada/SPARK has taken design by contract to a new level in the 2012 release. To the point that you can formally prove your system. If design by contract is your thing, you owe it to yourself to check out SPARK. Nowadays the vendors offer open-source/free-to-use versions for personal use. The downside is that expressing your constraints in SPARK is a lot of work. The upside is that you need to do less Unit Testing.
@dealloc
@dealloc 3 жыл бұрын
The last part of the video sounds like Erlang and Elixir (which is also based on Erlang and runs on Erlang VM).
@asdfghyter
@asdfghyter 3 жыл бұрын
Since Haskell is much better at polymorphism than Java, would you say that it's more OO than Java?
@NullLabs
@NullLabs 3 жыл бұрын
Want to say I really appreciate your video and am going to be promoting your video on my channel! awesome discourse on the subject! Keep up the awesome work!
@ContinuousDelivery
@ContinuousDelivery 3 жыл бұрын
Thank you for your support!
Why Pull Requests Are A BAD IDEA
19:13
Continuous Delivery
Рет қаралды 232 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Functional Programming & Haskell - Computerphile
9:19
Computerphile
Рет қаралды 675 М.
The Problem With Microservices
17:47
Continuous Delivery
Рет қаралды 438 М.
Is Functional Programming DEAD Already?
21:07
Continuous Delivery
Рет қаралды 76 М.
Avoid These Common Mistakes Junior Developers Make!
17:54
Continuous Delivery
Рет қаралды 158 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 591 М.
Continuous Integration vs Feature Branch Workflow
17:31
Continuous Delivery
Рет қаралды 194 М.
Object Oriented Programming is not what I thought - Talk by Anjana Vakil
38:51
If Your Code Looks Like This... You're A GOOD Programmer
16:39
Continuous Delivery
Рет қаралды 78 М.
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 255 М.
Programming Paradigms - Computerphile
10:44
Computerphile
Рет қаралды 687 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН