Object Oriented Programming vs Functional Programming

Sdílet
Vložit
  • čas přidán 9. 06. 2024
  • Object-Oriented Programming has been the dominant approach for the past couple of decades, but Functional programming languages are growing in popularity and influence. So is OO programming outdated? Is Functional programming a fashion that simply misses the point?
    Many Functional programmes think that Object Oriented programming is bad. Many OO programmers think that Functional Programming is not scalable, what is the truth?
    In this episode, Dave Farley explores the software engineering question of object-oriented vs functional programming. Where did these ideas come from, what do they mean and why do they matter. Also, are there other ideas that may be coming in future?
    -------------------------------------------------------------------------------------
    Also from Dave:
    🎓 CD TRAINING COURSES
    If you want to learn Continuous Delivery and DevOps skills, check out Dave Farley's courses
    ➡️ bit.ly/DFTraining
    📧 Get a FREE guide "How to Organise Software Teams" by Dave Farley when you join our CD MAIL LIST 📧
    The best way to keep in touch with the latest discussions, events and new training courses, get FREE guides and exclusive offers. ➡️ www.subscribepage.com/organis...
    -------------------------------------------------------------------------------------
    📚 BOOKS:
    📖 Dave’s NEW BOOK "Modern Software Engineering" is now available on
    Kindle ➡️ amzn.to/3DwdwT3
    In this book, Dave brings together his ideas and proven techniques to describe a durable, coherent and foundational approach to effective software development, for programmers, managers and technical leads, at all levels of experience.
    📖 "Continuous Delivery Pipelines" by Dave Farley
    paperback ➡️ amzn.to/3gIULlA
    ebook version ➡️ leanpub.com/cd-pipelines
    📖 The original "Continuous Delivery" book by Dave Farley and Jez Humble
    ➡️ amzn.to/2WxRYmx
    -------------------------------------------------------------------------------------
    CHANNEL SPONSORS:
    Equal Experts is a product software development consultancy with a network of over 1,000 experienced technology consultants globally. They increase the pace of innovation by using modern software engineering practices that embrace Continuous Delivery, Security, and Operability from the outset ➡️ bit.ly/3ASy8n0
    Harness helps engineers and developers simplify and scale CI/CD, Feature Flags and Cloud Cost Management with an AI-powered platform for software delivery. ➡️ bit.ly/3Cfx3qI
    Octopus are the makers of Octopus Deploy the single place for your team to manage releases, automate deployments, and automate the runbooks that keep your software operating. ➡️ octopus.com/
    SpecFlow Behavior Driven Development for .NET SpecFlow helps teams bind automation to feature files and share the resulting examples as Living Documentation across the team and stakeholders. ➡️ go.specflow.org/dave_farley
    -------------------------------------------------------------------------------------
    REFERENCES
    A History of Programming Languages ➡️ cs.brown.edu/~adf/programming...
    “The Last Programming Language” Bob Martin ➡️ • The Last Programming L...
    “GOTO statement considered harmful”, Edsger Dijkstra ➡️ homepages.cwi.nl/~storm/teach...
    Edsger Dijkstra ➡️ en.wikipedia.org/wiki/Edsger_...
    “The forgotten history of OOP”, Eric Eliot ➡️ / the-forgotten-history-...
    "The Reactive Manifesto", Jonas Bonér, Dave Farley, Roland Kuhn, and Martin Thompson, ➡️ www.reactivemanifesto.org/
  • Věda a technologie

