Тёмный

Functional Programming & Haskell - Computerphile 

Computerphile
Подписаться 2,4 млн
Просмотров 655 тыс.
50% 1

Just what is functional programming? We asked a member of the team that created Haskell: John Hughes, Professor of Computer Science at Chalmers University of Technology in Gothenburg.
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Опубликовано:

 

16 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 693   
@DustinRodriguez1_0
@DustinRodriguez1_0 7 лет назад
One of the things that the Haskell language should really get kudos for is its community. I've learned many different languages, and participated in many different communities around them, but the Haskell community is on a whole other level. I often felt bad about how far the people in the Haskell community would go to make sure I understood things. I would ask a question and I would always find someone willing to work with me for HOURS if necessary, writing all kinds of example code to show me things, walking me through difficult concepts, etc. Many languages have helpful communities, but the Haskell community is simply the best I've ever seen. Top notch folks all.
@mduckernz
@mduckernz 7 лет назад
Dustin Rodriguez Heh, if you think the community of Haskell is great, just wait until you experience that of Rust's! (another [predominantly] functional language, but which is compiled to fully native code, no VM or GC) I often wonder what, if any, beliefs and values are responsible for for this apparent trend - essentially, what sorts of people use languages like this, why do they want to use them, and do those reasons likely have a strong effect on the community as a whole? Perhaps a shared desire to get things _right_ ... not just to "work"..?
@Will-tb8qm
@Will-tb8qm 7 лет назад
I think it's because FP is so much fun to teach. Why it's so much fun to teach is something I'll have to think about more.
@kptnix
@kptnix 7 лет назад
Matthew Ducker: Hmm. I think that could be it, yes! People in the functional communities tends to be people who are Very passionate about programming; it's more than "just a job" or about "making it work" - they spend a lot of time thinking about the most perfect way to do something - and they probably want to share that with others...
@slamislife74
@slamislife74 5 лет назад
wholesome :)
@Said75010
@Said75010 5 лет назад
Can you guys share any books or resources to start with for a java developer ? Cheers
@barbariandude
@barbariandude 7 лет назад
6:35 John Hughes goes full code ninja mode. God help any computer that tries to modify his data.
@Villfuk02
@Villfuk02 7 лет назад
I HAVE BEEN JUMPSCARED
@HexHunter
@HexHunter 7 лет назад
He had an adrenalin shot I guess. That was seriously out of character (well, as far as character building goes in one vid). I seriously just stopped and was like "WTF?"
@KuliJens
@KuliJens 7 лет назад
hahahaha
@Ti133700N
@Ti133700N 7 лет назад
That clearly deserves a GIF.
@JP-mc3bv
@JP-mc3bv 7 лет назад
That was awesome. It totally showed how he feels about that mutable state. ITS CRAZY, ALL OVER, AND FAST!! Sooooo Awesome!!
@FlashManinSpace
@FlashManinSpace 7 лет назад
My dad is an expert dragon slayer. "eeer but I don't see any dragons around... " You're welcome.
@kapa1611
@kapa1611 7 лет назад
your dad is great at his job!!! thank him for his service to humanity!! :)
@Bashir000
@Bashir000 7 лет назад
Flash Man reported to PETA
@gofer9156
@gofer9156 7 лет назад
unless only an expert recognizes a dragon.
@amitdawar6411
@amitdawar6411 5 лет назад
what am i missing here?
@Enutie
@Enutie 5 лет назад
@@amitdawar6411 It's a joke referring what was said in the video about: "there is no spam on facebook"
@Biped
@Biped 7 лет назад
6:34 sudden rage-mode
@gorgolyt
@gorgolyt 7 лет назад
I was not ready.
@ArgoIo
@ArgoIo 7 лет назад
Even the camera gets scared.
@markusr3259
@markusr3259 7 лет назад
Not to mention being completely wrong.
@ArgoIo
@ArgoIo 7 лет назад
Mark Randall No, he has a point. Some imparative languages such as C may force one to use pointers as function arguments.
@markusr3259
@markusr3259 7 лет назад
But you can define those as const type * to prevent it. You're explicitly passing those pointers to be changeable, and of course there are ways around it if you're trying to blow your own foot off.
@C0deH0wler
@C0deH0wler 7 лет назад
Holy... that was very well explained. If you can get John back on camera that would be appreciated.
@ThisIsNotMyHandle
@ThisIsNotMyHandle 7 лет назад
On of the best professors I have had!
@pixelmaniac8534
@pixelmaniac8534 7 лет назад
I was at one of his lectures at my university. Talked about the benefits of functional programming over imperative, as well as the powers of QuickCheck. Kind of like really nice propaganda from the man himself.
@C0deH0wler
@C0deH0wler 7 лет назад
Pixelmaniac Did you just watch that DNews Plus video...
@Ibakecookiess
@Ibakecookiess 7 лет назад
He pretty much did not explain anything? The video had like no analytical content.
@azufendusgarendum6583
@azufendusgarendum6583 3 года назад
Yes, please
@dynten1
@dynten1 7 лет назад
How wonderful to see my first, and very best, programming professor again! I took functional programming courses for prof Hughes in 2004. Very great memories from that time :-)
@simonalling
@simonalling 7 лет назад
After three years' CS studies at Chalmers, I always name Functional Programming (the very first course we took, and in which John played a major role) as the most valuable course - the one I would pick if I could choose only one single course to have taken. Not only are functional languages absolutely fantastic to work with; one can also use many of the important concepts of FP in imperative languages like Java to write monumentally superior code.
@grhaonan
@grhaonan 2 года назад
Charmers in Gothenburg?
@simonalling
@simonalling 2 года назад
@@grhaonan I might be a member of that set, yes - having studied at Chalmers and all! ^^
@grhaonan
@grhaonan 2 года назад
@@simonalling nice, I studied at Chalmers 10 years ago:)
@rootbeersoup
@rootbeersoup 5 лет назад
Wow he must be an excellent teacher. You can tell he has a firm grasp on functional programming concepts because he can explain things in layman terms.
@sirkickassalot123
@sirkickassalot123 3 года назад
he is ... easily one of the best professors I have had.
@bre4159
@bre4159 10 месяцев назад
He is one of the guys who made Haskal 🤣
@ElagabalusRex
@ElagabalusRex 7 лет назад
I wish they had some concrete examples. A lot of these summaries of programming paradigms fail to show what problem solving looks like and how it differs from other paradigms.
@Vulcapyro
@Vulcapyro 7 лет назад
That's because pretty much any programming language can do simple things very easily and it's difficult to showcase important differences and what their impact is without experience and complicated examples.
@simonalling
@simonalling 7 лет назад
Here are a few very simple examples of what functional programming can look like if run interactively in GHCi, where the user types an expression and GHCi returns its value. ">" indicates user input and this is not what an actual functional program looks like, just some standalone example expressions: >5+3 8 > > let someNumbers = [1..10] > someNumbers [1,2,3,4,5,6,7,8,9,10] > > let otherNumbers = map (+ 5) someNumbers > otherNumbers [6,7,8,9,10,11,12,13,14,15] > > all (> 5) someNumbers False > > all (> 5) otherNumbers True > > let square x = x * x > take 6 (map square [1..]) [1,4,9,16,25,36] Functional programming is all about pure expressions (most of the time). There is no such thing as mutable variables that you can assign some value to and then overwrite with something else. "=" in FP is a lot like equality in mathematics and not at all like assignment in imperative programming.
@gofer9156
@gofer9156 7 лет назад
Ok, you asked for some concrete Haskell code: filterM (const [True,False]) [1,2,3] produces [[1,2,3],[1,2],[1,3],[1],[2,3],[2],[3],[]] which is the power set of [1,2,3]. explanation: we filter the list by both keeping and dropping every element in the list, using the list monad. [(2*),(3+),(1-)] [1,2,3] produces [2,4,6,4,5,6,0,-1,-2] which is every function in the first list APPLIED to every element in the second list. explanation: the list type [] is a member of the applicative class, enabling us to do such cool stuff.
@MrPoutsesMple
@MrPoutsesMple 7 лет назад
You can join Project Euler and see many examples.
@jackozeehakkjuz
@jackozeehakkjuz 5 лет назад
Here is a two-line quicksort in Haskell. qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
@kognitiva
@kognitiva 7 лет назад
So proud! He was my teacher ^^
@KangJangkrik
@KangJangkrik 3 года назад
I would assume you did graduated, congrats!
@JeyPeyy
@JeyPeyy 6 лет назад
He was my professor in parallel functional programming, he's fantastic! Koen Claessen who also teaches Haskell at Chalmers is also incredible and was the reason why I got interested in functional programming.
@benoitranque7791
@benoitranque7791 5 лет назад
I'm a javascript developer and I started programing funtionally and it makes so much sense I've never looked back
@Nathan5791
@Nathan5791 7 лет назад
I was a core Object Oriented programmer but over the past few months have shifted to using Clojure which is another Functional Language very similar to Haskell and OMG does Functional Programming make so much more sense than OOP! Pure Functions means less bugs and the syntax of the language helps you write beautiful code that one can read so much more naturally. People who are getting into programming, give it a shot, you'll like it much more than OOP
@MrCmon113
@MrCmon113 7 лет назад
That makes me happy I started computer science in the summer, so our first language will be Haskell rather than Java.
@gogl0l386
@gogl0l386 4 года назад
Nothing makes me more happier than seeing functional programming rescuing fellow programmers from the terror of OOP, the dragon that has dominated the industry way too long.
@amigalemming
@amigalemming 4 года назад
OOP and FP are no contradiction. OCaml and O'Haskell are object oriented functional languages. OOP is a type system feature, FP is a control flow feature.
@EduardoGonzalez-bm1mk
@EduardoGonzalez-bm1mk 4 года назад
If you work with databases objects it’s a must .
@cube2fox
@cube2fox 4 года назад
@@amigalemming How is it not a contradiction? In object orientation you have getters and setters, which by definition have side effects: Setters modify the state of an object, and the output of getters does depend on the state of an object. For example car.getSpeed() and car.setSpeed(50). From the OOP perspective having these side effects isn't even a bug but intended behavior. (Of course you could "de-OOP" everything by instead only allowing getCarSpeed(car) and setCarSpeed(car, 50), but then you don't have OOP anymore: All functions are global and no longer encapsulated in their classes as methods.)
@rommelmartinez5599
@rommelmartinez5599 5 лет назад
I had subtitles on, so naturally I was suprised when it mentioned the airline programming language.
@amigalemming
@amigalemming 4 года назад
So far I was not aware that Ericsson was concerned with aviation. :-)
@lindhe
@lindhe 7 лет назад
This really made my day! I like Computerphile, I like Haskell and functional programming and I like John Hughes! He was such a great lecturer to have on my first course on university, and he left a good enough impression that three years after the course it still makes me excited to see him in a video!
@bra5081
@bra5081 3 года назад
I find this dude's enthousiasm very communicative. I would love to attend one of his classes. His students are lucky.
@XetXetable
@XetXetable 7 лет назад
I'd like to see a video on dependent types, and type systems in general, in the future. Types are extremely important to properly using languages like Haskell, and they have a rich history of interactions with the foundations of mathematics.
@ioratv
@ioratv 5 лет назад
Having no side effects, now this is genius! I was so impressed with functional programming that I spent last 5 years of my life coming up with an algorithm that can tell if a function is going to halt or not in O(1) time even. I'd would like to share the code with you all but unfortunately that would be a side-effect so I can't.
@atlantic_love
@atlantic_love Год назад
Nonsense
@Nikkikkikkiz
@Nikkikkikkiz Год назад
@@atlantic_love I'm pretty sure this comment was a joke
@MrMctastics
@MrMctastics Год назад
curse these side effect rules, curse them!
@dealloc
@dealloc 4 года назад
Few clarifications: Functional programming in at of itself doesn't mean you don't have side-effects. Functions that doesn't mutate and always provides the same output with the same input are called pure functions, which are part of the functional programming paradigm. Side effects are inevitable if you work with I/O such as networking, threads/multiple processes. You can still use functional programming languages (like Haskell) to write functions that handles side-effect, but it's usually done by separating them out from other business logic. Scala is also not _really_ a functional programming language by itself. It is mix between functonal and object-oriented, similar to JavaScript.
@kieranblazier4058
@kieranblazier4058 7 лет назад
YES. More of this! Love where this channel is going.
@doctorscoot
@doctorscoot 7 лет назад
I was taught Miranda in my first year of university, 1989. Twenty years later into my career spent mostly with C and Java and I was surprised to find it making comeback! (in the form of Haskell, Scala, etc).
@karlkastor
@karlkastor 7 лет назад
He wrote QuickCheck? I used it during a Functional Programming course in uni. Very useful to make sure you got a function right fast.
@ancieque
@ancieque 5 лет назад
I have read some of Hughes' papers and listened to him on RU-vid and just wow... He is just so elaborate without confusing people.
@Posiman
@Posiman 2 месяца назад
Watching this in 2024, it's amazing to hear there was a time when there was no spam on facebook.
@ThePixelize
@ThePixelize 7 лет назад
John Hughes is an incredibly nice man. Had the fortune to have met him twice so far.
@Antony0098
@Antony0098 5 лет назад
I love the amount of passion this guy has about what he does. Very interesting stuff. Had no idea Haskell is used in so many ways. Good interview, and love the samurai remake =)
@LukusCannon
@LukusCannon 3 года назад
I was lucky enough to take multiple Haskell courses with Dr. Jon Peterson, a contributor to much of the Haskell98 documentation during his tenure @ Stanford, as well as a co-author of the Arrow ( -> ) Prelude extension class. He sadly passed near the end of my graduating semester - It was a privilege to learn from him.
@gulllars4620
@gulllars4620 7 лет назад
I think one of the nicest parts about functional programming is the focus on composability. You can have functions that take functions and returns functions, which you can then run (btw, you can also do that in many mixed paradigm languages that are not pure functional).
@andobando4873
@andobando4873 7 лет назад
So glad you put this out, I was just starting to teach myself Haskell
@PixelOutlaw
@PixelOutlaw 7 лет назад
The most important thing is to pick the language and paradigm that works best for you and the project. It is nice to be able to use functional styles when the language and problem fits it. I tend to fluctuate between Functional and Imperative styles in the same project often. Sometimes that implicitly bound functional environment is nice to have other times a state modifying loop is handy. I tend to try and stay with what the language designers expect though. A lot of functional style recursion will blow the stack if implemented carelessly in many imperative languages. I tend to write in Common Lisp which allows for both but I can respect people who prefer one paradigm if it feels more "pure" to them.
@bobzone09
@bobzone09 7 лет назад
Really like the way he explains the concepts at hand. Perhaps it is just suited to my learning style, but I understood everything he said and its implications, and I'm by no means an expert.
@jaymalby
@jaymalby 7 лет назад
This was awesome! Very nicely explained. Computerphile needs to do a video on Lisp next- something on the history, or more modern dialects like Clojure. That would be really cool!
@pedrofurla
@pedrofurla 7 лет назад
nah, lambda calculi
@Tatsh2DX
@Tatsh2DX 7 лет назад
Functional is the future. I truly believe it. Haskell is my favourite functional language. Used Haskell at IMVU for many things.
7 лет назад
The world has been moving away from functional so it would have to make a comeback which it doesn't really seem to be doing. In functional programming everything feels like an algorithm. There are things like GUI programming that don't lend themselves well to this way of thinking.
@pedrofurla
@pedrofurla 7 лет назад
Note Purescript, Elm, GHCJS, and various FRP Haskell flavors, this is UI mostly, for everything else notice companies using Haskell, Scala and OCaml.
@OverG88
@OverG88 7 лет назад
Companies using Haskell? You got to be joking...
@Tatsh2DX
@Tatsh2DX 7 лет назад
Need to mention Nim as a Python-style alternative to Rust. :) You can get the best of both worlds, but I would rather see functional if there had to be one. In any given program, design 99% of the functions/methods to have no side affects (what constitutes a side affect depends on the situation). Do not give in to temptation to make quick fixes which break this rule. As a benefit, you get automatic thread safety and re-entrancy.
@Tatsh2DX
@Tatsh2DX 7 лет назад
Lazic B. It's a lot faster than PHP?
@hmhamam_ham
@hmhamam_ham 7 лет назад
Just did a module in a Java course that was about the functional programming implementation in Java. This is adds a neat perspective.
@anja8595
@anja8595 7 лет назад
I love haskell! : D Thanks for covering it.
@DanielMinshewTheInternet
@DanielMinshewTheInternet 7 лет назад
Yes! Thank you Computerphile, great great intro to some huge ideas!
@pedrofurla
@pedrofurla 7 лет назад
Hughes ideas too!
@jellocraft34
@jellocraft34 7 лет назад
Can we get more videos about Functional Programming / Lambda Calculus and how to solve simple problems with this way of programming?
@kathyh8047
@kathyh8047 7 лет назад
very cool! had a module on Haskell last year which I really enjoyed; the teacher was super enthusiastic about it haha
@gggfx4144
@gggfx4144 5 лет назад
Really enjoyable video, for a while I've been wondering what makes functional programming different. What I do find strange though, coming from a language which separates functions (return a value) and subroutines (no value return) is that it seems obvious to me that a function wouldn't do anything else than return a value - you could implement that paradigm just with a change of programming style
@jojo300001
@jojo300001 7 лет назад
'I didn't think there was spam on facebook!' What...?
@madsmtm
@madsmtm 7 лет назад
Facebook is pure spam
@howtoandroid7523
@howtoandroid7523 7 лет назад
I think it was 'a little bit' of sarcasm :D
@SpeedyDrawMcGraw
@SpeedyDrawMcGraw 7 лет назад
Spambots with 10000+ friends and posts all fake don't really exist anymore.
@RWoody1995
@RWoody1995 7 лет назад
Never had any spam myself or heard of anyone who gets spam. Twitter on the other hand oh wow what a world of spam that is lol
@LeoMRogers
@LeoMRogers 7 лет назад
I only see spam when I click on one of the trending news stories, and see a load of identical statuses posted by completely different people. I've never seen spam in my news feed, unless you count advertising, and posts from pages like by your friends, but facebook puts those there deliberately, so its not really the same.
@JamesCoyle95
@JamesCoyle95 7 лет назад
Would there be any possibility of actually covering the process of creating a language definition and writing a compiler and/or interpreter for it?
7 лет назад
The would require an entire series of videos. Creating a language is easy but writing a compiler requires a lot of low level assembly understanding.
@JamesCoyle95
@JamesCoyle95 7 лет назад
Stefán Örvar Sigmundsson not necessarily. It could just be compiled into another language which can then compile to machine code. It's more the theory behind the syntax and how the raw text can be processed into a data structure that is of use to a compiler.
7 лет назад
James Coyle Compiling into another language is called source-to-source compiling or transcompiling, sure that's a lot easier.
@pwnageperson32
@pwnageperson32 7 лет назад
You don't know what you're talking about
@fnvtyjkusg
@fnvtyjkusg 7 лет назад
+James Coyle If you google "g53cmp" that will take you to a course page for a Compilers module taught at the University of Nottingham which is implemented in Haskell if you are interested.
@themodernshoe2466
@themodernshoe2466 7 лет назад
You should do a video on lambda calculus!
@firemaker272
@firemaker272 7 лет назад
Fantastically explained, thank you very much sir!
@jamma246
@jamma246 7 лет назад
I love using Haskell, thanks for the video!
@ulilulable
@ulilulable 7 лет назад
Hughes! This brings back memories from my first fp course at Chalmers way back. :D
@MrDaanjanssen
@MrDaanjanssen 7 лет назад
6:35 Those Karate lessons really are starting to pay off
@squirrelpatrick3670
@squirrelpatrick3670 2 года назад
Bruce Lee would have been a great functional programmer
@mattlm64
@mattlm64 7 лет назад
I've never looked into functional programming that much. It's so very different from other types of programming that it pretty much requires going back to square one.
@TechyBen
@TechyBen 7 лет назад
Most languages do that (spoken and programmed).
@hanelyp1
@hanelyp1 7 лет назад
You can do functional style programming in most procedural languages. But it would be on the programmer to avoid side effects. It's advisable in many cases for subprograms to avoid or restrain side effects even in procedural programming.
@mattlm64
@mattlm64 7 лет назад
I'll certainly get around to it one day. I don't have the time to learn functional programming at the moment. It's certainly interesting. When I have looked at it before it seemed to be harder to read and comprehend than imperative programming, as imperative programming makes it easy to follow the flow of the program, but a large part of that might be that I'm not used to functional programming. If I learned it, I should find it more intuitive over time.
@jbrownson
@jbrownson 7 лет назад
You're right, but I highly recommend taking the time to do so. You'll be greatly rewarded even if you don't wind up using Haskell it will give you new abstractions to make your programming in other languages much better.
@jbrownson
@jbrownson 7 лет назад
going from Java to Haskell is much more difficult than going from Java to C++. It's a different way of thinking not just a new syntax, but it's very much worth the effort.
@peter_castle
@peter_castle 7 лет назад
It should have been longer, very interesting theme and guy!
@SchplatJR
@SchplatJR 7 лет назад
It's been years since I used Erlang. It was actually fun to build a prototype for my last project during my internship.
@Outfrost
@Outfrost 6 лет назад
Now Mr Hughes is a professor I'd love to have at my faculty.
@andrewdunbar828
@andrewdunbar828 7 лет назад
You really really need to do a video on monads. One of the functional programming topics that many of us have a lot of trouble getting our heads around.
@andybaldman
@andybaldman 2 года назад
They did one. Still doesn’t make any sense though.
@georganatoly6646
@georganatoly6646 5 лет назад
Generally, whether you prefer OO or functional, your functions should be stateless and without side-effects unless they need to have state. Also unidirectional data flow is much easier to work with.
@ancbi
@ancbi 7 лет назад
As a category theorist in training... I was waiting for the words like "Haskell enable composable side effects" which never came.
@DDranks
@DDranks 7 лет назад
I expect there to be something about monads and burritos in the next video! (And monoids in the category of endofunctors!)
@Greamzih
@Greamzih 7 лет назад
Then this video must not for category theorists. I hope functional programming will share the fate of OOP: in the beginning everyone thought, so I heard, that OOP was super difficult and only geniuses could do it, but nowadays OOP languages like Java and C# are considered not requiring too much technical expertise.
@p_serdiuk
@p_serdiuk 7 лет назад
Вася Бубликов And now we are moving away from OOP towards even better paradigms. It all depends on the existing availability of tools, the more stuff is already written that enables you to write code in a particular way quicker and easier, the more people will adopt it.
@cube2fox
@cube2fox 4 года назад
One thing he doesn't mention is the fact that functional programming languages are used only very, very rarely. Probably less than 1% of all produced code today is written in a purely functional language like Haskell. Almost all other languages are imperative with a few functional ideas mixed in, or (more rarely) hybrids of sort, like Scala. Even scientists, which are usually much more math-savvy than usual business programmers, rarely use Haskell. So why are functional languages so unpopular, despite all their advantages? My theory is that one problem is their inability to handle loops. As far as I understand, in functional languages you always have to use recursive functions instead of loops. Which has two problems: - Recursive functions are usually significantly harder to understand than loops, which makes writing and reading code more difficult, and increases the chance of making mistakes or not understanding someone's elses code. If programmers have the freedom to use either of them, they, in by far the most cases, use loops instead of recursive functions. - It is much easier to write inefficient code with recursive functions than with loops. E.g. if you write a loop inside a loop, you usually end up with a time complexity of about O(n^2), which can in most cases still be computed very quickly. However, if you write two recursive calls in your recursive function, you typically get something like O(2^n)! Computing this can get _extremely_ slow even for what you might consider medium sized inputs. (Also, if you want to make a recursive function really as efficient as a typical loop, you often have to make sure that your function is "tail-recursive", which is even harder to write and understand than usual recursion.)
@zhulikkulik
@zhulikkulik Год назад
Got an error on my calculator trying to calculate 2^1024 )) My take on the reason why they aren't popular - they feel extremely... Elitist? In a sense that most languages use pretty familiar or understandable concepts like array, loop, variable, pointer etc. But «monad is a monoid in a category of endofunctors»... Is it just a meme?
@nO_d3N1AL
@nO_d3N1AL 7 лет назад
I'd recommend watching some of Venkat Subramaniam's talks on functional programming for any developers watching this video
@Fexisepic
@Fexisepic 3 года назад
I learned haskell in my first semester programming course at uni. I absolutely hated it at first for its lack of global variables and pickyness with types, but once I understood the basics it was very nice to use and programming with it felt like a fun challenge.
@recursion.
@recursion. Год назад
Do you still use it?
@exoticcoder5365
@exoticcoder5365 3 года назад
6:36 It awakes the deepest part of my soul
@robert33232
@robert33232 2 года назад
For perfomance we theoretically could take the Rust's memory management model which allows us not to use Garbage Collector and at the compile time automatically create the instructions for freeing the unused memory.
@MorganEarlJones
@MorganEarlJones 7 лет назад
Follow up please! Higher-order functions and type declarations :3
@PointB1ank
@PointB1ank 7 лет назад
Rocky Horror and functional programming in one video? Great stuff.
@alecdelu83
@alecdelu83 3 года назад
This man represents perfectly the meaning of passion, easy to tell :)
@kjell3198
@kjell3198 7 лет назад
Haskell and Erlang are both really nice languages to work in. I prefer it so so much over C/ C++.
@chadestioco
@chadestioco 7 лет назад
6:36-6:38 startled me. :) Out of curiosity, does anyone know what laptop brand he's got there?
@kaboom1321
@kaboom1321 2 года назад
2:08 i like his „Oh“
@keheliya
@keheliya 5 лет назад
Subtitles incorrectly say 'airline' instead of 'erlang' :-)
@AquibA
@AquibA 3 года назад
Thnx for clarifying.
@lachlanmann4511
@lachlanmann4511 3 года назад
I love this guy's voice
@HebaruSan
@HebaruSan 7 лет назад
Haskell has one awesome feature I've never seen anywhere else (but that's probably just my ignorance): partial application. If you define a function that takes three parameters, you can call it with just one parameter, and the result is a new function that takes the remaining two parameters, with the value you passed bound to the original first parameter. And this works for ANY function. When I write a function in Haskell, I tend to order the parameters according to how likely I am to want to bind each one like that.
@prochafilho
@prochafilho 7 лет назад
You can find partial application in all sorts of computer languages. I use a lot of partial application with Javascript, believe it or not; I have also seen it in Python. I truly love this feature.
@HebaruSan
@HebaruSan 7 лет назад
***** If you call a Javascript function with fewer parameters than it's defined to take, the left over parameters are just set to 'undefined' and the function is executed as normal. I guess you're talking about writing a special function that returns a function? Haskell makes it SO much easier.
@prochafilho
@prochafilho 7 лет назад
You are right.
@germannavarro7320
@germannavarro7320 7 лет назад
HebaruSan lool. Thats functionception and is in every prg lang that supports closures
@gofer9156
@gofer9156 7 лет назад
Technically, all Haskell functions take one parameter only, and may, as result, return functions returning functions, and so on ... There's nothing special about functions compared to data. Functions ARE data.
@ghelyar
@ghelyar 7 лет назад
At my work we were mixing and matching F# and C# for a while but ended up just ditching it in favour of using a single language (C#) for maintainability and performance, among other reasons, and using the ideas behind functional languages like immutability and avoiding side effects (e.g. using a [Pure] attribute and static code analysis) without the burden of the unintelligible syntax. I've yet to see anything in functional languages that you can't do in imperative languages, it's just a bit stricter.
@incelstate2466
@incelstate2466 3 года назад
What kind of programming language would you recommend for firing the missiles? Thanks
@DrDress
@DrDress 7 лет назад
He make it sound like functional programming is something new. I thought it predated most "conventional" programming languages (like LISP from '58).
@waynemv
@waynemv 7 лет назад
Do tasks like reading input and displaying output count as side effects? Is the idea for the program to have core functionality that is solely functional, called by a user interface written without the functional restrictions? Is functional programming better for particular kinds of programming tasks than others? If so, what kinds of projects does functional programming work best with and worst with?
@zubmit700
@zubmit700 7 лет назад
Could be nice if you made a video on Kaspersky Lab's new secure operating system.
@alcesmir
@alcesmir 7 лет назад
You were at Chalmers? If so, I hope you liked our university! I'm not a CS student, but I've heard about John through friends who are. Very interesting to hear from someone who helped pioneer the field.
@DanielBeecham
@DanielBeecham 7 лет назад
He's still definitely about. He holds guest lectures at the campus every now and then.
@jyrikgauldurson8169
@jyrikgauldurson8169 7 лет назад
John Hughes teaches Parallel Functional Programming in the Master's level at Chalmers.
@sebbes333
@sebbes333 6 лет назад
6:09 Is it possible to run a whole functional program on a GPU? (because GPUs are usually better at multitasking) So as long as a function isn't depending on a previous function has to finish first you can push them all into the GPU (as long as there are available threads) and get the expected result each time?
@lukekurlandski7653
@lukekurlandski7653 6 месяцев назад
I love the idea of func programming, but I constantly run into problems with efficiency. A lot of my code does large scale data processing. I end up doing a lot of caching/checkpointing on the filesystem. My code ends up being very confusing an error prone, but I just can’t do it any other way.
@markusr3259
@markusr3259 7 лет назад
That was a better explanation than we ever got at university... That said, I find find the premise of it a bit odd. I *want* functions to be able to have side effects, encapsulation is one of the major foundations of object orientated programming... call a member function, have it update something, and (optionally) return another value... the same in C operating on global variables... I would argue it is more reliable to have well defined side effects than to go without them at all. A compiler could also easily tell you if a function referenced anything external to itself, as when compiled in isolation anything external would be unlinkable.
@sebastiaanpeters2971
@sebastiaanpeters2971 7 лет назад
You can still have side effects in functional programming languages. You can take a look at the IO monad of haskell.
@viktorstrate
@viktorstrate 7 лет назад
Please make a video, describing the general idea of functional programming
@pedrofurla
@pedrofurla 7 лет назад
+Marcos Martinelli answer isn't incorrect but IMHO is not the core of the question. (Marcos, these are implementation details). +Viktor Strate, the general idea is total functions. Every input produces the same output and always the same output for the same input. Actually, that's exactly what "without all of the under the hood" Marcos pointed to.
@Demki
@Demki 7 лет назад
More of John Hughes please!
@thomaskember3412
@thomaskember3412 2 года назад
I have been studying Haskell for some years. I keep getting stuck on understanding monads. The term comes from Leibniz and I pretty well know what he meant with it. But what it has to do with Haskell I just can’t figure out. A video that explains what a monad is and how it is used would be very welcome.
@tomsawyer283
@tomsawyer283 Год назад
Additionally, part of why local variables aren't side effects aside from how they are allocated on the stack is the same as the constant of integration.
@Pyriold
@Pyriold 7 лет назад
Would be nice to have a little deeper discussion about functional programming. How to overcome its limitations for example. Not being able to easily use mutable variables is so foreign to a "normal" programmer that people get frustrated very fast when trying functional. I tried once and wasn't convinced that the benefits are worth the limitations. Later i met an earlier colleague and he was very enthusiastic about haskell. For a "normal" programmer functional programming is pretty hard at the beginning.
@davidwuhrer6704
@davidwuhrer6704 7 лет назад
Bah. You are thinking about variables the wrong way. Typically, C style programmers think of variables as bins in which to put values. What you should think of variables as is aliases for values. This way you won't need mutable variables, and come to see them as the abhorrence they are. The compiler should make the code use the available registers optimally, not the programmer. This isn't the 20th century anymore. Nary a programmer even knows how the registers will be used with dynamic superpipelined out-of-order execution on a multi-core processor with parallel arithmetic and logic units and with branch prediction in speculative execution pipelines and multi-layer caches anyway.
@valshaped
@valshaped 7 лет назад
I love Scala; it was the subject of my 1-year independent study project.
@uzKantHarrison
@uzKantHarrison 5 лет назад
Cool, seems I have chosen the right uni to learn functional programming!
@ttthttpd
@ttthttpd 7 лет назад
Chalmers University and Functional programming? You better be getting ready to do an Agda and dependent (AKA Per Martin Lof) type theory video! Or perhaps a video on the Howard Curry Isomorphism or it's extension "computational trinitarianism"
@mellamosteve331
@mellamosteve331 3 года назад
6:35 When the java intro teacher sees students checking if 2 strings are the same with str1 == str2
@rolandgharfine534
@rolandgharfine534 7 лет назад
I would LOVE to know more about "Quick check"
@thingsiplay
@thingsiplay 3 года назад
6:31 I have to say, I didn't see this coming. He surprised me.
@World_Theory
@World_Theory 4 года назад
I don't know the right words for talking about programming languages, but I have a question, so I'll just try my best… Regarding higher level programming languages, such as the one this video's about… Do the things that make it up, have a direct equivalent in a lower level language that's not machine code? Because one way I'm imagining how it works, is that someone decided on a list of things that it ought to be able to do, and then built those things with a lower level language, by going over them with a fine tooth comb to find bugs, spending a lot of time to make sure each one does what they mean it to. Then you use those things to build your program, like building a machine out of off the shelf assemblies of parts, like a motherboard is assembled from lots of little electronics, such as capacitors, resistors, chips, etc., and the parts can be equated to a low level language, and manufacturing process to make all of those individual parts is the equivalent of machine code.
@Boopadee
@Boopadee 4 года назад
It is true that plenty of languages are built on lower level languages. I only really see examples where the compiler is written in C(++). Beyond that though, there's assembly which is a little higher level than machine code but not by much. With the introduction of intermediary languages like webassembly, you can often compile to something that is completely detached from the computer's hardware implementation
@World_Theory
@World_Theory 4 года назад
Daniel Vasquez, Thanks!
@coolluckyme2007
@coolluckyme2007 7 лет назад
If you don't specify all or correct requirements to the quickcheck there still will be gaps in the tests, so what does quickcheck solve? Is it trying to bring easier syntax (implementation) to describe a unit test?
@jpratt8676
@jpratt8676 7 лет назад
coolluckyme2007 Pretty much, it's a really handy way of checking that a property holds true for a lot of inputs (not just the ones that we worked out by hand). You should test static data (e.g. data that has broken the code before) and also dynamic tests which quick check does. Its a really amazing tool that I have been saved by a few times
@heyandy889
@heyandy889 7 лет назад
it sounds similar to "behavior-driven development" or even test-driven development
@dealloc
@dealloc 7 лет назад
BDD and TDD are methodologies-write tests first, then implement to fulfill those tests-whereas QuickCheck is a program to empower those methodlogies.
@Suprem0o0radical
@Suprem0o0radical 5 лет назад
One thing I don't catch is what he said at 6:20 - I mean you can have the same safe parallelism if you do a pass by value and spin-off two threads in a conventional program no?
@MrWvid
@MrWvid 7 лет назад
Can you do a reactive functional programming? That would be cool, I can't find any video explaining the concept itself.
@thomassynths
@thomassynths 7 лет назад
Does this mean we'll get Simon Peyton Jones too? (All these sorts of Haskell guys are awesome.)
@pedrofurla
@pedrofurla 7 лет назад
Yeah! Yeah! And Phil Wadler and Simon Marlow!
@bjzaba
@bjzaba 7 лет назад
Phil Wadler would be amazing. I might resubscribe then! :D
@pedrofurla
@pedrofurla 7 лет назад
Wonder if the guys of ***** are reading these. Another great one would be Simon Peyton Jones
@berksteraydo9517
@berksteraydo9517 6 лет назад
The fact that closed captions have some [words] in '[ ]' ( funny-right?) erlang code is written as airline code every time.
@DarkGuardsman
@DarkGuardsman 7 лет назад
Is there a java version of quick check as I'm not a fan of writing 100s of java JUnit tests for my code. It currently takes up 45% or more of my time per project.
@tx7300
@tx7300 5 лет назад
not sure if you guys will read this, but the English subtitles seem auto-generated (even though they were seemingly manually uploaded), they're full of errors and strange notation with square brackets.
@Desmaad
@Desmaad 7 лет назад
Would you do a section on Lisp languages?
@lordansem2
@lordansem2 Год назад
I think of functional programming and side effects like this: A = B, where B is a function or operation. While we do this implicitly in math, we specify to computers the Boolean operators ==, and ===. Ultimately, A can be represented by whatever by is on the right so long as A == B is true. However A === B is false in a pure function. While A and B may have equal values, what happens to B is not directly happening to A. Take 7=4+3. 7 is 7, 4+3 is 4+3. In programming = would be an assignment, but in math it's a == in programming syntax. 7 can be represented by really any infinite combination of operations. In 7=4+3, 7 is never being directly changed or manipulated. A pure function's output is constant given the same inputs
@lepidoptera9337
@lepidoptera9337 Год назад
A pure function is useless.
@maria-lm8ze
@maria-lm8ze 4 года назад
4:08 omg that would be AWESOME i'm calling it Curry from now on
@MikaelLAOhman
@MikaelLAOhman 7 лет назад
Quick check can't solve core issue with testing correctness of programs. Writing a test that checks that function does what it's supposed to? How do you know the results? By writing the function again in the test? And then test the test's test's tests.... It can only be used to check simple properties, like the length of the output. And to get any decent coverage you have to still write all these property-checks.. and on top of that you have to write a generator for valid inputs. Many functions have very complex scenarios where they don't throw an exception, so writing a generator that randoly manages to generate valid inputs is harder than writing the test itself. Nothing about this is automatically generated (and it can't ever be).
@lakshyarajsinghrathore1902
@lakshyarajsinghrathore1902 2 года назад
If i want to learn much of functional programming and related concepts which two should i choose out of haskell, clojure, racket, scala. can anyone give me a detailed explanation.
@schmetterling4477
@schmetterling4477 2 года назад
You shouldn't chose to lean functional programming, in the first place. It's useless.
@Wabbajack-kj2kg
@Wabbajack-kj2kg 20 дней назад
Go Haskell or ask chatgpt
Далее
Lambda Calculus - Computerphile
12:40
Просмотров 997 тыс.
Object Oriented Programming vs Functional Programming
18:55
Rust and RAII Memory Management - Computerphile
24:22
Просмотров 211 тыс.
How DNS Works - Computerphile
8:04
Просмотров 454 тыс.
Simon Peyton Jones - Haskell is useless
6:23
Просмотров 364 тыс.
Uncle Bob LOVES Functional Programming | Prime Reacts
22:59
Programming Loops vs Recursion - Computerphile
12:32
Просмотров 1,4 млн
What is a Monad? - Computerphile
21:50
Просмотров 588 тыс.
Why C is so Influential - Computerphile
10:50
Просмотров 1,9 млн