Functional Programming & Haskell - Computerphile

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
functional programming is essentially kind of programming where functions don't have side effects So what does it mean when you call a function you give it some inputs? And it will return some output and that's all that it does it doesn't modify the inputs It doesn't do something on the side people often talk about firing the missiles It can't do that the entire behavior of the function you can see by [looking] at what the inputs were and what the apple was that was generated and if you [program] [in] that style, then functions are you know you know a lot [about] their behavior and Many of the mistakes that are easy to make when you program in more conventional programming languages is that [you] forget about some effects that a function has in addition to returning its result and What you forget about those effects then they can lead to very difficult to find bugs and a lot of wasted time? What did I get used for these languages? Quite a variety of things they've made a lot of impact on the server side of internet applications. So for example haskell Which is the language that I played a part in designing. That's now used for all the spam filtering on Facebook now when I heard that first of all I said, I didn't think there was spam on Facebook and Sally Marlowe, the man is now in charge of this said to me exactly That's how good we [are] All of that is running in Haskell nowadays another example would be airline that's another functional [programming] [language] which I'm working with a lot at the moment [and] Airline was used to implement. Whatsapp always everybody uses whatsapp at some point that's all airline code running behind it there are other examples Twitter's code is built using scala which is a programming language that I think was heavily inspired by Haskell, but integrates very well with Java and but it's also mostly functional and So you know many of the services that we use [everyday] are actually running functional code in the background You've just mentioned then you had a hand in the development of haskell. Where did you start? [did] you have a big team that you weren't where tell me about that? Oh? so that was interesting and so when I first got in functional programming there were small number of people working on it at different universities around the world and In those days you couldn't really get hold of a functional programming language from somewhere else you had to write your own compiler So many of us around the [world] were doing that and then after [a] while We realized and it was a man called Paul [hugh] deck yale university took the first initiative to this We realized that we were all working with very much the same kind of programming language But because we each had our own compiler. We couldn't share any code We couldn't share our results And that just seemed [like] a waste of effort so that led to the proposal [tooned] just Take the common core [of] what we were all doing put it together and [designer] a programming language that we all use Which became haskell what where did the name come from then? It's actually named after Haskell Curry who was One of the early logicians who work with with lambda calculus the first time that the committee that was formed designed the language got together? then we decided we had to choose a name and nobody really knew [what] to choose so we Everybody was allowed to write up one proposal on the blackboard and Then everybody was allowed to go round and cross off one proposal now you might think that we would end up with zero names that Way, but no there was one name that Survived and it was curry named after Haskell curry So that was fine. We thought okay the new language will be called curry and This is last thing in the evening. So we all went to bed which meant we had a chance to sleep on it and next morning one of us realized that one of the Abstract machines that was very popular at that time was called the Tim Tim curry Oh dear [that] [wouldn't] be good and so we decided to call it haskell instead, so it's still named after haskell curry But his first name rather than second from what I've [seen] when you look at a functional program It is very much like a mathematical equation am [I] right with that. Yes, that's right. So one of the things is that like mathematics Functional programs will satisfy what we call laws for example in mathematics if you see x plus y you can always replace it by y plus x if that's more convenient and in Functional programs then very often you may be able to replace one program by another so you have different ways of expressing the same thing And you can replace one by the other which you may want to do because one of them may be much more efficient than the other and you know that that replacement will not change the overall behavior of your program and So we find that these laws extremely important for reasoning about programs and they can let you Rewrite your program quite freely in order to try and improve its performance for example and be sure that you're not introducing bugs [I'm] assuming that the same kind of Mechanics are happening somewhere at some level on the computers with any other programming language though is a [repeal] for this is it slow is It faster. What's that? What's the deal? Oh, well, so Functional programming languages take care of a lot [of] the implementation details that an older programming languages you have to do manually for example memory management but nowadays It's very popular to use languages like even Java for example which builds memory management into the programming language functional languages do that too Very often there is some kind of performance penalty for this and that has meant that One of the very active parts of functional programming research has been developing compilers that [can] give good performance Despite the fact that you're programming at a higher level nowadays Code written and functional languages can be as fast as or sometimes faster than code written in conventional programming languages one of the very nice benefits of functional program by the way is that it's always safe to evaluate two independent expressions in Parallel and That's because functions have no side effects so you can all the functions going to do is convert inputs to outputs And you can have two of those computations going on at the same time they cannot interfere Whereas if you use Programming languages in which each function may be modifying data somewhere else at the same time then you can't tell whether or not Two functions will interfere they're very likely to and that means that when you want to make programs run in parallel When you want to make them use more than one of the cores in your laptop Then it's much easier to do that if you start with a functional program and that can give a performance benefit over and above What conventional programming languages have I've heard as well? there is [a] possibility to make hack-proof code using functional programming is that something you could tell me about or Yes, so there is a lot of work in trying to make of the cannot be hacked of for example. Can't leak confidential Data and There are people who are working on programming languages that will provide some guarantees about that one of the quite successful approaches is to build a library into haskell in fact that can be used for enforcing in particular Privacy constraints So yes, there's work [going] on in [that] area We're going to talk about things like your quick check And you know that we've already filmed some stuff on that and what do you up to? What do you do? What's what's next for you? So I'm devoting most of my time to quick check nowadays where the basic idea is not to write tests by hand because Because basically it doesn't work Software is so complex that to make sure there are no bugs in it you have to try all kinds of weird Combinations, and there are just too many combinations to try for people to be able to try them all so really the only way to ensure that you Avoid these bugs is to generate tests instead That's what quick check does it lets you write test Code that says what your program [should] do and then it generates as many tests as you want to check that it does And I've been working with quick check for many years now [10] years ago I founded a company that is commercializing quick check And that's been huge fun because it means I get [to] apply this technology to all of real problems all kinds [of] different kinds of software, and that's been a huge learning experience for me and a Tremendous source of Research problems when we find oh, it's hard to apply it in this case well There's a research [property] to solve so [as] a professor and a researcher It's given me all kinds of new ideas for problems to work on which which has been very very stimulating and the value of y at this position is going to be some polynomial that we have to find which is a x cubed plus [be] x squared Plus C. X plus d. There are four unknowns here x we know because we're going between no [1] 1
Info
Channel: Computerphile
Views: 650,661
Rating: undefined out of 5
Keywords: computers, computerphile, computer, science, computer science, University of Nottingham, Professor John Hughes, Chalmers University of Technology, FP, Functional Programming, Haskell
Id: LnX3B9oaKzw
Channel Id: undefined
Length: 9min 19sec (559 seconds)
Published: Wed Nov 30 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.