Komentáře • 2,4K

  • @mikefromwa
    @mikefromwa Před 2 lety +3162

    "Let's be clear, you can write crap code in any paradigm"
    I see you're familiar with my work...

    • @fleetingfootnotes9133
      @fleetingfootnotes9133 Před 2 lety +56

      ...sounds like you're setting yourself up for a couple of copyright infringement lawsuits. :P

    • @Dschinny2004
      @Dschinny2004 Před 2 lety +39

      shut up both of you. he meant MY work!

    • @oldcountryman2795
      @oldcountryman2795 Před 2 lety +17

      The only thing that determines the “quality” of your code is how much you (or your employer 😉) can get paid for it.

    • @thegamingdemon4788
      @thegamingdemon4788 Před 2 lety +7

      Shut up all of you, he's talking about MINE.

    • @tommornini2470
      @tommornini2470 Před 2 lety +15

      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 Před 3 lety +921

    "It's not about objects, it's about sending a message" :-)

    • @irok1
      @irok1 Před 3 lety +12

      Lol, nice

    • @badradish2116
      @badradish2116 Před 3 lety +8

      omfg winning

    • @cosmic53
      @cosmic53 Před 3 lety +11

      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 Před 3 lety +35

      Understanding that OO is actually not about inheritance is an awesome moment of enlightenment I hope all programmers cherish reaching.

    • @ivanmoen9982
      @ivanmoen9982 Před 3 lety +7

      @@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..

  • @mike.hawk_
    @mike.hawk_ Před 3 lety +817

    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 Před 3 lety +37

      Scala programmers: let’s make a functional programming language with four new styles of classes

    • @Megalomaniakaal
      @Megalomaniakaal Před 3 lety +53

      @@dexterantonio3070 "Let us increase class struggle"
      Wait. Wrong topic, my bad...

    • @DudeWatIsThis
      @DudeWatIsThis Před 3 lety +56

      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 Před 3 lety +9

      @@DudeWatIsThis C# is terrible only java is worse, but point taken

    • @janglestick
      @janglestick Před 3 lety +8

      @@Megalomaniakaal lol Class struggle

  • @h4plugins334
    @h4plugins334 Před 3 lety +185

    "You can write crap code in ANY paradigm" - You been looking over my shoulder ? :)

  • @ducodarling
    @ducodarling Před 3 lety +1903

    I feel like I'm in programmer church, listening to a sermon

    • @TaylorIserman
      @TaylorIserman Před 3 lety +51

      That’s super accurate actually

    • @davem.8681
      @davem.8681 Před 3 lety +28

      Duco Darling Speaking of sermons, I believe that object oriented programming is one of the great deceptions.

    • @vladimirljubopytnov5193
      @vladimirljubopytnov5193 Před 3 lety +33

      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 Před 3 lety +19

      @@vladimirljubopytnov5193 rebased
      edit: and f-pilled

    • @ironmagma
      @ironmagma Před 3 lety +3

      @@flightrisk7566 f-pilled 😂😂😂😂😂😂 I'm going to start using that ASAP

  • @travis1240
    @travis1240 Před 3 lety +685

    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 Před 3 lety +55

      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 Před 3 lety +40

      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 Před 3 lety +32

      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 Před 3 lety +1

      Exactly.

    • @w41g87
      @w41g87 Před 3 lety +3

      But how do you decide which paradigm will induce less cognitive load beforehand?

  • @Pedro5antos_
    @Pedro5antos_ Před 3 lety +304

    10:54 "let's be clear, you can write crap code in any paradigm!"

    • @aloisxyz
      @aloisxyz Před 3 lety +2

      but particularly in oo

    • @axea4554
      @axea4554 Před 3 lety +1

      Nice, then I can just pick any paradigm

    • @jamesgg9950
      @jamesgg9950 Před 3 lety +1

      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 Před 2 lety +1

      I can confirm this statement.

    • @neon13x
      @neon13x Před 2 lety +2

      I write crap code and I can confirm this.

  • @marcosdiez7263
    @marcosdiez7263 Před rokem +6

    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.

  • @Mark73
    @Mark73 Před 3 lety +770

    "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 Před 3 lety +63

      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 Před 3 lety +44

      That sounds like a story worth telling. Thanks for the rabbit hole.
      EDIT: oh, its a myth.

    • @ricosrealm
      @ricosrealm Před 3 lety +58

      640kb is all the memory anyone would need

    • @imrematajz1624
      @imrematajz1624 Před 3 lety +6

      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 Před 3 lety +8

      @@imrematajz1624 Wrong patent office. Einstein worked in one in Europe. The one that was to be shut down was in Washington, DC.

  • @ContinuousDelivery
    @ContinuousDelivery  Před 3 lety +571

    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 Před 3 lety +24

      I once gave a presentation on why copy-paste is evil, so seeing "contrains" pop up over and over made me chuckle.

    • @michaelmiller237
      @michaelmiller237 Před 3 lety +28

      Not typos, undocumented features.

    • @mayabartolabac
      @mayabartolabac Před 3 lety +12

      Another correction: Haskell's sum function should be:
      sum :: [Int] -> Int
      sum [] = []
      sum (n : ns) = n + sum ns

    • @dtkedtyjrtyj
      @dtkedtyjrtyj Před 3 lety +38

      @@mayabartolabac That gives my brain a TypeError, shouldn't it be
      sum :: [Int] -> Int
      sum [] = 0
      sum (n : ns) = n + sum ns
      ?

    • @mayabartolabac
      @mayabartolabac Před 3 lety +3

      @@dtkedtyjrtyj ooooohhhhh right thanks for letting me know

  • @ianollmann9393
    @ianollmann9393 Před rokem +16

    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.

  • @sunshinelizard1
    @sunshinelizard1 Před 2 lety +110

    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.

    • @MP-mx9nf
      @MP-mx9nf Před 9 měsíci +3

      the ease of testing has nothing to do with the paradigm. oop or functional. but about the nature of the function. as long as your function is pure and I/O, testing it is simple. as soon as it has to interact with the outside world, things get more complicated. both in FP and OOP or whatever else paradigm you want to think of

    • @D4no00
      @D4no00 Před 5 měsíci +2

      @@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.

  • @sryx
    @sryx Před 3 lety +241

    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 Před 3 lety +16

      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 Před 3 lety +10

      @@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 Před 3 lety +8

      @@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 Před 3 lety +6

      wait… You wrote software for years without understanding recursion? Yeesh

    • @caseyhawthorne7138
      @caseyhawthorne7138 Před 3 lety +9

      @@pmarreck That was a bit loopy 🖖

  • @fburton8
    @fburton8 Před 3 lety +227

    The mistake is to believe a single paradigm is the best approach to solving all problems.

    • @vitalyromas6752
      @vitalyromas6752 Před 3 lety +11

      @@LegendLength Scratch?

    • @eduarddumitru1
      @eduarddumitru1 Před 2 lety

      @@LegendLength i worry about dealing with merge conflicts / viewing a diff between version A of such a visual creation and version B

    • @berylliosis5250
      @berylliosis5250 Před 2 lety +14

      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 Před 2 lety +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 Před 2 lety +1

      @@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?

  • @nathanarnold7661
    @nathanarnold7661 Před 2 lety +61

    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 Před rokem +6

      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 Před rokem

      @@markdewey6788 how long did it take for you to learn FP? And how long to really appreciate the concepts

    • @markdewey6788
      @markdewey6788 Před rokem +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 Před rokem

      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 Před rokem +2

      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.

  • @magiclover9346
    @magiclover9346 Před 2 lety +36

    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.

  • @user-hk3ej4hk7m
    @user-hk3ej4hk7m Před 3 lety +20

    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 Před 3 lety +4

      Yeah, the niceness is like an optimisation that is possible because of the lack of side effects.

  • @rhbvkleef
    @rhbvkleef Před 3 lety +68

    You essentially described Erlang with that message passing example.

    • @gregbigwood4532
      @gregbigwood4532 Před 3 lety +9

      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 Před 3 lety +2

      I only managed to write a "hello world" example in Erlang, but I definitely got that vibe too.

    • @HansTheGeek
      @HansTheGeek Před 3 lety +13

      @@nwoDekaTsyawlA Try elixir it is a “modern” erlang and it is great

    • @JohnDavidDunlap
      @JohnDavidDunlap Před 3 lety +2

      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 Před 3 lety

      @@JohnDavidDunlap that’s right. On the other hand how should the suggested system work without copying?

  • @williamheymann8180
    @williamheymann8180 Před 3 lety +31

    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 Před 2 lety +6

      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 Před 8 měsíci

      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.

  • @simonr7097
    @simonr7097 Před 3 lety +5

    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).

  • @TinBryn
    @TinBryn Před 3 lety +22

    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 Před 2 lety +1

      Nothing new under the sun! I'll have to add it to my reading list, sounds interesting.

    • @TigercatDesigns
      @TigercatDesigns Před rokem +1

      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 Před rokem +1

      @@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 Před rokem +1

      @@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.

  • @mattiasmartens9972
    @mattiasmartens9972 Před 3 lety +83

    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 Před 2 lety +10

      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 Před rokem +4

      You don't need duck typing to achieve polymorphism. Just generics and typeclasses.

    • @gustavoandrade58
      @gustavoandrade58 Před rokem +9

      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 Před rokem +7

      @@gustavoandrade58 I am a Typescript programmer.

    • @simonpettersson6788
      @simonpettersson6788 Před rokem +1

      Polymorphism is widely used in functional languages too, i.e. type classes in Haskell and row polymorphism in Elm.

  • @onthecodeagain
    @onthecodeagain Před 2 lety +111

    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 Před rokem +3

      there are many problems: dead line , time to market ...etc.

    • @claudiubele4892
      @claudiubele4892 Před rokem

      the more you do the more you learn because you are the one writing your own projects

    • @jonbezeau3124
      @jonbezeau3124 Před rokem +1

      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 Před rokem

      "...part oo, part functional, part structured..."
      JavaScript: "Someone said my name?"

    • @kikoyz
      @kikoyz Před rokem +1

      @@paulkanja the only thing 'functional' about javascript is it uses functions. 😁

  • @llpBR
    @llpBR Před 3 lety +9

    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.

  • @rcrawford42
    @rcrawford42 Před 3 lety +159

    The hardest part of reactive programming is convincing management, especially those who were once developers.

    • @ZigzauerLT
      @ZigzauerLT Před 3 lety +36

      and they are not always wrong :)

    • @parlor3115
      @parlor3115 Před 3 lety +32

      @@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 Před 3 lety +71

      @@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 Před 3 lety +24

      on the frontend, the hardest part is convincing people that reactivity isn't always good =)

    • @brooksfire9580
      @brooksfire9580 Před 3 lety +53

      ​@@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.

  • @willful759
    @willful759 Před 3 lety +31

    "... 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 Před 3 lety +4

      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 Před 3 lety +7

      Fun fact: Lisp influenced the first OO languages.

    • @willful759
      @willful759 Před 3 lety

      @ཀཱ yeah, I didn't mean to say he was wrong, I was just adding to that statement

  • @mc.ivanov
    @mc.ivanov Před 2 lety +12

    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 Před 6 měsíci +1

      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 Před 5 měsíci +1

      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.

  • @ContinuousDelivery
    @ContinuousDelivery  Před rokem

    Sharpen your modern software engineering skillset with Continuous Delivery's online courses, presented by Dave. Whether you're a developer, development team leader, or an entire organisation striving to provide quality software... There is no better place to focus your efforts in learning to build better software faster. TAKE A LOOK HERE ➡ courses.cd.training/

  • @foxoninetails_
    @foxoninetails_ Před 3 lety +43

    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 Před 3 lety +2

      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 Před 2 lety

      Word

    • @SimonWoodburyForget
      @SimonWoodburyForget Před 2 lety +3

      You're missing the point of a paradigm though. The idea with ensuring you stick to a paradigm, is to allow the human brain to function efficiently. A code base is like a honeycomb structure for brains: you've seen one part of it, and you can easily keep repeating the same patterns for other parts of it, and it has nothing to do with solving problems faster, but purely about being capable meshing things together in such a way that they just work. The problem with jumping between OO and FP is that you fall into a pattern of switching between potentially incompatible patterns.
      If you play around too much with the paradigms (have your cake and eat it), you're going to confuse everyone who comes into the code base, so sticking to a small subset of either paradigms is extremely useful (if not absolutely required). For the same reason you don't build a house out of random objects you find on the street, you're not going to build a code base out of random paradigms you've found on Reddit. The larger number of paradigms you follow, the higher the complexity of your code base, and this is why people like to stick to either OO or FP, as those are the current high level seperations, and so it's the typical rough barrier of abstraction.
      You might *want* to treat paradigms as a "tool" but they're not a "tool"... they're a religion. The style of code base you go with isn't going to be based on scientific assumptions. It's not going to be scientifically proven to be the best way to go about things. You probably haven't even run double blind studies to figure out which pattern is best. This is what seperates art from science, or religion as you have it. The paradigm is in of itself simply a philosophy, so thinking of it like a "religion" isn't even incorrect in the slightest, because we pretty much are just making it up as we go.... I mean other then the fact that it's totally not a religion.

    • @klausehrhardt4481
      @klausehrhardt4481 Před 2 lety +1

      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_ Před 2 lety +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.

  • @royfu4971
    @royfu4971 Před 3 lety +71

    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  Před 3 lety +12

      Thanks, yes, it is very like Erlang.

    • @TheDerwisch77
      @TheDerwisch77 Před 3 lety

      @@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 Před 3 lety +1

      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 Před 3 lety

      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 Před 3 lety

      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.

  • @dm9910
    @dm9910 Před rokem +24

    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 Před 9 měsíci

      Look to SOLID

    • @V000idZer000
      @V000idZer000 Před 8 měsíci

      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.

  • @maddmethod5880
    @maddmethod5880 Před 2 lety +4

    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

  • @madhupramod
    @madhupramod Před 3 lety +75

    Why don’t you like async await? I’d love to hear more of your thoughts on that

    • @KangJangkrik
      @KangJangkrik Před 3 lety +1

      Yeah I want to know too!
      To be honest it's better than Kotlin's coroutine in term of syntax length

    • @AntonMochalin
      @AntonMochalin Před 3 lety +2

      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 Před 3 lety +5

      @@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 Před 3 lety +6

      Because it’s not deterministic, and can be memory unsafe.

    • @norpriest521
      @norpriest521 Před 3 lety +4

      @@airman122469
      What the hell are you guys talking about? 😂
      And why Arts student like me is in here?😂

  • @pedrobotsaris2036
    @pedrobotsaris2036 Před 3 lety +39

    In the end off the video you got close to describing Erlang which is a functional language

    • @TomislavJakopanec
      @TomislavJakopanec Před 3 lety

      Was just thinking that also :-P

    • @JustHeathen
      @JustHeathen Před 3 lety +1

      Exactly, Erlang and/or Elixir, pretty close description :)

    • @AustinSalonen
      @AustinSalonen Před 3 lety

      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 Před 3 lety

      I used erlang but now use golang with nats . Very similar patterns

    • @HansTheGeek
      @HansTheGeek Před 3 lety

      What makes elixir so flexible are macros. That’s another dimension not mentioned in the Video. Code that generates code.

  • @imadetheuniverse4fun
    @imadetheuniverse4fun Před 2 lety +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.

  • @supercheetah778
    @supercheetah778 Před 3 lety +8

    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 Před rokem

      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.

  • @xenopheliac7202
    @xenopheliac7202 Před 3 lety +102

    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 Před 3 lety +65

      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 Před 3 lety +15

      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 Před 3 lety +14

      @@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 Před 3 lety +8

      @@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 Před 3 lety +6

      @@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?

  • @StefaanHimpe
    @StefaanHimpe Před 3 lety +5

    A very interesting book in this context (in my opinion) is "Concepts, techniques, and models of computer programming" by Peter Van Roy.

  • @TheIst0NE
    @TheIst0NE Před 2 lety +1

    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!

  • @tommornini2470
    @tommornini2470 Před 2 lety +5

    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 Před 9 měsíci +1

      Also in OTP directly from erlang or through elixir.

  • @Twisol
    @Twisol Před 2 lety +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  Před 2 lety +1

      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.

  • @larryculver4375
    @larryculver4375 Před 3 lety +3

    In college I spent some time learning how to unfold recursion. Now we are trying to fold it back together again.

  • @mtnygard
    @mtnygard Před 3 lety +1

    Dave, the framing around paradigms as constraint is really good. Regarding constraining synchronicity, your description sounded close to the actor model.

  • @acobster
    @acobster Před 3 lety +24

    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 Před 3 lety +1

      You can do polymorphism without inheritance. Reflection is using that.

    • @fat_pigeon
      @fat_pigeon Před 3 lety +4

      For example, Haskell implements polymorphism using type classes, which constitute a very different approach from OO.

  • @JeffreyRennie
    @JeffreyRennie Před 3 lety +38

    Erlang very closely matches what you described in your reactive manifesto.

    • @AnupDhakalSharma
      @AnupDhakalSharma Před 3 lety +9

      Yeap! And I was thinking of Elixir.

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +3

      Yes, it does.

    • @openroomxyz
      @openroomxyz Před 3 lety

      Do you know any source where I could learn how to make the thing in C#?

    • @insertoyouroemail
      @insertoyouroemail Před 3 lety

      @@openroomxyz you can do erlang style programming in C# with Akka.NET and reactive programming with Rx.NET

    • @Qrzychu92
      @Qrzychu92 Před 3 lety +1

      @@AnupDhakalSharma but Elixir sucks because it is dynamicaly typed...

  • @PanduPoluan
    @PanduPoluan Před 3 lety +19

    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 Před 2 lety +1

      Why the quotes?? Lol…

    • @thefakepie1126
      @thefakepie1126 Před 2 lety +2

      your quotes makes it sound like an inuendo, yeah those """paradigms""" really are just """"tools"""" to really """""help""""" programmers

    • @AdobadoFantastico
      @AdobadoFantastico Před 2 lety

      @@thefakepie1126 maybe they're instructions for an esoteric language like RockstarLang, but you code everything through ambiguous sarcasm.

  • @andrew_ray
    @andrew_ray Před 3 lety +1

    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.

  • @dan9948
    @dan9948 Před 3 lety +3

    The argument about constraints is a nice refreshing view!

  • @adrianperez8695
    @adrianperez8695 Před 3 lety +82

    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 Před 3 lety +11

      The strength of the imperative style is that it's close to the hardware.

    • @sandipanumbc
      @sandipanumbc Před 3 lety +2

      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 Před 3 lety +1

      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 Před 3 lety +10

      @@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 Před 3 lety +1

      @@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.

  • @tomcowell9653
    @tomcowell9653 Před 3 lety +10

    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  Před 3 lety +6

      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 🤣

  • @macpmilo2020
    @macpmilo2020 Před 3 lety +1

    As a relatively newb to programming, this was really Insightful to me. I'm sure it'll allow me insights into the way I'm coding in the future. Thanks!

  • @mehtubbhai9709
    @mehtubbhai9709 Před rokem

    Hi Dave! Great talk as usual. Would definitely like to hear more abt constraining synchronicity.
    James Coplien worked on something called Trygve that is more closely aligned with Alan Kay's view of the OO paradigm.

  • @danieljensen2626
    @danieljensen2626 Před 3 lety +17

    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.

  • @peterpodgorski
    @peterpodgorski Před 3 lety +11

    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  Před 3 lety +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 Před 3 lety +4

      @@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 Před 2 lety

      @@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.

  • @h4plugins334
    @h4plugins334 Před 3 lety

    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 :)

  • @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

  • @austinabro2027
    @austinabro2027 Před 3 lety +61

    You should definitely go more in depth on your idea at the end in future videos!

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +24

      Will do, thanks.

    • @blitzkr1egg
      @blitzkr1egg Před 3 lety +5

      Maybe something about Sending async messages = actors

    • @viniciusgarcia3452
      @viniciusgarcia3452 Před 3 lety +2

      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 Před 3 lety +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 Před 3 lety +3

      @@viniciusgarcia3452 yes, and Erlang, though that is nearly the same thing as Elixir as I understand it.

  • @ajibolaoki5064
    @ajibolaoki5064 Před 3 lety +21

    only just realised I'm a functional programmer after watching this video. Keep it up!

  • @javaguy5783
    @javaguy5783 Před 3 lety +1

    Great Video, love to hear more on this topic !

  • @sourestcake
    @sourestcake Před 3 lety +25

    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.

  • @j-r-hill
    @j-r-hill Před 3 lety +23

    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 Před 3 lety +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 Před 3 lety +2

      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 Před 3 lety +1

      @@j-r-hill yes, you are completely right about that

    • @____uncompetative
      @____uncompetative Před 3 lety +1

      Every single paradigm is wrong.

  • @MaxHaydenChiz
    @MaxHaydenChiz Před 3 lety +14

    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 Před 3 lety

      A well-thought, well-written, relevant comment that offers valuable insight and provides a counterpoint to the video? What has happened to the CZcams I know?

    • @jakistam1000
      @jakistam1000 Před 3 lety

      @@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 Před 3 lety

      @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 Před 3 lety

      @@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. Před 3 lety

      The holy grail is a typed Excel (And I kinda wish I was joking), it would definitely solve the MARCH1 issue.

  • @L1da77
    @L1da77 Před 2 lety

    I love these kind of discussions. Not only claiming which is better but actually comparing and pointing at good and bad. Love it!

  • @cornelmasson4610
    @cornelmasson4610 Před 3 lety +26

    From another grey-headed programmer, well done. There is no silver bullet, just pragmatics.

  • @kguentube
    @kguentube Před 3 lety +10

    great video! alternative paradigm mentioned on last minutes sounds me like erlang/elixir :)

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +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 Před 3 lety +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  Před 3 lety +3

      @@kguentube Yes, I think that they might be.

  • @DeanPickersgill
    @DeanPickersgill Před 3 lety +9

    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.

  • @TsuruchiBrian
    @TsuruchiBrian Před 3 lety

    Is the concept you talk about at the end of your video basically what Qt signals and slots are doing?

  • @richardhasting6046
    @richardhasting6046 Před rokem +2

    Nicely done, simply explained. I would love to hear a conversation about how Java is moving towards functional concepts and creating something of a hybrid system.

  • @_indrid_cold_
    @_indrid_cold_ Před 3 lety +5

    12:30 Absolutely agree and see this as a powerful argument for the functional approach. It forces me to understand what I’m trying to achieve with greater clarity and resolution. What a well thought out piece - thank you!

    • @otarshavadze9178
      @otarshavadze9178 Před 3 lety +5

      Few times I wrote code with "fancy" and short way. It worked for that moment, but after some time I had trouble and it take more time understand "what I tried here to do?"
      So i prefer bit longer, but more readable and understandable code.

  • @dealloc
    @dealloc Před 3 lety +10

    The last part of the video sounds like Erlang and Elixir (which is also based on Erlang and runs on Erlang VM).

  • @moczikgabor
    @moczikgabor Před 3 lety

    When you brought up synchronous processing with the addItem(x) message, my first thought was it also copies the data in memory to be safe, passing by reference does not really work here.
    And my second thought were, is there any language which uses copy-on-write variable management? For example the caller of additem allocates x, then passes the reference, then the receiver could use it as needed. Whichever thread is going to run, can access the same memory as long as it won't write it. The one who first does, it (the runtime subsystem) makes a new copy, then the other still references his old copy. Then the runtime could release (GC) those copies that are ran out of scope. So it is passing by reference in nature, it is as fast, but behaves like pass by value if by any chance accessed concurrently.
    It is undeterministic, maybe to much overhead, and I don't know, whether would it even have more practical use case than preventing an inherently badly designed system to fail.

  • @hri7566
    @hri7566 Před 3 lety

    At the end, with the synchronous stuff, I usually use event emitters in js to achieve this, especially with connections between computers when you don't know when you'll be receiving or sending messages

  • @felixlipski3956
    @felixlipski3956 Před 3 lety +6

    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?

  • @wusheeify
    @wusheeify Před 2 lety +14

    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: czcams.com/video/PLFl95c-IiU/video.html
    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.).

  • @NullLabs
    @NullLabs Před 2 lety

    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!

  • @rumble1925
    @rumble1925 Před 3 lety +2

    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

  • @ubercorey
    @ubercorey Před 3 lety +4

    Good lord, this is the most cogent explanation of programming ive heard since ive been learning the subject the last 6 months.

  • @dmitryplatonov
    @dmitryplatonov Před 3 lety +18

    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 Před rokem +5

      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 Před rokem

      Did C++ way before Java/C# came along.

    • @dmitryplatonov
      @dmitryplatonov Před rokem

      @@sis1296 yes, but that time it was not prevalent paradigm.

    • @acasualviewer5861
      @acasualviewer5861 Před rokem

      @@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 Před rokem

      @@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.

  • @PrimalCoder
    @PrimalCoder Před 2 lety

    First time watching one of your videos, and it is an instant like. Thank you for taking the time to share your experience and understanding.

  • @marshalsea000
    @marshalsea000 Před 3 lety

    Brilliantly presented, you have a new subscriber.
    The end comment of a new language paradigm is broadly described by mixing Event Driven and MicroService Architectures. This is now for a lot of developers, and an encouraged approach by AWS, Azure, GCP.
    For anyone interested in this, you need to be looking at Kafka (or other Stream oriented systems), and investigating Akka as this will give you a crash course in this area and cover a lot of the sub-architectural principals you need to understand (Event Sourcing, CRQS, Worker pattern).
    Also, the number of OO developers (and very senior ones at that) I've interviewed that do not understand polymorphism is painful. There's a reason there's an awful lot of bad OO code in the world - uneducated developers. Don't blame the language for stupid implementation.

  • @vicsteiner
    @vicsteiner Před rokem +19

    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 Před 11 měsíci

      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.

  • @Diginegi
    @Diginegi Před 2 lety +33

    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 Před rokem +8

      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 Před rokem

      @@gustavoandrade58 absolutely right!!!!

  • @siyaram2855
    @siyaram2855 Před 2 lety

    Namaskar,
    What a wonderful video.
    This is regarding the last part of tge video.
    What do you think of ErLang? Alan said it implements all what he thought of OO should be.
    I would be glad if you can elaborate on the last part of where you shared your own idea of a concurrency model. 🙏

    • @ContinuousDelivery
      @ContinuousDelivery  Před 2 lety

      Yes, Erlang is certainly very close, if not the same, idea. I have had it on my list of things to learn for some time. I talk about my version of that approach in more detail in this video: czcams.com/video/eRxLfUIMJwk/video.html

  • @jameslecka8085
    @jameslecka8085 Před rokem +1

    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?

  • @code_report
    @code_report Před 3 lety +6

    13:58 is an unfair comparison. FP solution should be: val x = someCollection.map(_.size).sum

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +2

      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 Před 2 lety

      @@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

  • @sendyofindia
    @sendyofindia Před 3 lety +3

    you mentioned that you hate async/await :)
    Please make a video for us regarding that

  • @c_b5060
    @c_b5060 Před 7 měsíci +1

    The most joy and the most satisfaction I got was from IBM mainframe (360 & 370) assembler language programming. I was ignorant of most "programming paradigms". I wasn't constrained. I was free! Free to do whatever I wanted. And my programs were readable and maintainable.

    • @lepidoptera9337
      @lepidoptera9337 Před 7 měsíci

      You aren't constrained in C, either. You can do any bullshit that you want with it... even inline assembly. x86 assembler is not much of a joy, though. ;-)

  • @arbdistress5592
    @arbdistress5592 Před 3 lety +2

    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.

  • @konstantingavrilov7748
    @konstantingavrilov7748 Před 3 lety +8

    You’ve just described Erlang and Elixir at the end. And I’m sure, sir, you’re very familiar with them :)

    • @AlexandreZandaoDrummond
      @AlexandreZandaoDrummond Před 3 lety +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 Před 3 lety

      Hadn’t heard of Akka… thanks for that!

  • @jonathanmoore5619
    @jonathanmoore5619 Před 3 lety +7

    The hardest part of programming... A good idea, elegance and knowing when to stop.

    • @brandonhale7574
      @brandonhale7574 Před 3 lety +1

      Wait, I need this feature! Just one more!

    • @NimhLabs
      @NimhLabs Před 3 lety +1

      Didn't Alan Turing say knowing when to stop was impossible?

    • @jonathanmoore5619
      @jonathanmoore5619 Před 3 lety +1

      @@NimhLabs wait... if I answer you, then... D'oh!

    • @NimhLabs
      @NimhLabs Před 3 lety

      @@jonathanmoore5619 I may or may not have been purposely misconstruing The Halting Problem for the purpose of being funny

    • @jonathanmoore5619
      @jonathanmoore5619 Před 3 lety +2

      @@NimhLabs stop... Just stop... :)

  • @maxlin5998
    @maxlin5998 Před 3 lety

    That restriction of synchronization reminds me of Solidity on the Ethereum network. Smart contracts can’t really interact synchronously with other smart contracts, but are pretty much a single thread or module by themselves. I’m still learning about them, so hopefully I didn’t mischaracterize anything, but this video was very insightful

  • @mennekamminga600
    @mennekamminga600 Před 2 lety +1

    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.

  • @davidjohnston4240
    @davidjohnston4240 Před 3 lety +15

    The primary idea of OO being primarily about messaging was exactly how it was taught to me in college circa 1990.

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +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 Před 3 lety +2

      OOP is not about messaging. That came from Smalltalk and it's just not how people understand and use OOP today.

    • @warferton6429
      @warferton6429 Před 3 lety +7

      @@Christobanistan The butchered understanding of OOP today and what OOP was intended to be are two almost completely different things

    • @Christobanistan
      @Christobanistan Před 3 lety

      @@warferton6429 It's not "butchered," it makes complete sense.

    • @dorcohen3522
      @dorcohen3522 Před 3 lety

      @@Christobanistan 7 levels of inheritance in some Java modules makes sense to no one.

  • @johnbrazil7
    @johnbrazil7 Před 3 lety +4

    The functional code at 14:00 is not correct. The parameter y isn't being used.

    • @johnbrazil7
      @johnbrazil7 Před 3 lety

      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 Před 3 lety

      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: czcams.com/video/US8QG9I1XW0/video.html
      I appreciate how you gave attention to asynchronous messages and message-oriented programming. +1

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety

      Yes, thank you, I have pinned a correction for the typo in these comments.

    • @ContinuousDelivery
      @ContinuousDelivery  Před 3 lety +1

      ​@@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 Před 3 lety

      @@ContinuousDelivery and are humans good classifiers? might be a good thing to constrain ...

  • @sis1296
    @sis1296 Před rokem

    I am an oop programmer trying to wrap my head around functional programming. Thank you for this video. I find the oop code in the examples mentioned more readable. However I do recognize that understanding an intricate matrix of classes takes time and is not immediately obvious. I wonder where did this functional programming renaissance come from? Is it because of GPU programming? Or simply because of many core multi-core processors?

  • @bappaichotu
    @bappaichotu Před 3 lety

    after many years of programming (26 ) to be exact I have seen sbdy really speaking of the programming language design. This is really beautiful.

  • @donedgardo
    @donedgardo Před 2 lety +5

    I agree with most of what your saying, and I believe that each OO and functional paradigms bring positives to any project.
    I've had a great experience using them both with the language Clojure.
    I don't think any other language lets you use these two paradigms in your own way.

  • @aDifferentJT
    @aDifferentJT Před 3 lety +3

    Have you seen Erlang? A functional language following the actor model, probably the purist embodying of what you describe as your OO design for concurrency.

  • @manuel-rubio
    @manuel-rubio Před 3 lety +1

    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.

  • @sunshinelizard1
    @sunshinelizard1 Před 2 lety

    I've also seen over the years where the latest/newest thing in programming is debated over such that one is more "right" than the other when the reality is it's best to understand when to use which. Agile processes are great, especially if done correctly, but "waterfall" has it's place - on sun setted projects where nothing new is being developed, just bug fixes and maintenance.
    When non-relational databases came out, like noSQL, it was supposedly modern and relational databases were old fashioned. Oh geez, it's very important to know which to pick or you're going to have to ask the business for funds to rewrite it when unexpected requirements eventually creep in.