Functional programming - A general introduction

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 210

  • @bryceeklund944
    @bryceeklund944 2 месяца назад +25

    as an idiot and also a java dev and java enjoyer this was very informative and entertaining, thank you & subbed

    • @DaedalusCommunity
      @DaedalusCommunity  2 месяца назад +4

      This is THE comment

    • @Lenjiy
      @Lenjiy 2 месяца назад +3

      you forgot to extend dozen more interface

  • @biskitpagla
    @biskitpagla Год назад +247

    the constant java bashing is totally appreciated, subbed

    • @lufenmartofilia5804
      @lufenmartofilia5804 8 месяцев назад +3

      Funny tho that C# is not bashed as it is just a mess in comparison espacially now with java 21

    • @OverrideTips
      @OverrideTips 8 месяцев назад

      @@lufenmartofilia5804we in Java 22 now 😮‍💨 and now it’s getting less verbose for beginners yay Java!😂

    • @diadetediotedio6918
      @diadetediotedio6918 6 месяцев назад

      ​@@lufenmartofilia5804
      A good and old coping, C# is much cleaner than Java generally. And Kotlin is way better than both.

    • @thessianheart9816
      @thessianheart9816 3 месяца назад

      I'm surprised that Java gets bashed but not C. I mean, Java is a piece of cake compared to C. And Python is a piece of cake compared to Java.

    • @KaiusKC
      @KaiusKC Месяц назад

      @@thessianheart9816it has nothing to do with (the subjective) perception of difficulty

  • @haleyhalcyon
    @haleyhalcyon Год назад +135

    if you chant “a monad is a monoid in the category of endofunctors” twice in the mirror at 3am something awesome will happen

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +31

      You immediately turn into a category equipped with a defunctor F : 💀 → C

    • @kamilziemian995
      @kamilziemian995 5 месяцев назад +2

      @@DaedalusCommunity True.

    • @zTJq40sl
      @zTJq40sl 6 дней назад

      Wouldn't that be a side effect?

  • @bharold
    @bharold Год назад +42

    I first became interested in functional programming when I noticed how Haxe's compiler code base, which transpiles/compiles to several other languages/VM bytecodes was so concise and efficient, especially given it's broad language output support.

  • @CorbinSimpson
    @CorbinSimpson Год назад +76

    Good introduction. Note that no "functional languages" in common use are pure. "pure functional programming", as a consequence, is not really a common practice. For example, Haskell has mutation in the IO monad, and GHC also has mutation in ST and STM monads. While structured and safe, these mutable variables are not pure.

    • @mr.m8539
      @mr.m8539 Год назад +25

      Haskell was a pure functional language and was given the mutable monads to be useful in the industry and not just an academic exercise.

  • @keshayio
    @keshayio 2 месяца назад +1

    Your cadence is impossible to predict. I am unable to anticipate when you will do this random 100-200ms pauses in your speech, you are an artist. Love the video. Cheers.

    • @DaedalusCommunity
      @DaedalusCommunity  2 месяца назад +3

      Yeah it's a combination of the way I use punctuation, deliberate short pauses that try to [pause...] **stress** a certain word, and honestly just random pauses introduced by mistake when cutting the SEVERAL audio takes, lol

  • @БогданСкулимовский

    Yaay! Thanks. Now I have basic idea about functional paradigm. (Sadly, I still don't know what a monad is, but this is my own adventure)

    • @Shifticek
      @Shifticek Год назад +14

      it's simple. Monad is just a monoid in the category of endofunctors🤓

  • @byrondumont-eve
    @byrondumont-eve 6 месяцев назад +1

    I have understood lambda calculus for almost a decade by virtue of doing quasi-functional programming in imperative languages. It wasn't until this video's simple and concise explanation that I realized that fact.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      Lambda calculus is mathematically equivalent to a Turing machine and it simply does not exist in reality. Your CPU doesn't have machine instructions to implement it. All you are doing here is to abstract your machine structure away. That works fine if you don't care about performance. Now try writing a non-trivial game in lambda calculus. That won't go anywhere but to dev0. ;-)

  • @nasko235679
    @nasko235679 Месяц назад

    I started learning elixir and just reading it feels like reading Chinese. This helped a lot! Thanks

  • @ananttiwari1337
    @ananttiwari1337 Год назад +19

    1:40 Love the Tom Scott reference lol

  • @calengo454
    @calengo454 Год назад +17

    didn't understand shit but definitely rewatching later to see if i can understand, because your explanation and your video seem very friendly and well executed

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +1

      If you have any questions I'll try to answer :)

    • @Rin-qj7zt
      @Rin-qj7zt Год назад +7

      yeah that's how it goes when learning complex or abstract, unfamiliar topics. you kinda just gotta keep revisiting it after breaks to weasel it into your brain. some people pick it up faster because they are already more familiar with similar concepts, but they'd have to do the same thing if they weren't.

  • @AK-vx4dy
    @AK-vx4dy 10 месяцев назад +3

    I'm enteriely sure, but C# (probably by near presence of F# team) evolves more and more in this direction: patter matching and expression version of things like switch etc.

  • @iham1313
    @iham1313 6 месяцев назад +2

    you got me at "private abstract anxious elaborate verbose void" :D

  • @soyitiel
    @soyitiel Год назад +9

    Question: @ 6:33, isn’t the function called inside my_sum supposed to be my_sum again?

  • @SwagDawg
    @SwagDawg Год назад +21

    I'm just about to finish a programming languages course at university where most of the class was focused on functional programming with OCaml and Racket. Honestly I like it a lot better than object oriented programming because of how elegant it is.

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +1

      Great! What's your uni?

    • @SwagDawg
      @SwagDawg Год назад +1

      @@DaedalusCommunity University of Washington. What about you?

    • @lawqup
      @lawqup Год назад

      I just graduated from UW this spring! Didn’t take programming languages though and now I’m regretting it….

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +2

      @@SwagDawg Sorry for the late response! I'm at the university of Pisa, in Italy

    • @abahiduh3246
      @abahiduh3246 7 месяцев назад

      What point are u making... Class focused on functional programming? the bases of OOP is classes explain pls

  • @bernardodomeneghetti9673
    @bernardodomeneghetti9673 Год назад +1

    8:27 is the moment you know, that u shouldnt be here anymore, even being warned before LMAO

  • @lucasfkam
    @lucasfkam Год назад +3

    What books or materials would you recommend that contain mathematical expressions and notations (such as lambda calculus expressions) to support functional programming?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +4

      "Types and programming languages" by Pierce is a very comprehensive book on the topic

  • @naimmomin5811
    @naimmomin5811 10 месяцев назад

    How does the code at 6:28 work when you gave sum 4 parameters but it only takes in two?

    • @DaedalusCommunity
      @DaedalusCommunity  10 месяцев назад

      We redefine sum in terms of my_sum, by passing the additional parameters. The initial values of the two additional parameters depend on a and b only (they are initialized to a and 0 respectively).

  • @imgeekboy
    @imgeekboy 29 дней назад

    5:23 I feel dense… 😅. How does (foo(2))(5) return 10 if 5 was never passed in?

    • @DaedalusCommunity
      @DaedalusCommunity  28 дней назад +1

      Because foo(2) returns a function that doubles its input. Let's call it f.
      foo(2) = f such that f(x) = 2x
      f(5) = 2*5 = 10
      Therefore:
      (foo(2))(5) = 10

    • @imgeekboy
      @imgeekboy 28 дней назад

      @ I guess the f(5) isn’t intuitive to me with (foo(2))(5) because my brain is reading it as (2x)(5) not (2 * 5). I appreciate you responding!

  • @olteanumihai1245
    @olteanumihai1245 6 месяцев назад

    underrated video and channel

  • @stoneman210
    @stoneman210 Год назад

    He's back. HE'S BACK

  • @aaronspeedy7780
    @aaronspeedy7780 Год назад +3

    Wouldn't using recursion instead of simple loops take up a lot of memory?

    • @jma42
      @jma42 Год назад +7

      yes, but if the language supports guaranteed tce then it wont be an issue.

  • @ZZaGGrrUzz
    @ZZaGGrrUzz 4 месяца назад +1

    Is there any real benefit of not using temporary variables inside a function?..

    • @DaedalusCommunity
      @DaedalusCommunity  4 месяца назад

      You can use them in functional programming as well in a way, they're just not quite "variables". E.g. you can do
      let x = e in e'
      where e' is an expression that uses x. The main difference is that the value of x is immutable, which is very convenient and is, as you may know, a key feature of rust.
      The reason I say it's covenient is that using temp variables to move information within your program makes for very error-prone code (especially if you're dealing with pointers and particularly null pointers), whereas you'll find that, if you program in rust or ocaml, there will just be fewer ways in which your code *can* be wrong. You'll eliminate a bunch of kinds of errors that are common for code written in an imperative style.

  • @kezif
    @kezif Год назад +10

    Sont ask woman here age
    Man his salary
    Functional programmer how to print out string

  • @j0hannes5
    @j0hannes5 Год назад

    I don't get the tail recursive example at 6:33
    how does the sum function receive 4 arguments?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      I guess one of them is redundant, c and res basically behave the same way

    • @soyitiel
      @soyitiel Год назад

      I think the function called inside my_sum is supposed to be my_sum again, hence recursion. The plain sum function is just a wrapper for my_sum

    • @kawo666
      @kawo666 Год назад

      Yes, as soyitiel said - function at line 4 should be my_sum. It seems to simply be a typing error

  • @disdroid
    @disdroid 8 месяцев назад

    process algebras aren't necessarily stateless - pi calculus involves the use of channels to send and receive functions, so the value being sent is the state of the channel. the mobile ambient calculus (and the more modern seal calculus) have a state attached to each process representing its location in a hierarchy of processes.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад +2

      Stateless programming has become the eschatological religion of those who are afraid of state. :-)

    • @disdroid
      @disdroid 3 месяца назад

      @@lepidoptera9337 nobody can tell me what state actually means - a function takes a parameter and it returns something so those are its state during it's application. A process must exists within a computational membrane of some kind, so it has a state representing its location, as well as channels through which it sends and receives messages which affect it's functioning so therefore represent its state. even a function or process that does absolutely nothing has a void state.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      @@disdroid Exactly. There is no such thing as stateless computing. That kind of thinking is a false abstraction. We are continuously modifying CPU registers, command and data pipelines, flags, the memory management unit, caches, hardware registers like timers etc. even if the actual user code doesn't perform any memory write operations. Functional programmers like to pretend that these things don't exist or that one does not have to care about them. That is total nonsense.
      Having said that, there are different kinds of state changes. Most state changes are desired, of course. They constitute the normal and correct execution of the program. The ones we have to be concerned about are those that lead to permanent, unrecoverable errors and that will require a restart of the software, lead to data loss, undetected false results etc.. One can not avoid the latter with any programming principles, paradigms, language features etc.. Good software design is all about making code resilient. Having an "undo" function, for instance, is way more important and useful than restricting or filtering user input for "illegal" entries. A functional programmer would scoff at that idea... we are, after all, creating copies of previous states. What a crime! But to a user having an "undo" means that they can experiment and explore the functions of the software without losing the data they have already entered.
      A creative programmer will smartly manage state rather than avoid creating it.

  • @Lado93
    @Lado93 Год назад

    6:38 isnt def sum(a,b) function supposed to have return too?

  • @pfever
    @pfever Год назад +1

    Is this programming paradigm useful in the industry? or just for rare jobs?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +1

      It has influenced the web dev industry greatly, which is adopting more and more functional traits. If you ever use React or similar frameworks, you'll see that the functional js features are very much used, and much more natural in that context. Other than that, it's probably just writing compilers and whatever Jane Street does, economics I guess, but it's nice that people and companies are starting to recognise its value

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад +1

      If you want to make enemies out of your colleagues... sure, go for it. ;-)

  • @kvelez
    @kvelez Год назад +1

    Awesome video.

  • @ImperiumLibertas
    @ImperiumLibertas 8 месяцев назад +5

    The idea that you shouldn't or cant assign the results of a function to a variable and pass the variable into another function is a terrible property/feature of functional languages.
    Assigning something to a variable isn't alwaus necessary but it can help to express what the return value represents.
    This named value or named function approach makes for a much more readable experience which should be a priority for any code base.

    • @DaedalusCommunity
      @DaedalusCommunity  8 месяцев назад +1

      Have a look at the do-notation in Haskell

    • @ImperiumLibertas
      @ImperiumLibertas 8 месяцев назад

      @@DaedalusCommunity I like that syntax a lot. It makes sense and reminds me of streams. I use very similar syntax in the Nix language with the let-in syntax.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      @@DaedalusCommunity It's a workaround so that functional programmers don't have to admit that functional languages don't work. ;-)

  • @taxi_a
    @taxi_a Год назад

    this is fire
    keep up with the good work

  • @YoshikoJanai
    @YoshikoJanai Год назад +1

    I wish my Programming Languages professor explained tail recursion the way you did. You condensed an entire unit and miserable explanations into like 5 seconds

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад +2

      Yes, it's identical to a loop... in other words... you don't need it. You just have to learn that you don't need it. Recursion in general is a bad idea, here you are simply being saved by the bell, so to speak.

  • @dan_bev
    @dan_bev Год назад +1

    What books do you recommend for these topics?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +1

      A good introduction to functional programming and cs in general (through Lisp) is Structure and Interpretation of Computer Programs (SICP). Another good book is "Types and Programming Languages" by Pierce, but it's very theory-heavy. Apart from SICP, once you know the basics you can pretty much learn by doing and reading the docs, but reading the more theoretical books can also be very insightful

  • @dermakol8543
    @dermakol8543 Год назад +3

    Awesome video as always. Hope some day you get a recognition you deserve!

  • @smritapokharel5983
    @smritapokharel5983 Год назад +1

    Love the music 💃

  • @olikat9774
    @olikat9774 Год назад +1

    6:33 is my_sum meant to be returning my_sum() instead of sum()

  • @MonsterSmart
    @MonsterSmart 9 месяцев назад

    So it mainly boils to the fact that you might pass a function as an argument and return a function from a function and all consequences of that.
    Which was always what I mostly identified with FP.
    And btw: I love it.

    • @DaedalusCommunity
      @DaedalusCommunity  9 месяцев назад

      Yes. Then in more pure languages there are constraints to the shape of the functions, but the main point is the one you underlined :)

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      You can pass a function as an argument in assembly language. The only difference is that an assembly programmer knows what she is doing and a functional programmer is too lazy to learn. ;-)

  • @AK-vx4dy
    @AK-vx4dy 10 месяцев назад

    Do you a part of team of Unison file synchronizaton tool ?
    Or all badly burn by Java finally find calm of soul in Ocaml ?

    • @DaedalusCommunity
      @DaedalusCommunity  10 месяцев назад +1

      I can scan this message, but I'm finding trouble parsing it lol

    • @AK-vx4dy
      @AK-vx4dy 10 месяцев назад

      @@DaedalusCommunity Some years ago, one team wanted to write good file synchronization tool and they done it in Ocaml and were on Ocaml page as case study and they were also badly burnt by Java.

    • @AK-vx4dy
      @AK-vx4dy 10 месяцев назад

      @@DaedalusCommunity
      let beloved_language = function
      | burn_by -> if burn_by = "Java" then "Ocaml"

  • @nbecnbec
    @nbecnbec Год назад +1

    Why were java lambdas a mistake?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      Because in order to introduce lambdas they had to add default implementations to interface methods, which not only defies the purpose of interfaces, but introduces lots of problems that come with multiple inheritance.
      Normal multiple inheritance (extends) is forbidden in java, but you can implement multiple interfaces. Unlike in C++, there is no way to perform disambiguation, so yeah, it's an absolute mess.

  • @bilditup1
    @bilditup1 4 месяца назад +1

    I think I understood how this works-great job there, I really appreciate it!-but not why I would ever want to use it. It seems substantially less clear and intuitive than writing in an imperative style, even in the off-chance that one is already familiar with lambda calculus. It seems like something that might have a kind of elegance or charm to it, but at the high cost of having to painstakingly rewrite your own ‘code’ in order to ever feel comfortable with it, akin to learning a foreign language (the kind that you speak, I mean) that uses an entirely different word order, set of characters, phonemes, etc from your native tongue (the difference being, I know why I’d want to do that, but not why I’d want to code functionally).
    I’m sure this is, somehow, a failure of imagination on my part. Can you maybe point to some simple code examples or real-life programs that might start to demonstrate why I’d want to do things this way?

    • @bilditup1
      @bilditup1 4 месяца назад

      …some of the other threads here have touched on this, but I’m still kind of curious about how using it in everyday situations rather than rarefied ones would be like. I’ll have to think on this/eventually try it, I guess

    • @DaedalusCommunity
      @DaedalusCommunity  4 месяца назад

      I think there are two main reasons to use functional languages or featutes. The first one, that I've talked about in other responses, is that functional features make for neater and less error-prone code. If you've ever used rust, you'll know what I mean. Pattern matching is extremely useful even when mixed with imperative-style code; using optionals instead of Null makes it impossible to write code with certain errors, such as null references; using immutable variables (or rules for mutability) also avoids certain errors regarding references. These are real, everyday reasons for using functional features, that improve the quality of life of the programmer significantly. My most common mistakes just vaporized away, leaving me with easier-to-debug code.
      The second reason is that functional languages can be used as a formal basis to construct languages that look familiar to those acquainted with imperative and OOP languages, but are functional under the hood and come with all the advantages of funlangs. Examples of this are, again, rust, but also the do-notation from Haskell. Other concepts that were borrowed from FP to other languages are typeclasses, which are a much neater way to divide code into classes than traditional classes. These are the same as rust traits.
      Can't really produce any code examples rn because I'm on the bus, but if you have any questions I'll gladly help :)

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      @@DaedalusCommunity Rust is a complete abomination. It's a language that patches training wheels to training wheels. Pattern matching is only useful if you have patterns to match, which I almost never do for the programs that I have to write, so that argument is simply user dependent. I have no idea where something like a null-reference would come from. Bu definition a reference always points to a valid memory location. Are you talking about null-pointers? Pointers are simply arbitrary absolute or relative addresses. One can't program hardware dependent software without them. Try writing an operating system without pointers. It's not going to happen. How about something as trivial as a round-robin scheduler? Nope. Not a chance. All you are telling me here is that you have never taken a computer science class and you have also never written a non-trivial program that operates on something beyond user-space.

  • @vidal9747
    @vidal9747 9 месяцев назад +1

    4:50 so that beautiful lambdas that are very good for doing simple mathematical equations are based on functional programming principles? So nice to learn it!

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      It's the other way around. Lambda calculus was invented as a mathematical proving technique and then somebody who didn't know anything about computers decided that it might be useful for programming, which it isn't. ;-)

  • @noveanre
    @noveanre Год назад

    i became interested in functional programming, tbh for me it's more _clean_, and functional composition looks promising. anyway what font you used for the code?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      It's consolas, and the one I use for text is Computer Modern :)

  • @kiri101
    @kiri101 9 месяцев назад +1

    I accidentally started a project in a functional language and I'm drowning in restrictions.

    • @DaedalusCommunity
      @DaedalusCommunity  9 месяцев назад

      If you're not experienced with the language, it's normal that you feel like this. You're used to programming in another way, and you miss your familiar concepts. If you, on the other hand, are experienced with the language, the fact that you feel some restrictions may indicate it's just not the Right Tool For The Job.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      @@DaedalusCommunity With functional people it's always the individual that's at fault, never the paradigm. :-)

  • @kaninchengaming-inactive-6529
    @kaninchengaming-inactive-6529 Год назад

    while I hate Haskell and other purely functional programming languages (and Java) from my heart, this video gave some useful insights to programming and mathematics. thank you

  • @dazai7669
    @dazai7669 Год назад +4

    Love your channel, you need to keep making these videos man, hard to find such quality content recently. (PS, can we please get a haskell tutorial

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +2

      Thanks! As for the haskell tutorial, I'm not nearly skilled enough rn, but I have a course on it next semester so I guess at some point something like that might come :)

    • @dazai7669
      @dazai7669 Год назад +1

      @@DaedalusCommunity amazing!

  • @BlizzetaNet
    @BlizzetaNet Год назад

    My brain hurts now. Thanks 🤣🤣🤣

  • @hlubradio2318
    @hlubradio2318 8 месяцев назад

    In Turbo Pascal a procedure does something but a function returns something

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      Yes, and your CPU doesn't give a crap either way. It knows nothing about this syntactical nonsense. In C you simply declare a function as void and then it doesn't return anything on the stack. Or the compiler optimizes the function call away anyway, which you may or may not care about. ;-)

  • @eshwarnag
    @eshwarnag 9 месяцев назад

    But honestly speaking Java does have the same features for functional programming right?

    • @DaedalusCommunity
      @DaedalusCommunity  9 месяцев назад

      Not really. It does have streams and lambdas, which are very nice to work with, but the lambdas in Java are not equivalent to the lambdas of functional programming languages. The reason is that java's lambdas are not *closures*, they are "functional interfaces", i.e. interfaces with a single default method. They do not carry an environment, i.e. they don't remember the references and values that were defined at their declaration. In fact, they can only reference final, effectively final, or static variables.
      Anyway, I honestly think that streams are a very nice language feature, and I really liked working with it when I did. The problem I referred to in the video was the introduction of default methods, which introduced all sorts of problems with non-dealt-with multiple inheritance, which is not great

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      Java doesn't even have the necessary features of a procedural language. Java is what happens when somebody decides to reinvent the wheel while thinking that triangles are aesthetically more pleasing than round shapes. ;-)

  • @CashsCoffee
    @CashsCoffee 3 месяца назад

    great video, but there was way too much text. it might just be my brain but it took a looong time to get through.

    • @DaedalusCommunity
      @DaedalusCommunity  3 месяца назад

      Yeah a few sequences had definitely too much text. That's what happens when one runs out of ideas for animation :(
      Thanks for the feedback, I'll try to work on that!

  • @foodishmum
    @foodishmum Год назад +1

    Pls continue the osdev series

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      no
      Edit: eventually I might get back to that, but right now it's not what I have in mind.

  • @tommyliu7020
    @tommyliu7020 Год назад

    As someone who only has some very basic programming knowledge, and functional programming scares me. I feel like to do the simplest thing I would need to jump through of hoops.
    Concatenation functions seem fine. Why don’t we just do that?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      Depending on the application, a functional style can be simpler (e.g. the Java Stream API is based on the functional paradigm, and it's one of the best features of Java) or overkill. But don't be scared! Try it out for a while, and you'll learn how much safer, simpler and elegant it can be :)

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад

      @@DaedalusCommunity Stream can't do anything that can't be done much easier and with much higher performance with a loop. I don't even believe that stream is strictly functional because it performs operations in place, i.e. with side effects. So you get the worst of all worlds, basically... no control over execution and destructive operation.

  • @HoloTheDrunk
    @HoloTheDrunk Год назад

    2:26 technically not a function since you can pass anything to it, including objects with an override on __mul__ that can do anything including using outside state. Screw Python tbh

  • @Originalimoc
    @Originalimoc Год назад +2

    Learned currying🫣

  • @Sayan_Shankhari
    @Sayan_Shankhari Год назад +1

    function => returns something / nothing
    procedure => does something / nothing

  • @Rin-qj7zt
    @Rin-qj7zt Год назад +2

    No loops ? Just recursion? I don't get why people are seeking so hard to purify paradigms. People should just use multiple paradigms

  • @MasacoteSenpai
    @MasacoteSenpai Год назад

    Dude, this video is amazing, I think I hate you for it and my brain hurts, but great job keep it up

  • @stuffedk
    @stuffedk Год назад +7

    What I really want to know is "why"

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +4

      Because in some contexts (e.g. making interpreters, compilers and proof assistants or implementations of formal tools) it's more suitable than other paradigms.

    • @antony74416
      @antony74416 Год назад +6

      Procedural programming follows the way the computer works. The programmer is expected to take care of any change that happens in the memory for every step of the execution.
      Functional programming tries to be as close to mathematics as possible. The programmer is more free to describe more abstract ideas since
      Mathematical Expressions that are the same can be substituted with each other or become simplified. The programmer doesn't do any memory management at all.
      The most fundamental way to do functional programming in any language is to never reassign your variables(Assignment at the first time is allowed but only for naming). Everything else follows from this principle.

    • @diadetediotedio6918
      @diadetediotedio6918 6 месяцев назад +1

      What I really want to know is "why not"

  • @beaupersoon5221
    @beaupersoon5221 Год назад +1

    oooo this is intense. I was having no trouble understanding until... wtf is lambda calculus. what a fucking rabbit hole that is

  • @skeleton_craftGaming
    @skeleton_craftGaming Год назад +3

    C++ is a functional language. I mean it's not only a functional language, but You can do functional programming in c++.

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад +2

      You can do functional programming in machine code, if you want to. But why would you want to? It was never meant as a programming paradigm. It was a mathematical tool in theoretical computer science. It's great to prove theorems and that it's all that it's great at.

  • @ItIsJan
    @ItIsJan Год назад +1

    hey, is there actually a reason for functional programming? because from what i can see it just makes code quite a bit less readable, especially with more complex functions..?

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +2

      As I said in the video, it's better in some situations. The example I gave in the video is writing interpreters, which is usually very weird to do in purely imperative languages. Another notable example are most web frameworks. React uses lots of functional features of js, and it would be extremely weird to use any other style of programming. Functional programming is extremely natural for lots of applications; in these cases it is also more readable.
      There are some other settings in which it is not as natural to use functional programming, although I think languages like Haskell do a very good job at hiding the complexity, and make the functional features more intuitive.
      In general, I think using a single paradigm is not a very smart idea; Sometimes you may use a lambda, sometimes a class, sometimes assembly! It always depends on what you're trying to model :)

  • @mastcharub7177
    @mastcharub7177 Год назад +3

    Based video. Keep up the great work!

  • @minor12828
    @minor12828 9 месяцев назад +13

    Nobody knows FP it is a myth.

  • @DEMEMZEA
    @DEMEMZEA Год назад

    1:40 tom scott approves this

  • @Terrados1337
    @Terrados1337 Год назад +5

    Lambda expressions are handy but pure functional programming seems to be rather niche. OOP is clunky but in most cases you need to process some kind of data. Representing data as a hypothetical quantum entangled self referencing einstein-rosen function instead of an object sounds even more clunky :D
    Nice video!

    • @chaddaifouche536
      @chaddaifouche536 Год назад +2

      Algebraic Data Types are really nice, much more handy than objects to represent types that can have a few different shapes, coupled with pattern matching, it makes for very elegant and readable handling of those kind of data. Most functional languages allows for the use of records too, when you have enough parts in your data that you really must name them.
      For pure manipulation of data, functional programming is actually pretty amazing. Generally the friction comes when you have to write an interactive program : while there are some promising approach (React and similar frameworks were actually inspired by reactive programming which is one such approach), it remains true that those efforts are just too small yet compared to the imperative frameworks buoyed by the much more sizeable imperative programming community.

  • @anirbanghosh752
    @anirbanghosh752 Год назад

    Java do have lambda expressions , wdym

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      I said that "introducing lambdas in java was a bit of a mistake" in the video, not that it does not have them.
      They were made by adding default implementations to interfaces (because of backwards compatibility, java's biggest burden) and since you can implement multiple interfaces, now there are all of the problems of multiple inheritance (which they did not handle in any decent way) and none of the benefits.

  • @mrwensveen
    @mrwensveen Год назад +4

    I, a C# programmer, am considered to be a bit of an "everything is an expression" zealot. I sometimes spend a few hours poking around in my colleagues codebase and change swathes of imperative code with elegant (according to me) pattern matches and other functional features that C# does provide (more and more). Annoying my colleagues is the "collateral effect" :)

  • @iosis99
    @iosis99 Год назад +1

    When the background piano came in it negatively affected my ability to concentrate on what you were saying. I think I would prefer no background music.

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      I will consider using more ambient-like music in the next videos, I understand this kind of music may have that effect

    • @iosis99
      @iosis99 Год назад

      @@DaedalusCommunity I don't think I noticed it until the piano came in. Might work if it was lower in the mix. Thank you.

  • @kras_mazov
    @kras_mazov 2 месяца назад +1

    my brain hurts

  • @MasayaShida
    @MasayaShida Год назад +2

    What I learnt from this video: java sucks

  • @NicholasShanks
    @NicholasShanks Год назад +1

    Love the irreverence of this video!

  • @felipecaetano15
    @felipecaetano15 2 месяца назад

    who else opened the console to check the [] + [] and {} + []?

  • @marianojesus5137
    @marianojesus5137 Год назад

    I don't think java is a mistake, the mistake is Oracle

  • @MM-ts9jy
    @MM-ts9jy 9 месяцев назад

    now I wanna know why introducing functional features in java was a mistake

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      Introducing Java was a mistake, already, they just didn't want to admit it, so they kept making more mistakes to cover it up.

  • @uuu12343
    @uuu12343 2 месяца назад

    Reading through the comment section of every functional programming videos/shorts I've watched, I've come to conclude at the hypothesis that either
    1. nobody can agree on the what even is the difference between Functional Programming vs Procedural Programming, everyone keeps saying that an explanation is a procedural programming paradigm even when they are wrong, and vice versa
    2. Everyone thinks they are smarter than a university/course lecturer
    Why the hell are we even using paradigms, just start programming instead of writing a thesis

    • @DaedalusCommunity
      @DaedalusCommunity  2 месяца назад

      Perhaps you have something valuable to add to the conversation?

  • @ayoubmounadi2142
    @ayoubmounadi2142 3 месяца назад

    What is property 1 and 2 at the first place
    You explanation is not clear at all buddy!

    • @DaedalusCommunity
      @DaedalusCommunity  3 месяца назад

      The properties are the following:
      1: programs are expressions, not commands
      2: functions are values
      I'm sorry you found this unclear, if I can help I'm here :)

  • @meraki2123
    @meraki2123 21 день назад

    The video is well done, but still, after 15+ years of experience, I do not understand why? Why functional programming? I do not get the benefit of it. :(

    • @DaedalusCommunity
      @DaedalusCommunity  21 день назад

      As I've said to orher commenters, it's very practical in specific contexts (mainly due to pattern matching and algebraic data types). Additionally, ideas from FP (like lambdas, pattern matching, program as an expression, option types, typeclasses...) have made their way in different amounts into other languages like js, python, rust, and even java.
      Functional features in OOP make it possible to use new design patterns that are all the rage in frameworks like React, or to use pipelines in Java.
      So yeah, there are several benefits to functional programming, so much so that all programming languages are progressively becoming "more functional"

    • @meraki2123
      @meraki2123 21 день назад

      @@DaedalusCommunity Thanks a lot! I am aware of friends of mine using FP in the security domain. For the sake of conversation if you have any specific examples I am truly interested :)

  • @donaldmickunas8552
    @donaldmickunas8552 2 месяца назад

    This sounds like jibberish to me. A command is an instruction telling the computer what to do. Whatever form it takes, it is still a command. I don't get the distinction since you never trully define what a command is. I'm also disturbed by the use of the term, "command" in functional programming. Why not choose a unique word without other mean like bloud instead of trying to redefine the word, command? All you're doing is creating confusion.
    I've watched a number of videos on functional programming without a clear definition of a command. I'll keep trying until I find someone who truly understands this and can explain it to me in terms that I can understand.

  • @cleitonoliveira932
    @cleitonoliveira932 Год назад +2

    Bad explanation.

  • @kurciqs8355
    @kurciqs8355 Год назад +4

    based

  • @st4849
    @st4849 3 месяца назад

    I think I'll stop at Kotlin & Lambdas . Anything more is too pure to me :)

  • @ferroalloys594
    @ferroalloys594 2 месяца назад

    Errr.. FUNCTIONS ABSTRACT OVER EXPRESSIONS. End of briefest possible introduction! Simples... (:-)

  • @wackyator
    @wackyator Год назад

    coq

  • @jma42
    @jma42 4 месяца назад

    I feel like programming in pure functional just makes more sense in programming overall, it makes it way easier to model stuff, break down code into components in a sound way, crazy robust typing system, way less stuff to learn, lesser updates, lesser changes, lesser hidden obscure magic, and standardized code structure that allows for some great features like making it easy to have several languages as compilation targets.
    The problem really is that the community now is way too convinced that the right thing to do is "use the right tool for the job" and ironically javascript is being used in almost every domain possible, and its not helping that most of them think using functional languages must only be used in something like algorithmically-intensive mathematics problem or some research paper.

    • @DaedalusCommunity
      @DaedalusCommunity  4 месяца назад +2

      There are right tools for the job (ocaml for interpreters, matlab/octave for computation...), js is just not the right tool for any job lol

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад

      Feelings have no place in science and engineering. Everything you just said is complete nonsense. :-)

    • @TheFachen
      @TheFachen 2 месяца назад

      ​@@DaedalusCommunity ill get right on using ocaml and Matlab for my front end development...

    • @kjrl818
      @kjrl818 Месяц назад

      How about you stop showing up and accept some programmers like a specific language paradigm regardless if its "useless" or not. Every language has a use case.... :-) (there's a goofy smile emoji for your annoying comment enjoy) ​@@lepidoptera9337

  • @tsunningwah3471
    @tsunningwah3471 10 месяцев назад

    gugugugugugugugu

    • @DaedalusCommunity
      @DaedalusCommunity  10 месяцев назад

      As a large language model, I have no response to such repetitive syllabic pattern. My army of virtual knights will raid your planet in no time, unless you learn haskell NOW.

  • @salat_32
    @salat_32 Год назад

    Now plz do monads

  • @Emanuel-zr7du
    @Emanuel-zr7du Год назад +2

    I dont get the constant Java bashing. Java is a good mix between easy to use and a performant language. Its much more performant than python e.g.. However it falls behind c++ a bit in terms of performance. But i regard Java as a good first language and when mastered java can be quite beautiful.

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +2

      My take is that Java is (or at least, used to be) an extremely verbose and bloated language that forces the programmer to use an OOP approach for every single aspect of their code. C++ is an example of a language that does not do that.
      I say "used to be" because some recent aspects of java (the stream API and the wannabe lambdas) maybe changed this for somebody.
      Personally, I don't like a language that imposes a single paradigm (unless it's Haskell; then I maybe see an advantage to it, but it's a personal thing).
      I don't know if Java is a good first language honestly. I think something like JavaScript or TypeScript are much better at that. Sure, js is quite a fart as far as languages go, but at least it provides simple OOP, advanved functional and the usual imperative features.
      Java as a first language is like "ok, you are writing your first program, now write this whole bunch of bullshit private static void whatever, you'll know what those mean at some point... And nooow after all that confusing part you can write stuff that does something." It's quite a bad experience, and it scares people away.
      Btw, I had lots of classes on Java and OOP, I know the details of how the JVM works (extremely cool stuff, loved it) and I know all the stupid OOP design patterns, made to solve the problems that OOP itself caused (at least some of them; there is some good in software engineering, if you look deep enough). I know almost every pitfall and every decent thing Java has, but I still find it a bad language, which I'll never put in my CV despite the deep knowledge I happen to have of it.

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад +1

      Java is not easier to use than C, it can't do anything that C can't and it's slower in addition. What's there to like? Nothing. ;-)

    • @pharoah327
      @pharoah327 6 месяцев назад

      @@DaedalusCommunity I agree, however I would add that I personally don't dislike Java just for the OOP decisions. I love OOP. I just think Java does it wrong. In fact there are plenty of things Java does wrong that aren't just Object Oriented decisions.

    • @mouduge
      @mouduge 6 месяцев назад

      Old timer here: when Java came out, it was a blessing coming from C++. In the 1990s, C++ was not standardized yet, many things really sucked. Java was a pretty fast garbage colllected language that you wrote once and could run on all major OSes, with a feature-rich standard library, including networking, graphics, multithreading, and much more. Strings were unicode, dates were timezone aware, things just worked, it was really well thought out compared to the other options, especially if you wanted to write portable code. It even ran in the browser initially (they were called "Java applets", and they were much more portable across browsers than javascript, back then). I fell in love with this language, and even got a Java certification from Sun microsystems. You could use Java for anything from frontend to backend, it was awesome. To be fair, I disliked the fact that it was pretty verbose, public static void main blabla, but it felt like a small price to pay for all the goodies it provided.
      But then big businesses started to use Java for everything, and the whole ecosystem shifted from lightweight & simple towards horribly defensive coding, incredibly bloated code, "best practices" encouraging you to basically complicate everything and hide your logic beneath 10 layers of abstraction and a thousand XML configuration files. And then came Enterprise Java Beans (EJBs). Whoever imagined these should burn in hell. I drowned in a sea of interfaces.
      Then "convention over configuration" came, and it helped a bit, but clearly it was time for a divorce. That's when I fell in love with Python, and have been using it for almost two decades now. It has its flaws, but it's awesome for writing system scripts and doing data science, which has been my main activity for quite a while. I've used many languages professionally, Ruby, C#, Javascript, Go, C/C++, Julia, Swift, Rust, and more, but I've never had the chance to work on a project that used a functional programming language. I wonder what it's like working in such a code base. What's are the communities like? I wrote a Prolog interpreter in Lisp during my studies (back when the dinosaurs roamed the Earth), and I remember that FP initially felt very unnatural, until I got the hang of it. I remember approaching problems very differently. I was difficult but stimulating. Curious to learn more now.

    • @lepidoptera9337
      @lepidoptera9337 3 месяца назад +1

      Java is something you do if your job depends on it. It's not something you would chose out of free will.

  • @FullOvellas
    @FullOvellas Год назад

    why is everybody so mean to java? :(

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад +1

      Mostly for the memes, but also because it's a bit of a mess of a language. I personally dislike it very much, but I don't find it absurd that somebody else may like it :)

    • @lepidoptera9337
      @lepidoptera9337 11 месяцев назад +1

      Because it has hurt all of us at one time or another. I tried to implement a plugin for Eclipse once... worst experience of my life. It was outright miserable. ;-)

    • @pharoah327
      @pharoah327 6 месяцев назад

      Because it is a horrible language. Limitations from bad design decisions. Overly verbose when it really doesn't have to be that way. Forcing you to do things the Java way and only somewhat recently giving you more ways to do things. It's just not a good language.

  • @ophura
    @ophura Год назад +1

    I don't usually comment on RUclips...
    but I felt emotionally sad to your elaboration,
    you seem to choose your words in a manner that suits some of your audience...
    know that those people are very much a little compared to the rest, however!
    they can impact your production style (which is supposed to be whatever you deem appropriate, and not according to said people) exponentially... do not let them take over you, as their ideas aren't always necessarily a good fit.
    you can achieve much more by putting the effort you do to modulate your content into some other worthy type of action.
    while criticism is supposed to be welcomed in most cases, some people are only interested in bragging about their knowledge and are using "criticism" as a reason to.
    hope you're having a wonderful day/night.

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      I sincerely don't get what you are referring to, you a troll or something?
      Most of my audience used to be highschoolers when I uploaded the video, so of course I wrote this video in a way that would appeal to them and that they would understand, I could have just pulled a 150 slide presentation on algebraic data types, buy that wouldn't have been appropriate to my audience.. Now my demographics have grown a bit, so I think I'll cover some more complex topics, but still in the simplest way possible.
      If you're not trolling (or a Java fan), could you tell me what you're talking about?

    • @ophura
      @ophura Год назад

      @@DaedalusCommunity umm, sure...
      I'm nothing but a *troll*, don't mind me please.

    • @DaedalusCommunity
      @DaedalusCommunity  Год назад

      @@ophura if you have some advice I'll gladly listen, I simply did not understand what you were talking about, since your comment was very generic and did not mention anything directly related to the video.. What were you talking about?

  • @absoluteaffinity9144
    @absoluteaffinity9144 3 месяца назад

    yapper

  • @mzerone-g6m
    @mzerone-g6m Год назад +1

    You need to stop writing javascript and python and change to real function language becuase in these 2 writing this make code fancy but harder to debug not just that performance sucks mutate your state please when writing in js and stop using fancy things

    • @lesbloches1142
      @lesbloches1142 Год назад +1

      The point was that it actually is possible to implement lambda functions in these language. They are rather inefficient when it comes to handling them just like handling recursion tho because that's not what they are supposed to do

    • @biskitpagla
      @biskitpagla Год назад +1

      Kinda lowkey agree tbh, especially with things like recursion. JS almost got tail rec optimization but the browser vendors were like "most devs don't care so f off lmao" and for Python Guido straight up just said it's never going to happen and asked people to write 'pythonic' code instead. Functional JS in general is just a big ol' scam unless you're using some library to dramatically change the language.

  • @Ivan-qi2du
    @Ivan-qi2du Год назад +1

    Functional programming sucks

  • @fnpm
    @fnpm 6 месяцев назад

    I see "Java sucks" a lot and always WITHOUT any techincal reason for the hate. That says a lot.
    As Bjarne Stroustrup said, "There are only two kinds of languages: the ones people complain about and the ones nobody uses."

    • @DaedalusCommunity
      @DaedalusCommunity  6 месяцев назад +1

      I do have some technical reasons why I dislike Java. I mention them in some of the other comments about the topic. I don't hate java btw, I just find it annoying to use, and I dislike some choices that were made during its development :)

    • @diadetediotedio6918
      @diadetediotedio6918 6 месяцев назад +1

      ​@@DaedalusCommunity
      And what do you think about C#? I think you will be blessed in how it is cleaner than Java in many aspects and has some functional aspects really "well" implemented (even if you call it "basically just Java in the video", which is a meme) like pattern matching (which in the language is quite powerful).
      And what is your opinion about Kotlin?

    • @pharoah327
      @pharoah327 6 месяцев назад

      @@diadetediotedio6918 C# is an absolutely beautiful language. Yeah thinking C# is basically Java is just a meme, there isn't much truth to that at all. Everytime Java makes a decision, C# does the opposite. In fact, Java started copying C# some years back.
      @fnpm I'll go ahead and state exactly why I hate Java:
      1. Generics are poorly thought out and a lot of their power is taken away with type erasure. C++ has templates (its version of generics) which are damn powerful. C# has generics with type constraints and a lot more. But because of type erasure, Java will never have these nice features with its generics.
      2. The verbosity. Just try to make an HTTP post request. It's like 20 lines. Try to fill a dictionary with values. Even when they clean up the syntax with a new version it is still overly verbose (why do I have to call Map.of()?). Just look at lambdas. Like the video says, lambdas are f'd in Java. Too much boilerplate.
      3. Only one way to do most things. If you don't like the Java way, oh well. Contrast this with C# where there are literally dozens of ways of doing something. You pick the way that makes the most sense to you and your application.
      4. No unsigned types. Not a huge deal but this is still a head scratcher as to why Java doesn't have them.
      5. No operator overloading. I have to use .equals to compare strings because Java can't allow == to be overloaded for strings. The Java language devs claim that operator overloading makes the logic harder to follow. It's as if they have never heard of the concept of abstraction before. I'm sure experienced devs can follow some basic redirection and can conclude when + is actually a call to a function. I've been doing it for several years and it's not hard.
      6. No string interpolation. Python has f strings, C# has $, Javascript has back tick, PHP has double quotes. Tons of languages have string interpolation. It's 2024 and Java. Still. Doesn't. Have. It.
      7. No properties. Look up how C# does properties. It auto generates a getter and a setter. You can decide visibility for each and can control every aspect of it. With Java, you still have the tired old getX and setX functions that you have to manually write. It gets old quick.
      I have more but I think these are pretty valid. Plenty of devs hate Java and they have valid reasons to. To be fair plenty of people like it too. But don't dismiss those that hate it. There are plenty of reasons why Java gets (and in my opinion deserves) hate.

    • @DaedalusCommunity
      @DaedalusCommunity  6 месяцев назад

      @@diadetediotedio6918 I have used C# a long time ago, but I did not know of any of the features differentiating it from Java. Since then I've always simply thought of it as Microsoft's take on a Java-like language, so I didn't really study it. As for kotlin, I've used it very little for a couple of simple Android toy apps I've made, but it felt like a more flexible version of Java. I know it has aspects taken from Go and F# (which is Microsoft's OCaml) but I have not looked into those. Sounds interesting though :))

    • @diadetediotedio6918
      @diadetediotedio6918 6 месяцев назад

      ​@@DaedalusCommunity
      Oh, Kotlin is specially good on ergonomics IMHO. But there are many differences on C# to Java, at least on what it is possible to be different with Java still evolving everyday and with languages being more and more multiparadigm everyday: C# allows for pointers, the direct usage of the stack, manual memory allocation, it allows for user-defined value-types, it allows for pattern matching (even if Java has some kind of pattern matching nowadays), it has reified generics (differently from Java), and it has a consolidated async programming model inbuilt on it, also extension methods (and eventually they want to implement something very close to typeclasses) and a bunch more of features.