Why Isn't Functional Programming the Norm? – Richard Feldman

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everybody this is why isn't functional programming the norm I'm Richard Feldman so I'm gonna start with the question why is it functional programming the norm I as anyone else wonder this like everyone like ever looked around and be like hey yeah exactly like I spent a lot of time doing object-oriented programming in my career and then eventually came across functional programming I started doing it and doing it more and more and now I've been doing it for several years and at some point I was just like yeah what why isn't this the norm it seems so great like why isn't everybody else doing this so I set out to sort of answer this question and just it's pretty direct they say like why are things the way they are like why are they this way instead of that way and I found out the answer and it turns out the answer is it's complicated there is no one living very simple nice neat tidy answer but in this sort of quest for understanding I ended up learning a lot of things about that sort of explain why things got to be the way that they are and I'm gonna share them with you so because it's complicated gonna break this down into three parts so first gonna talk about language and then paradigm and then finally style so I'll start with language so what languages are the norm today if it's not functional programming once you know what is it so I found this study by this this company called slash data and they've drawn up various different sources to compile this information and they ended up producing this global developer population report for 2019 which you can read on their website and it basically blazed out the top ten languages like in terms of usage thusly and this is probably no no serious surprises here JavaScript Python Java and so on and so forth these are probably languages we've all heard of and it's also not huge surprise that unfortunately the total number of functional programming languages in this list is zero out of ten but you know that's the way things are not necessarily the way that I would like things to be and so looking at this list I then sort of ask the question like how did they get so popular like how do they become some of the 10 most popular languages in the world so I ended up concluding that this breaks down into three major categories and then two kind of exceptions so one is they had a killer app another is they had some form of platform exclusivity another is they had a really quick upgrade story so let's start with the killer apps so this is the Apple 2 and it's running VisiCalc so physical is one of the earliest examples of killer app and what I mean by that is that basically people wanted to use visicalc so badly they would sometimes pay upwards of $10,000 for this hundred dollar piece of software to get the hardware to run it on like people wanted visit calc in their lives so badly they would just go out and buy an Apple too just so that they could run VisiCalc and this is sort of like an example that sort of crops up in programming languages as well byte magazine back in 1980 said VisiCalc is the first program available that has been responsible for sales of entire systems and that metaphor also extends to cases where if someone wants to get at a particular application of a programming language and then they buy into the programming language itself along the way as a sort of a cost of getting at the application they want so here's an example of this what would you say is the killer app for the Ruby programming language well it's exactly right and I think this really drove this point home when I looked up the like the Google search trends for both Ruby and for rails and it turns out they have the same shape like in 2005 when rails comes out like rails Google search term goes from zero has a big spike and then Ruby has exactly the same spike and then rails popularity tapers off and then Ruby's popularity tapers off so I think from this I can kind of conclude pretty definitively that like Ruby's popularity in the top ten is explained by rails and I don't think that if rails had not happened that that Ruby would actually be one of the top ten most popular languages killer app for PHP I think has changed over time so I think at first it was basically the things that kind of everybody was using it for which is basically making HTML dynamic like if you've got a static HTML page and you wanted to make it a little bit dynamic it was really hard to do that faster more easily than PHP you just like tweak some stuff insert some code in the middle of your HTML and then up a little like you know FileZilla it up to a server and then okay it's there you go you're done but these days it actually seems to have narrowed down to having like two particular kit for PHP so this is a graph of PHP is popularity over time a little bit more dire than Ruby's it's been like in pretty steady decline since 2004 and in fact if you look at the end in these two particular applications of PHP WordPress and Drupal it looks like the the total number of hits for PHP is like the sum of WordPress and Drupal odd like that's about it these days which kind of matches like anecdotally what I hear from people I still hear people using Drupal a good mount I still hear people using WordPress for building sites for people but in terms of like using PHP for like their own site or for going out and then like starting a startup around it that's like pretty much done like Facebook and slack are kind of cautionary tales in that regard killer app for C it was actually systems programming so back in the day when this came out this is way before my time but I actually watched a talk by Brian Kernighan one of the co-creators of C and he explains that actually at the time if you wanted to do like systems level programming like you wanted to write a kernel or you wanted to write like LS or some you know system utility your options are basically like assembly language or Pascal which I'm not a Pascal programmer but the way that he talked about it sounded like that was a ludicrous idea so apparently not really done and so when C came out it really filled this need a lot of people had so like awesome I want to do systems programming I'm gonna reach for C that really kind of kicked off C's popularity I think there's some potential for like some FP killer apps like anything can do it if something comes out that's sufficiently popular if it takes off I believe that it would take that language with it so examples that come to mind for Elm there's Elm UI basic pitch there is you don't have to write CSS anymore you know you can make front-end applications and it's got this whole layout system that's really nice that you don't have to think about CSS you just write your code Elm code and then you have a UI closure de Tomic like it's a nice database like that's independent of programming languages if you want a really nice database and you say hey I think I would like to use the atomic on date Tomic takes off if a bunch of people say that I think it would bring closure with it it would it would bring a lot more closure programmers into the world in the same way that rails did for Ruby and finally a reason ml has this thing called reverie where the basic pitch is you can have a cross-platform app built with web technologies but it doesn't actually run let everyone's favorite electron so all these things you know have the potential to cause these languages to take off in the same way that they have for non-functional languages it's just a matter of will they I don't know we'll see so second way that a lot of these languages became popular is platform exclusivity so I'm gonna talk about a few examples objective-c Swift JavaScript and C sharp so start with Objective C and Swift does anyone think that Objective C and Swift are just like great general-purpose programming languages used in all sorts of different domains kind of the way the Python is okay there's one III appreciate your bravery so I think probably the rest of the people were thinking is like no those are things that you use to build for Apple but it turns out you know even if that's kind of their deal like Apple has this like platform exclusivity thing we're like these are the blessed ways to develop for Apple and everything else is maybe technically supported but like really really difficult in comparison turns out Apple makes a ton of devices so even if like both of these languages Objective C and Swift are pretty much just being used to build for Apple devices that's such a huge amount of development that gets done that it's just like yeah that's enough to get you in the top ten and which is kind of interesting if you think about it because it almost means like pretty much no matter what the design of these languages was within reason could have been functional could have been imperative could have been object oriented could have been just about anything and they would be in the top ten because Apple is such an enormous you know source of programming so interesting to think about these things JavaScript kind of in the same boat not not with a proprietary thing but just with the web I don't know if you know this but studies have shown that the web is huge and and has gotten really big and I mean technically when it came out like in the at the inception of the web there were like two and then very shortly three viable options namely JavaScript Java applets remember those and flash remember that and and pretty quickly people discovered that the problem with Java applets is that they're miserably slow no one was ever wants to use them and flash kind of had a heyday it had a good run and by good I mean was full of security problems and crashing but eventually it kind of died off no one really knows why and and then eventually it was pretty much just JavaScript so it javascript had platform exclusivity over the most popular application delivery platform in the history of anything so somehow that made it to get all the way to number one really surprising next specifically over the web and as far as like you eyes go and so this is another example of platform exclusivity not because you know of a closed proprietary thing but because of an open standard where they just all converged on one language be interesting to see if web assembly changes this I mean it's really got an uphill battle but it at least has the potential that finally we come to C sharp this is an interesting case because it's about platform exclusivity from two different angles so first we have Microsoft Windows so this is mid-90s Windows 95 is you know in the works and out comes Java some from Sun Microsystems and Java has this tag line of write once run anywhere and Microsoft does not like this because if you can run it on any operating system trivially that means you don't have to run it on Windows and you could run it on somebody else's OS like Mac or Linux or something like that and Microsoft at the time made pretty much all their money from windows and windows related things so they really didn't want people to be writing a ton of Java they wanted to be people to be writing something that they controlled so they came up with this language called C sharp and that was the language that they controlled that had an almost identical feature set to Java by some very strange coincidence so what Microsoft actually wanted out of this was they wanted lock-in like they wanted people to be like ok let's let's just you know you use our thing instead of that thing but the way that they achieve this was by using platform exclusivity on their vast and very genuinely good network of tools and ecosystems around like MSDN documentation and stuff like that so if you wanted to get in on like the Microsoft IDE s like Visual Studio like before Visual Studio code and you wanted to get a Java like experience the only way to do that was C sharp because Microsoft was not gonna build those tools for Java they were just gonna build it for c-sharp and it was successful so c-sharp became a very popular language and it to its credit it had a number of design features that were considered by many people improvements over Java and this this got it up into the top 10 and then finally we have the quick upgrade path so this is basically sort of working at people's like the considerations that they do when they're deciding to adopt a programming language so of course everybody's thinking about the benefits you know the things that I think will be good if I use this language familiarity is always a big thing you know we're humans we get a first impression of something we're like ooh that looks nice I know what that is or you say like oh no that's a lot of parentheses but hypothetically you know this is a thing that people do like they we make snap reactions to things and it impacts whether or not things get popular learning curve is another one right like you look at this things like well that's slide on what the word Monette is like I don't think I'm gonna have time to learn all these text books about category theory or whatever ecosystem access right am I gonna be able to like it leverage this huge equal some of code that's already written for whatever languages and how much effort is it gonna be to migrate like how different is this from the current code that I have or the way that I'm used to writing code all of these things are considerations and sort of the quick upgrade path is basically saying don't worry about it don't worry about it this is all benefits and like the drawbacks like it's super familiar learning curves almost zero fully access to the ecosystem code migrations snap CoffeeScript is one of the early languages that that succeeded on this their tagline was it's just JavaScript and the bases were like yet you can learn this in about half an hour if you're a JavaScript programmer will migrate all your code for you can just run a script that will convert your JavaScript to CoffeeScript and then it'll have all these benefits and this was enough to rocket CoffeeScript up to at one point like at its peak it was the 11th most popular language on github and and this tagline was maybe not 100 percent accurate I mean it's literally not just JavaScript it is a different programming language but it's so close to JavaScript that it's like okay it's approximately equal to JavaScript the language that I think has a more reasonable claim to that is typescript I mean typescript is actually a strict superset of j/s so it's like okay yeah yes fair enough it that actually is just JavaScript so they actually have the thing where you can like rename your file name from JSC TS and it's supposed to just work right out the box nuke then you can just start adding features from there pretty impressive and certainly if you're looking at that and saying oh so you have these benefits and the costs are I have to rename the file okay that sounds good where do I sign up and a lot of people have signed up type scripts doing really well in terms of popularity C++ is arguably the first example of sort of like doing this and being really successful at it C++ is a near superset of C it wasn't like literally no typescript style a strict superset but often enough you could just take your dot C file rename is dot CPP and just go and just get the additional benefits of c++ worked out really well Carlina is maybe like the most modern example of this it's going more with the CoffeeScript flavor what Kotlin is a substantially different programming language from Java it's not just claiming to be a drop in upgrade but it is like they really emphasize this on the website 100% interoperable existing code bases I'm no trouble migrating we've got a script they'll convert your Java to Kotlin and again also language that's been doing really well ok so that's most of the languages in the top ten but there are two that we haven't talked about so one of them Java has a strategy for getting popular that as far as I know has never before or since been attempted to get popular which is epic marketing IV nice seriously so like in the 90s like there was a lot of coverage and in fact the early 2000s of basically all the money that then like power that Sun Microsystems was putting behind Java in 2003 they had they introduced a new five hundred million dollar marketing campaign just for Java like nothing else other than this programming language and keep in mind this is in 2003 when Sun was like having financial difficulty so like this was after I told amounts of marketing dollars that they had done back when they were flushed with cash and at this point they already had millions of Java users they were like it's not enough we need to announce a new RiRi F Zephyr and tell everyone how much money we're spending this did however result in some pretty hilarious stuff so this is from the late 90s this is a Sun Microsystems commercial called the spy and it's basically just like a James Bond spoof it's like James Bond and Q where they just like go through this like briefcase full of gadgets and Q's like this was built with Java technology like over and over it's like including this credit card that for some reason it's like Java code running on it like I don't I don't know exactly like why that's critical to James Bond's success here also there was this funny moment in the middle of the commercial where they just had this like woman in a lab coat holding a C++ textbook I think that was just to be like hey C++ programmers kind of use Java it'll be great and like that was the goal of Java was it was supposed to be familiar for C++ programmers they really wanted to to attract them James Gosling in one of his talks said used the term he's like we wanted to hoodwink them into thinking that Java was something that I already understood so they were like really pushing this even then the littlest commercial so this this was so successful that it actually impacted what has today become the number one programming language so the story of Java scripts early development was Brendan Eich was working for Mozilla he was tasked with making a scripting language for the browser so you could do real-time scripts in the UI and his original design was actually based on scheme like a functional programming Lisp that was what he wanted to doubt could have been number one but people at Mozilla were like have you seen this Java hypetrain that's coming we gotta get on that like what in the name like just stick it in front it's gonna have JAV a in our name and also make the syntax look like that and make the you know the language be object-oriented and Brandeis like okay and that's the story of why the number one programming language in the world is object-oriented instead of a functional Lisp you know I think it's pretty you would have a tough time making the case that it's like yeah you know if JavaScript had been a Lisp and it was the only way it had like exclusivity on the browser no I wouldn't have gotten popular now that that's you know web who cares about the way that's not a big deal I mean people get scared away from parentheses so no no no chance I mean it would still be number one it would still be the biggest thing in the world because the web was still the biggest thing in the world but this is why it ended up the way that it did it was because of ultimately Sun Microsystems spending millions of dollars on marketing go figure which brings us finally to Python which has unfortunately the the least exciting story of all these it's basically just like slow and steady it just slowly and steadily grew over the years so you can exemplify this by looking at Python in comparison to two very similar languages the Python Perl and Ruby so this is back in 2005 when rails is just taking off so you can see at this point among those three languages Python was the least popular so Python had just been kind of cruising along and Perl is kind of in decline almost PHP style and and Ruby at this point is just skyrocketed up in popularity because rails just came out so at this point Python is kind of in third place but hey so slow and steady wins the race as they say and as we see as time continues Perl continues to decline you know rails helps Ruby up but then eventually again it kind of tapers off Python still just kind of cruising along cruising along cruising along and then eventually Python just kind of gets an uptick the slope changed a little bit and it just sort of slides on up and then by the time we get to the president it's like holy cow what happened python is now the number two language in the world like out of nowhere but it wasn't out of nowhere I was just out of slow where it did really you know it never had like a rails moment where just like jumped up to the moon it was just kind of slow and steady and then eventually slow and steady slightly more increased and then that was it just multiply that by enough years and eventually it just becomes a really popular language so good on a might I almost feel like this is how we would like programming languages to work out you know they just have a good design they're people like them and then over time people use them more and that's it but of course as we're seeing real life it's more complicated than that most of the time of course there are other factors that go into popularity it's not like these particular stories or they are the only things that influence them but I think that they're kind of secondary to these things syntax is one we talked about like of course anyone who's useless is familiar with people's initial reactions job market right people are always this is kind of catch-22 with like oh I don't want to learn that because if I invest in it no one will be able to hire me and then employers are like I don't want to use that because if I do I won't be able to hire anyone it's like well no just whatever this happens right it very much favors languages that are already popular and sort of like reinforces their popularity and then finally community this can be either an asset or it can be something that makes people go away Ruby I would say this is a big asset to them was that the Ruby community has a reputation for being really welcoming and friendly I think among functional programming communities that's kind of a mixed bag some of them are notable for being really welcoming all these are notable for being kind of arrogant and and stuffy so it really kind of depends on where you go but again like I said I think these are pretty secondary to to the main ones that we just talked about so this let me do another question like okay so I can see that there's a variety of explanations for how these languages got popular but how come they're all oh oh like that doesn't really seem to relate to killer apps and things like that like how come all these except for C in the top ten are all object oriented languages is is there more to this stories there's something about object orientation that that causes or is partially responsible for this popularity because it seems like if that's just a coincidence that's a pretty big coincidence so I looked into this some more this leads me to part two paradigm so wikipedia defines paradigm as a way to classify programming languages based on their features so because features can overlap like you can have like multiple sets of features you can have overlapping paradigms as well so some languages are for example imperative and object-oriented and procedural at the same time or they can be hybrid object-oriented and functional you know this is a thing they overlap so I was trying to sort of narrow it down to the stuff that's uniquely oo like the the non Kross paradigms stuff and say like okay is is it the case that almost all these languages are oo because of some uniquely oo features that are really not found in other paradigms so this of course leaded the question of like what are the uniquely oo features I mean I can think of phew that get talked about is sort of canonical oo features like capsulation maybe inheritance objects methods so I kind of started to investigate these so inheritance this breaks down into two categories one is what people call interface inheritance this is basely just another term for subtyping of course subtyping is found in all sorts of languages so that's definitely not uniquely ooo the other one is implementation inheritance which most people just call inheritance but I have encounter people who wanted to be more specific so for the rest of this talk when I ever I say inheritance I mean implementation inheritance interesting thing about implementation adherence though so I'm actually considered to be a best practice really so there's this phrase composition over inheritance like favor composition over inheritance I think the earliest time this was used was in the the Gang of Four design patterns books this really influential object-oriented programming design book but now this has just become something that gets repeated by every object right that thought leader I pretty much ever heard of this is just kind of the way you're supposed to do stuff it's like yeah inheritance is the thing it's found pretty much every object-oriented language but you know what it's kind of disfavored in favor of composition I think that's pretty interesting so that leads me to the conclusion that like if inheritance is one of the uniquely Oh of language features which I think it is it's pretty hard to say that this like thing that is recommended not to use as a best practice is somehow explains like the popularity of all these languages so I don't think it's inheritance and I especially don't think this when you think about like what are some modern languages that sort of self-identify as being able to support oh paradigms like what do they think of inheritance so goes a good example of this because this is a language where they don't really nest to have backwards compatibility with any of the other object-oriented languages like Kotlin of course needs to have inheritance because they want to have really good Java Interop go doesn't care I mean go is basically trying to be another better see based on you know using the the learnings of the intervening time period really some of them and and basically go is like you know what we support an object-oriented style this is from their FAQ but they don't have inheritance they just just decided like it wasn't worth it didn't want to do it it's especially interesting when I look at this in terms of what does that imply for what methods and objects which are kind of two of the other things that I said might be some of the uniquely io features and it turns out that once you take inheritance out of the picture methods and objects are kind of just the same thing as like procedures and with some syntax sugar so I think this is kind of true and go like quote unquote objects and methods are really just syntax sugar so like if you look at these two function calls like one is or procedure calls circle dot grow parentheses three and grow parentheses circle comma three in both cases the logic that you're running is this grow logic and in both cases grow has access to the circle and the the number so whether or not you write it in method style or whether you write it in sort of procedure call style is really just a matter of syntax semantically the only reason these could possibly be different is if you have inheritance in the mix so to me this kind of reduces down to okay I've ruled out objects and methods as being uniquely Oh oh really it's either implementation inheritance and or maybe encapsulation so what about encapsulation if goes supports an object-oriented style how do they do that if they don't have a first class concept of objects how do they do encapsulation so this gets into a sort of broader concept that called modular programming this is one of the things you'll find listed on Wikipedia as one of the programming paradigms modular programming it's like imperative programming modular programming etc so modularity is essentially where you get to define a public interface and hide private implementation details this is about information hiding and this comes from a language called modular which sort of pioneer this in 1975 now languages with modules are all of them basically like every modern language except for c and c++ which are like too old-school to have had it back in the day all the modules actually are apparently coming in c++ 20 so this is a temporary state of affairs but it seems to me that pretty much every language has agreed you know what's good modules we should have a module system i'm except for the languages that are too old for it and go is no exception go has a module system now what's interesting here is how modularity and encapsulation relate so again this is a definition of modularity public interface private implementation details and here is the definition of encapsulation public interface private implementation details but specifically about an object so encapsulation is kind of like a weaker form of modular it's like a subset of it it's like modularity but only apply it to objects and this was a feature that you could find in another early language with a similar kind of name called Simula this is a language for performing simulations and Simula did not have a module system but they did have encapsulation so you didn't get the full-blown like module system that every modern language seems to agree is what you want but they did have a more limited form namely encapsulation so you got some of the benefits but they were kind of limited to to just objects so stimulus uh inherits from the home interesting choice of words similar is a descendant of the alcohol programming languages like really influential language in the 60s and it had some of these language features objects classes inheritance those were brand new as was stimuli Simula introduced to the world objects classes and inheritance garbage collection it did not introduce because John McCarthy did that with Lisp back in the day this was like the original garbage collected language but Simula you know just continue to use that and stimula was very influential in another famous object-oriented language small talk um so this is like sort of the maybe the most famous like of the original object-oriented languages considered by some to be the only true like object-oriented language so the small talk was designed by Alan Kay who drew on Simula among other sources of inspiration and he coined the term object oriented so objects existed before small talk but object oriented was an Alan Kay original he came up with this term and he applied it to small talk and you can kind of see why because the small talk everything is an object like you have objects right those are objects and then the way that objects call methods is by passing messages to other objects the messages are also objects and then also all of those have classes and classes are also objects so really like seriously every primitive in small talk is an object so I mean yeah I would use the term object oriented to describe that maybe even object obsessed and and really like you know so this is a pretty natural term and it got picked up by a lot of people and they were like oh cool object-oriented systems have like objects and classes and inheritance and then like three decades later in 2003 Alan Kay was like just kidding actually like object-oriented I never really should have called it that because really it's about these other things I really think Hopi is actually about messaging local retention and protection of hiding of state process extremely binding of all things and only small talk and Lisp or object oriented and the rest of the role is like excuse me like we've got C++ and Java and like all these other language that these seem object-oriented us and you're saying like no and he's like this I coined the term this is what it means here's the thing though like language like spoken language evolves over time I mean Alan Kay maybe this is what he actually in his heart truly meant back in the 80s but it's like that ship has sailed like we just with the words means a different thing now than what he wanted it to me and originally I think it's just too late like object-oriented programming is is just like what we consider to it to me in these days which is not this so if you want to learn more about objects in Alan Kay and the history of the term objects and object oriented I'm Hillel Wayne wrote this blog post it really goes into the history and a lot more depth and if you want to check out that link a little bit later I'm you can now I bring up small talk because this is a this is the language that influenced Objective C which is one of our top 10 so objective-c was created by Brad Cox he did an interview which is that that link right above there if you want to see the full interview where he kind of explained like the story of how he ended up creating Objective C and the story goes like this he was working at a company called ITT they were working on the UNIX systems and they were programming them in C this is where the C influence in Objective C comes from and Brad's job was he was on a Productivity team he was supposed to help everybody else in the organization get more productive and what he says in the interview is he's like I wasn't happy with C as a Productivity foundation I was kind of looking around for anything that could help and it was about the time that the byte magazine issue came out now if you look at that small talk logo I've omitted something here which is that this was actually the cover of byte magazine and we were talking about byte magazine for visicalc so byte magazine was essentially like getting on the cover of byte magazine was like being on the front page of hacker news in the 80s right this is like before the web you know there was no hacker news there was no any web but like you know this is this is a big deal so Brad's like leafing through this things like huh this is this is interesting this this seems like it's related to the problem I have a whole bunch of things in there that small talk was offering that I thought might help encapsulation for sure encapsulation being are like subsets of modularity C is so bad at it everything is public it just turns to soup the pain of that is what I was trying to escape this really interesting like Brad Cox was it was basically saying I want modularity I want a module system and you know with the benefit of hindsight we can say Brad go look at modular you'll get the real thing that everybody's gonna conclude is what you actually want later but he didn't have access to that he had bite magazine and small talk was the one that happened to be on the cover of a magazine so he was like cool here's the thing that solves my problem this is what I'm gonna use and so he ends up making objective-c from that and it's pretty interesting to think of like you know this is what happened you know in the 80s based on his being only aware of small talking though there was no web but like byte magazine has done other covers right like here's one for Lisp I mean who knows what could have been right what if it had just been like modulo on the cover of small-time magazine instead of objective-c it's just modular C right and then now one of the top ten languages is maybe a dialect of standard ml instead of instead of being a dialect of a small talk and hydrat of small talk and see because really that was the one thing that he wanted and this was the way that he knew to get it and much later after the fact we looked back and we don't think like Oh objective-c that was based on a need for modularity which everybody now knows his best solved by modules we look back and say nope that's an object-oriented language object orientation must be great not really the story when you dig dig into what what he was actually saying about what his goals were there's another language that's descended from Simula this time not by way of small talk I put up a little curtain so I can have a big reveal as to what the language is so this is Buuren a strauss trip anyone know who this gentleman is okay yes so III have a spoiler right here on the slide he's the creator of C++ but he's also the creator of another programming language which he created before C++ anyone know what that was called C with classes this language had a very specific goal it was to have C but with classes and actually it's not it's not quite true it was C with classes but also like a stronger type system he wanted like to make the type checker a little bit stronger so he gave this interview where he kind of explains it is like his thought process is while he was doing and he was like why did I want to add classes to C well Strasbourg had actually used Simula personally in a previous job when he was working at this company where he's like I want to UC and I want to use like something nicer than then see for like modeling my domain I just like want to be able to get more organized and he was like yeah you know what I thought classes were pretty good when I was using them in the simulated A's I really liked that um and so I'm just gonna try and bring that in so he does he makes scene with classes and then he runs into a problem which is that see with classes is what he calls a medium success and the problem with being a medium success as he explains is that it's like okay so this works I got a few people using it couple of users it's pretty nice they're happy with it the problem is that I'm the only maintainer and there's too few of us to spread the maintenance burden around and so I'm kind of in a pickle like on the one hand I could just say well I don't want to maintain this for the rest of my life I'm just gonna walk away and abandon it but then all the people who are using it are my friends so I don't want to do that names like so what do I do he's like well the only other option seems to be maybe I'll just like add more features so it'll be more useful to more people and then may be able to get popular enough that I can find some other maintainer 'he's so he does that he adds the additional non object-oriented features and renames the language to C++ and it became slightly more popular and and it still maintained this whole like drop-in C replacement thing right that that upgrade path that's really smooth but this is really interesting because again we have actually a pretty direct experiment of like does object orientation cause success and he was like well I added object orientation and a stronger type checker as a bonus that was not enough to cause success then I added a bunch more features and success so we have a very direct experiments like whether or not object orientation caused the success of C++ it's like no because when it just had object orientation it was called C with classes which nobody in this room had heard of so clearly not not not a causal relationship there between the OO stuff and the success of C++ you wanna see this whole interview again here's the link to this really interesting stuff this is from the 80s when Strauss Tripp was interviewed about C++ okay so to kind of sum up this like family of languages we have like a lot of people are going to write C code for UNIX like great systems programming language they find you know what the the ergonomics are not great or maybe like I just need some modularity in the case of C++ adding over features to it did make his life better he was happier with it but it wasn't enough to make it be like the rocket ship that jumped into the top 10 like it altum Utley did until he added additional non oo features and then we look at Java and we know ok Java really wanted to appeal to C++ programmers so why is Java so object oriented in such a way that seems very familiar to C++ program like well can we really say that like Java's object-orientation was like in there as like a first-class really great thing or was it just it like this was familiar to a large group of users and that was why it was object oriented and that was what caused its success because we've seen that familiarity and like this smooth upgrade path is like a really big deal and then of course the same thing can be said of c-sharp like c-sharp was intentionally designed to be exactly the same feature set or very close to it of java so that it could be presented as a really viable direct alternative to java so if you trace this lineage back all of it comes down to like potentially the reason that all of these languages are object-oriented in this whole lineage right here is just that yarnís rostra created c with classes and then it wasn't popular enough so we added other features but then the other features don't get the credit it's the OO that that one sort of medium success failed experiment is what gets all the credit in retrospect similar thing with with Objective C like Brad Cox just wanted modularity he says this multiple times the interview but ultimately what he ended up settling on for modularity happened to be small talk because that was what he knew about at the time and then of course Swift needs to have backwards compatibility with Objective C and so it's also an object-oriented language so really like digging through this like at least with this group of languages I'm not seeing it I'm not seeing that object orientation caused their success I'm actually seeing the opposite that it actually was legit a coincidence in all of these cases so what about Python Python is not any of these groups it's not like a direct descendant of C except in a you know very kind of weird argument type of way did object orientation cause Python success so I don't have as like direct an interview like to point to here but I do have a quote from the creator of Ruby which is Matz and he said you know when I made Ruby I wanted a scripting language that was more powerful than Perl and more object-oriented than Python so Matz his view is that Python was like not particularly object oriented he's like I really wanted something that was a lot more object to write that I liked he was pretty into like these small talk ideas I think that's really reflected in the language of Ruby so you would think that if object orientation is like really essential for success that the fact that math successfully made Ruby more object-oriented the Python and in fact Ruby did enjoy a you know a period of time where it was more popular than Python that that would have led to some sort of long-term success but of course we already know from previous turrets that that's not what happened Ruby did briefly surpassed pythons popularity but it was basically because of the rails bump and then once that died off you know Ruby's a killer app language Python is the language that's like people like it because it's fundamental design is pretty good so our old languages the norm because of uniquely oo features I think the answer is just know it there oh because modularity is a good idea and they happen to originally get it by from oh by chance all right which brings us to the final part style so functional programming style I'm going to just claim without any evidence is avoid mutation and side effects I'm claiming this because I've talked to a bunch of people about it and this seems to kind of be the consensus but at the end of the day like nobody's really entirely sure there's no like authoritative source that we can go to to say what the F P style is so I'm gonna claim it's this and hopefully you'll go along with me obviously like no language features are required to program this style like you can almost do this in assembly not saying it would be pleasant but theoretically you can just choose not to mutate in choose not to have side-effects and most languages certainly any procedural ones having said that obviously like languages differ in their support for this style some languages are very conducive to programming the style others make it pretty difficult like assembly so why isn't FP style the norm well one argument is just that it's just a matter of time like it just hasn't had enough time in the spotlight and just like over time it's going to become more and more normal until eventually it becomes kind of the norm actually this is a pretty compelling argument so if you look at the Kotlin faq it says is Colin an object-oriented language or a functional one and the answer is hey hey hey we got both we got oh oh and we got functional like you can use both this is not what you would see in a 1990s Java dialect FAQ that was just not a thing back then but like these days the functional style that's considered a selling point that's like oh no like people agree that the functional style is good now like don't worry we support that we have good support for that in a language remember we're its main thing is like hey this is a super smooth Java upgrade process they're bragging about their their ability to support the functional style look it's Swift they say some additional features of Swift include functional programming patterns like map and filter again this is a language which doesn't need any help to attract functional programmers they're just gonna be like everybody's gonna use it cuz if you want to build for Apple you kind of have to but Swift is also saying like hey we're a modern language in a modern language you got to have good support for the functional style again not saying this means FP is about to take over the world but it does it is important to note that this is not something you would see in the 1990s something has changed and if you don't believe me about those two languages take a look at these collection of books functional JavaScript functional JavaScript functional programming Java your beginning functions JavaScript functional like JavaScript I mean just lots and lots of stuff about how to do functional programming in languages that are not functional languages but which do have some support for it Java even like Java functional programming and Java like this is this is a real thing Python sure like that's the top three languages right there all this huge selections with C++ there are multiple C++ functional programming in C++ books I mean this is a change this is none of these things would have would have flown in the 90s no publisher is gonna be like oh yeah like functional programming in C++ let me sign you up I'll give you a nice advance on that one like no this is this is a sign that people are coming around to the idea that you know what actually like the functional programming style like I don't think people are at languages yet certainly but but the style is gaining traction and I think this is interesting because if we are somewhere in the middle of like a transition from op2 style to Fe style like maybe this hybrid thing is an intermediate stage on the road to FP becoming the norm that's a plausible thing now how much time are we talking about I don't really know I mean this whole talk we've been talking in timescales of like decades so it might be that maybe we're in the middle but actually the middle is like maybe we have another decade or two I don't really know I mean I can't say with with any certainty what I can say though is that something has changed like this style is not something that people were considering a positive thing in the 90s and the idea that is a positive that I think has become sort of mainstream now and I think the you know this this can translate to populated functional programming languages like imagine somebody who's already concluded hey you know FP style is good I'm just like choosing to write functional programming JavaScript functional programming Java that's just how I write my code at some point you look at you look at Ronnie like hey wouldn't it be nice if like the language I were using actually had strong support for the style instead of just kind of being an afterthought at best wouldn't that be nice and then at that point you know maybe people start saying on my next project I'm gonna try and embrace a language that is really good at this and not just like OK at it kind of as a side effect no pun intended and at that point like who knows maybe that that changes these rankings maybe that influences people's decision of what programming languages they're using okay so to sum up why isn't functional programming the norm well it's complicated but I think we've we've learned a lot about like some of the factors that go into this we talked about language paradigm and style why aren't FP languages the norm well no one there aren't any sufficiently large killer apps for FP languages but I gave three examples of things that could plausibly take off killer app can come out of nowhere can come out come from anywhere no exclusivity on large platforms but hey maybe if there's some platform that has FP languages as the exclusive way to write for them and that platform gets big who knows that that could happen too can't really be a quick upgrade if you're substantially different I mean if the whole point is the language is like really significantly different you also can't say don't worry it's a drop-in replacement it's it's just JavaScript if it's like well no the point is it's not JavaScript I don't think we can ever have that no epic marketing budgets and to be honest I don't know Fran we're gonna see an epic marketing budget on the scale of Java but we could dream and finally you know maybe FP languages are in a slow and steady Python s growth state but those just take decades to resolve so it might just be a long time before we actually see them you know the reach that level of popularity are they the norm because of uniquely oo features I don't think so I mean information hiding aka encapsulation and oo languages it's not a uniquely oh a feature modules can do it too and modules seem to be the consensus best way to do it inheritance does seem to be uniquely oo but again best practice in all languages is to encourage composition over inheritance and without inheritance like objects and methods are basically not only different from structs and procedures so I think the answer this is no it's not that oo causes languages to become popular it's just a coincidence they're just a lot it's just along for the ride and finally like why isn't FP style the norm well I think it's just a matter of time it's becoming the norm I think that's something we can all appreciate and look forward to in the future thanks very much [Applause] [Music] yeah questions yeah sure yeah so um how do you sue how do you see a lease fitting in July's picture is it that functional or unfuck functional programming language in your mind oh man so you're opening a real can of worms here so so the question was how do you see list fitting in here is it a functional or not a functional programming language so I actually this talk is trimmed down to 40 minutes from like two and a half hours because I just I had so much material in this one of the questions that I started going around asking people is like and just just think about this because it can kind of fry your brain after a while it's like how do you look at a programming language and decide this is a functional programming language or not how do you do it and I would just go to people and ask this question and they would say oh well it's this and I would give them a counter example like okay well no it's not that it's this so I'll just I'll rattle off a couple so one it's like okay so it's a functional programming language if it has support for like first-class functions like okay so Java is a functional programming language no no not Java but like they have to be pure okay so Oh camel is not a functional programming like closure is not a functional programming no no this those count but okay you need it like immutability like that's that's important okay but like so so rust is the functional programming there's this it's immutable by default even no no not like that but you know you just you just go around in circles one person suggested a score like if you have a certain number of things checked off then like you cross a threshold your functional but ultimately I ended up concluding that to be perfectly honest like classifying languages as functional or not is kind of arbitrary definitely very fuzzy and ultimately not as important as talking about like the style and their support for the style of like being able to avoid mutation and side-effects and like still have a really good experience so to directly answer your question like what I say Lisp is like a good functional programming language I would say it really depends on the list like if there's a list where like every part of the standard library requires you to mutate things and do side-effects maybe not closure definitely is so I think it really just depends on the language yeah I awesome taka thanks very much thank you performance for wits yeah it's one of these things where fighting is a bit slower C++ is meant to be fast so people often talk about this with with FP because reasons you can pop your intern I was just wondering what you thought about performance as a kind of like aspect of this discussion that's a great question yeah so the question was um you know what how does performance factor into this so I think performance is one of those secondary concerns that that doesn't necessarily cause a language to be popular or not I think it more impacts the the areas in which it can be used so for example like some applications like you just need the level of control over memory that C and C++ give you and like if you look at rust like rust is one of the very first like new competitors in that space that's like viable to like challenge the crown of C and C++ in a long time because of that so I think if you need that level of like control over performance you're probably not gonna go for a functional language so you're probably not gonna go for any garbage-collected language you know you just you just need to be able to directly manage memory but as we've seen there's a ton of domains where that's not true in fact like pretty much all the other ones which is why all the other languages now top ten except for C and C++ are garbage collected so I think as far as performance goes it really depends on what your performance needs are um if you're writing like a back-end server language in a lot of cases you don't like it you know Python is a perfectly acceptable one like it's not as fast as go but a lot of people are just like yeah but it's fine like it's good enough like it's gonna be dominated by the network in the database anyway so who cares I think that so it's really domain-specific and so overall to answer the question I would say performance I think is a consideration but it's pretty secondary to the other factors that I talked about earlier also I don't think it's true that like functionals last performance but that's like a myth that's it's just not like if you have mutation and like you can do it all over the place then like certain algorithms are available to you that are not otherwise available but if you're not using those algorithms anyway it doesn't matter so anyway and also there's certain performance optimizations you can only get if you have like certain functional guarantees so yeah after you go on for a while thank you reteach thank you [Applause] [Music]
Info
Channel: Metosin
Views: 1,291,110
Rating: undefined out of 5
Keywords: clojure, Elm, functional programming
Id: QyJZzq0v7Z4
Channel Id: undefined
Length: 46min 9sec (2769 seconds)
Published: Mon Sep 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.