Functional programming - A general introduction

  Рет қаралды 113,991

Daedalus Community

Daedalus Community

Күн бұрын

Пікірлер: 202
@bryceeklund944
@bryceeklund944 Ай бұрын
as an idiot and also a java dev and java enjoyer this was very informative and entertaining, thank you & subbed
@DaedalusCommunity
@DaedalusCommunity Ай бұрын
This is THE comment
@Lenjiy
@Lenjiy Ай бұрын
you forgot to extend dozen more interface
@haleyhalcyon
@haleyhalcyon Жыл бұрын
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 Жыл бұрын
You immediately turn into a category equipped with a defunctor F : 💀 → C
@kamilziemian995
@kamilziemian995 4 ай бұрын
@@DaedalusCommunity True.
@biskitpagla
@biskitpagla Жыл бұрын
the constant java bashing is totally appreciated, subbed
@lufenmartofilia5804
@lufenmartofilia5804 7 ай бұрын
Funny tho that C# is not bashed as it is just a mess in comparison espacially now with java 21
@OverrideTips
@OverrideTips 7 ай бұрын
@@lufenmartofilia5804we in Java 22 now 😮‍💨 and now it’s getting less verbose for beginners yay Java!😂
@diadetediotedio6918
@diadetediotedio6918 5 ай бұрын
​@@lufenmartofilia5804 A good and old coping, C# is much cleaner than Java generally. And Kotlin is way better than both.
@thessianheart9816
@thessianheart9816 2 ай бұрын
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 11 күн бұрын
@@thessianheart9816it has nothing to do with (the subjective) perception of difficulty
@bharold
@bharold Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Ай бұрын
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 29 күн бұрын
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 Жыл бұрын
it's simple. Monad is just a monoid in the category of endofunctors🤓
@ananttiwari1337
@ananttiwari1337 Жыл бұрын
1:40 Love the Tom Scott reference lol
@byrondumont-eve
@byrondumont-eve 5 ай бұрын
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 2 ай бұрын
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. ;-)
@AK-vx4dy
@AK-vx4dy 9 ай бұрын
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.
@calengo454
@calengo454 Жыл бұрын
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 Жыл бұрын
If you have any questions I'll try to answer :)
@Rin-qj7zt
@Rin-qj7zt Жыл бұрын
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.
@nasko235679
@nasko235679 24 күн бұрын
I started learning elixir and just reading it feels like reading Chinese. This helped a lot! Thanks
@iham1313
@iham1313 5 ай бұрын
you got me at "private abstract anxious elaborate verbose void" :D
@SwagDawg
@SwagDawg Жыл бұрын
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 Жыл бұрын
Great! What's your uni?
@SwagDawg
@SwagDawg Жыл бұрын
@@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 Жыл бұрын
@@SwagDawg Sorry for the late response! I'm at the university of Pisa, in Italy
@abahiduh3246
@abahiduh3246 6 ай бұрын
What point are u making... Class focused on functional programming? the bases of OOP is classes explain pls
@ImperiumLibertas
@ImperiumLibertas 7 ай бұрын
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 7 ай бұрын
Have a look at the do-notation in Haskell
@ImperiumLibertas
@ImperiumLibertas 7 ай бұрын
@@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 2 ай бұрын
@@DaedalusCommunity It's a workaround so that functional programmers don't have to admit that functional languages don't work. ;-)
@kezif
@kezif Жыл бұрын
Sont ask woman here age Man his salary Functional programmer how to print out string
@disdroid
@disdroid 7 ай бұрын
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 2 ай бұрын
Stateless programming has become the eschatological religion of those who are afraid of state. :-)
@disdroid
@disdroid 2 ай бұрын
@@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 2 ай бұрын
@@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.
@YoshikoJanai
@YoshikoJanai Жыл бұрын
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 10 ай бұрын
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.
@uuu12343
@uuu12343 Ай бұрын
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 Ай бұрын
Perhaps you have something valuable to add to the conversation?
@jma42
@jma42 3 ай бұрын
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 3 ай бұрын
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 2 ай бұрын
Feelings have no place in science and engineering. Everything you just said is complete nonsense. :-)
@TheFachen
@TheFachen Ай бұрын
​@@DaedalusCommunity ill get right on using ocaml and Matlab for my front end development...
@kjrl818
@kjrl818 9 күн бұрын
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
@olteanumihai1245
@olteanumihai1245 5 ай бұрын
underrated video and channel
@MonsterSmart
@MonsterSmart 8 ай бұрын
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 8 ай бұрын
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 2 ай бұрын
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. ;-)
@bilditup1
@bilditup1 3 ай бұрын
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 3 ай бұрын
…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 3 ай бұрын
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 2 ай бұрын
@@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.
@bernardodomeneghetti9673
@bernardodomeneghetti9673 Жыл бұрын
8:27 is the moment you know, that u shouldnt be here anymore, even being warned before LMAO
@Sayan_Shankhari
@Sayan_Shankhari Жыл бұрын
function => returns something / nothing procedure => does something / nothing
@lucasfkam
@lucasfkam Жыл бұрын
What books or materials would you recommend that contain mathematical expressions and notations (such as lambda calculus expressions) to support functional programming?
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
"Types and programming languages" by Pierce is a very comprehensive book on the topic
@smritapokharel5983
@smritapokharel5983 Жыл бұрын
Love the music 💃
@kvelez
@kvelez Жыл бұрын
Awesome video.
@vidal9747
@vidal9747 8 ай бұрын
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 2 ай бұрын
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. ;-)
@stoneman210
@stoneman210 Жыл бұрын
He's back. HE'S BACK
@aaronspeedy7780
@aaronspeedy7780 Жыл бұрын
Wouldn't using recursion instead of simple loops take up a lot of memory?
@jma42
@jma42 Жыл бұрын
yes, but if the language supports guaranteed tce then it wont be an issue.
@skeleton_craftGaming
@skeleton_craftGaming Жыл бұрын
C++ is a functional language. I mean it's not only a functional language, but You can do functional programming in c++.
@lepidoptera9337
@lepidoptera9337 10 ай бұрын
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.
@kiri101
@kiri101 8 ай бұрын
I accidentally started a project in a functional language and I'm drowning in restrictions.
@DaedalusCommunity
@DaedalusCommunity 8 ай бұрын
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 2 ай бұрын
@@DaedalusCommunity With functional people it's always the individual that's at fault, never the paradigm. :-)
@taxi_a
@taxi_a Жыл бұрын
this is fire keep up with the good work
@soyitiel
@soyitiel Жыл бұрын
Question: @ 6:33, isn’t the function called inside my_sum supposed to be my_sum again?
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
It is!
@sporfworfel
@sporfworfel Жыл бұрын
This should get more upvotes. Hopefully they'll notice and fix it.
@stuffedk
@stuffedk Жыл бұрын
What I really want to know is "why"
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
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 Жыл бұрын
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 5 ай бұрын
What I really want to know is "why not"
@dermakol8543
@dermakol8543 Жыл бұрын
Awesome video as always. Hope some day you get a recognition you deserve!
@Terrados1337
@Terrados1337 Жыл бұрын
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 Жыл бұрын
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.
@CashsCoffee
@CashsCoffee 2 ай бұрын
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 2 ай бұрын
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!
@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
@Originalimoc
@Originalimoc Жыл бұрын
Learned currying🫣
@1conscience0dimension
@1conscience0dimension 9 ай бұрын
chicken currying ?
@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 10 ай бұрын
@@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.
@mastcharub7177
@mastcharub7177 Жыл бұрын
Based video. Keep up the great work!
@beaupersoon5221
@beaupersoon5221 Жыл бұрын
oooo this is intense. I was having no trouble understanding until... wtf is lambda calculus. what a fucking rabbit hole that is
@BlizzetaNet
@BlizzetaNet Жыл бұрын
My brain hurts now. Thanks 🤣🤣🤣
@hlubradio2318
@hlubradio2318 7 ай бұрын
In Turbo Pascal a procedure does something but a function returns something
@lepidoptera9337
@lepidoptera9337 2 ай бұрын
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. ;-)
@foodishmum
@foodishmum Жыл бұрын
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.
@ZZaGGrrUzz
@ZZaGGrrUzz 3 ай бұрын
Is there any real benefit of not using temporary variables inside a function?..
@DaedalusCommunity
@DaedalusCommunity 3 ай бұрын
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.
@dazai7669
@dazai7669 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@DaedalusCommunity amazing!
@pfever
@pfever Жыл бұрын
Is this programming paradigm useful in the industry? or just for rare jobs?
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
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 10 ай бұрын
If you want to make enemies out of your colleagues... sure, go for it. ;-)
@naimmomin5811
@naimmomin5811 9 ай бұрын
How does the code at 6:28 work when you gave sum 4 parameters but it only takes in two?
@DaedalusCommunity
@DaedalusCommunity 9 ай бұрын
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).
@dan_bev
@dan_bev Жыл бұрын
What books do you recommend for these topics?
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
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
@Lado93
@Lado93 Жыл бұрын
6:38 isnt def sum(a,b) function supposed to have return too?
@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 :)
@minor12828
@minor12828 8 ай бұрын
Nobody knows FP it is a myth.
@Rin-qj7zt
@Rin-qj7zt Жыл бұрын
No loops ? Just recursion? I don't get why people are seeking so hard to purify paradigms. People should just use multiple paradigms
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
That's true :) You gotta pick the best of each paradigm!
@MasacoteSenpai
@MasacoteSenpai Жыл бұрын
Dude, this video is amazing, I think I hate you for it and my brain hurts, but great job keep it up
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
Thanks!!
@mrwensveen
@mrwensveen Жыл бұрын
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" :)
@nbecnbec
@nbecnbec Жыл бұрын
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.
@felipecaetano15
@felipecaetano15 Ай бұрын
who else opened the console to check the [] + [] and {} + []?
@olikat9774
@olikat9774 Жыл бұрын
6:33 is my_sum meant to be returning my_sum() instead of sum()
@sporfworfel
@sporfworfel Жыл бұрын
Yes. He made a mistake.
@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
@AK-vx4dy
@AK-vx4dy 9 ай бұрын
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 9 ай бұрын
I can scan this message, but I'm finding trouble parsing it lol
@AK-vx4dy
@AK-vx4dy 9 ай бұрын
@@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 9 ай бұрын
@@DaedalusCommunity let beloved_language = function | burn_by -> if burn_by = "Java" then "Ocaml"
@DEMEMZEA
@DEMEMZEA Жыл бұрын
1:40 tom scott approves this
@marianojesus5137
@marianojesus5137 Жыл бұрын
I don't think java is a mistake, the mistake is Oracle
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
That's surely a big part of the mistake
@NicholasShanks
@NicholasShanks Жыл бұрын
Love the irreverence of this video!
@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
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
That's right, lol
@MM-ts9jy
@MM-ts9jy 8 ай бұрын
now I wanna know why introducing functional features in java was a mistake
@lepidoptera9337
@lepidoptera9337 2 ай бұрын
Introducing Java was a mistake, already, they just didn't want to admit it, so they kept making more mistakes to cover it up.
@iosis99
@iosis99 Жыл бұрын
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.
@eshwarnag
@eshwarnag 8 ай бұрын
But honestly speaking Java does have the same features for functional programming right?
@DaedalusCommunity
@DaedalusCommunity 8 ай бұрын
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 2 ай бұрын
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. ;-)
@MasayaShida
@MasayaShida Жыл бұрын
What I learnt from this video: java sucks
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
The one real takeaway
@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.
@st4849
@st4849 2 ай бұрын
I think I'll stop at Kotlin & Lambdas . Anything more is too pure to me :)
@kras_mazov
@kras_mazov Ай бұрын
my brain hurts
@kurciqs8355
@kurciqs8355 Жыл бұрын
based
@ferroalloys594
@ferroalloys594 Ай бұрын
Errr.. FUNCTIONS ABSTRACT OVER EXPRESSIONS. End of briefest possible introduction! Simples... (:-)
@ItIsJan
@ItIsJan Жыл бұрын
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 Жыл бұрын
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 :)
@donaldmickunas8552
@donaldmickunas8552 Ай бұрын
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.
@Emanuel-zr7du
@Emanuel-zr7du 11 ай бұрын
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 11 ай бұрын
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 10 ай бұрын
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 5 ай бұрын
@@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 5 ай бұрын
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 2 ай бұрын
Java is something you do if your job depends on it. It's not something you would chose out of free will.
@ayoubmounadi2142
@ayoubmounadi2142 2 ай бұрын
What is property 1 and 2 at the first place You explanation is not clear at all buddy!
@DaedalusCommunity
@DaedalusCommunity 2 ай бұрын
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 :)
@salat_32
@salat_32 Жыл бұрын
Now plz do monads
@cleitonoliveira932
@cleitonoliveira932 Жыл бұрын
Bad explanation.
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
Unhelpful comment.
@wackyator
@wackyator Жыл бұрын
coq
@FullOvellas
@FullOvellas Жыл бұрын
why is everybody so mean to java? :(
@DaedalusCommunity
@DaedalusCommunity Жыл бұрын
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 10 ай бұрын
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 5 ай бұрын
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.
@tsunningwah3471
@tsunningwah3471 9 ай бұрын
gugugugugugugugu
@DaedalusCommunity
@DaedalusCommunity 9 ай бұрын
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.
@ophura
@ophura Жыл бұрын
I don't usually comment on KZbin... 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?
@fnpm
@fnpm 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
​@@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 5 ай бұрын
@@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 5 ай бұрын
@@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 5 ай бұрын
​@@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.
@absoluteaffinity9144
@absoluteaffinity9144 2 ай бұрын
yapper
@DaedalusCommunity
@DaedalusCommunity 2 ай бұрын
kzbin.info/www/bejne/imi4opt6qJ2toJY
@Ivan-qi2du
@Ivan-qi2du Жыл бұрын
Functional programming sucks
@mzerone-g6m
@mzerone-g6m Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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.
Dear Functional Bros
16:50
CodeAesthetic
Рет қаралды 553 М.
Object Oriented Programming vs Functional Programming
18:55
Continuous Delivery
Рет қаралды 761 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 21 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 93 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 6 МЛН
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
Lambda (λ) Calculus Primer
34:26
LigerLearn
Рет қаралды 12 М.
Functional Design Patterns - Scott Wlaschin
1:05:50
NDC Conferences
Рет қаралды 299 М.
Is Functional Programming DEAD Already?
21:07
Continuous Delivery
Рет қаралды 68 М.
FP vs OOP | For Dummies
8:43
BasicOverflow
Рет қаралды 193 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 670 М.
The 3 Laws of Writing Readable Code
5:28
Kantan Coding
Рет қаралды 735 М.
The purest coding style, where bugs are near impossible
10:25
Coderized
Рет қаралды 1 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 21 МЛН