Uncle Bob LOVES Functional Programming | Prime Reacts

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
why closure really now this is the weirdest part is this is Uncle Bob okay Uncle Bob we're talking the clean code guy the guy that wants to abstract on top of abstractions and put everything in its own little maybe this is not so crazy after all he wants to put everything in a function and all of a sudden now he wants to do it I just know that one fact about Uncle Bob is that he does not like functional programming languages at least in general he's openly stated I think he just like disdains lisp for 40 years uh something along that lines like so so you know he's been around the block for a long time and he does not like it I have programmed systems in many different languages from assembler to Java I've written programs in binary machine language Get Wrecked I've written applications in Fortran Cobalt PL onec Pascal C plus plus Java Lewis Small Talk logo and a dozen other languages I've used statically typed languages with lots of type inference I've used typeless languages I've used dynamically typed languages I've used stack-based languages like fourth and logic based languages like prologue okay if you program in prologue the only thing you literally can solve in prologue is Bill sits in room a Bill's adjacent to Susie Susie does not like to sit next to Shirley Shirley sits across the hall from George George is a close relative to Bob which room is George in and you're just like uh foreign over the five decades I've used a lot of different languages I've come to the conclusion my favorite language of all the language that I will Outlast all the others the language that I believe will eventually become the standard language that all programmers use is lisp major list W okay so I'm not gonna lie to you uh me and Uncle Bob we've had some we've had some disagreements in the past which means that when I see this I just automatically assume this is a lisp L okay this is a lisp plus L plus ratio uh you know what I mean I'm just saying I don't know what to go with this I don't know how to I don't know what to do with this I'm just saying this is very very confused I have not come to this conclusion casually nor even willingly I was not a fan of lisp for 40 years I was not a fan of lisp no I saw the cars and the cdrs and the CDs ca-dd-a-ddrs do you like how I do can you believe how I literally cannot read twitch chat and I just read that letter for letter perfectly I think I might be a savant I might actually be able to read things and thought it was all just academic baloney interesting but not truly useful uh and then a decade ago I found a sick pee and after that I found closed jerk clojure is a lisp that rides on top of the Java ecosystem that is not a way to sell it if there's ever been if there's ever been a phrase uh if there's ever been a way to not sell me on an item this is it right here and it does not have cars and cdrs or cadada Dr I wasn't convinced right away it took a few years but after the usual stumbling around and frustration I began to realize that this language was the easiest most elegant least imposing language I've ever used and not by a small margin so why clojure I've made a list are you ready for it here it is dude I am actually extremely excited about this I cannot believe someone's unironically recommending closure that's not from twitch chat now twitch chat you guys recommend everything right here watch this Nim gang can I get a Nim gang in here can we get some Nim gangs in here Nim gang Nim gang anyone nim nim nim nim nim nim nim nim nim nim nim game uh no no refuse Ivan rust uh nope nope nope nope no name get this you know what's crazy is this in Nim are you ready for something that's gonna blow your mind in Nim are you ready for this Foo bar is a variable right you can make the variable Foo bar did you know that Foo bar is the same variable as Foo bar let that sink in for a moment let it sink in that you could literally name it Foo underscore bar and Foo campbellcase bar is the same thing you should take that and you should just die a little bit off the inside snake case is garbage oh that's the solution snake case is garbage therefore we're gonna do this crazy ass thing based language that just hurts Fubar equals Foose a Bard what the first hail I don't know nobody knows so why closure I've made a list are you ready for it here it is I am ready this is the strangest transition ever so why closure I've made a list are you ready for it here it is okay geez that's like running we just went from uh you literally just started on home plate instead of hitting the ball you just went you just stayed on home plate uh one economy of expression if you're if you are wondering where the rest of the list is there isn't any more I I'm not wondering where the rest list is because I'm at one and I can't see below the fold so I assume there's more thank you for spoiling it I would have put that at the end maybe that's the reason there's only one it is just simpler and easier and less occluding to write expressive code enclosure it requires fewer lines it requires fewer characters it requires fewer hours it requires fewer mental gymnastics okay I am genuinely now interested in closure okay first when you said this whole Java thing wherever you put that Java thing it's like lisp but on Java like that did not sell it to me but this okay you're selling it to me well why should this be so the answer is very simple indeed the answer is very simple the language has almost no syntax or grammar what uh let me say that again the language has almost no syntax or grammar probably the best way to uh elucidate this point is to show you an example so Here For Your Entertainment is the program that prints the first 25 squares of an integer print line take 25 map pound me Daddy um range you're right very few symbols extremely few symbols um pretty much no symbols no symbols in that one obviously the pound me Daddy this is obviously obviously this is an anonymous function um star is the operator you're going to apply to it and the percent sign is implicitly the first argument passed into the map function every everybody knows that duh mental gymnastics okay none none appear here none you know why because it's simple let's walk through this means beginner list means end the innermost List names are just names and in all case they're all functions a star is the name of the multiply function bam goes the dynamite pound me means interpret the next uh list as a function pound me data or Daddy got it look at that percent side means the first argument of that function let's go I am a genius I knew it I am a genius I am Tom uh dude okay we got it we got that one uh you've just seen 80 or so of the syntax of cloture but before I show you any more let's just walk through the code above first of all there is an opening this that means everything that follows uh until the final is a list uh in most contexts closure interpreps lists as a function calls in this case the function is print line uh that's just a regular old system.out.println classic because when I think of a regular old print Ln I think of that one right there system.out.println that's the one I think of right there this guy right here Java uh we're used to it in Java sort of uh what are we passing into println well we're passing in the result uh of the take function the take function expects two arguments the first 25 is the number of items to take the second argument is a list in this case uh the take function will return a list with the first 25 items of the list in the second argument what is the list in the second argument it's the result of calling the map function the map a function expects two arguments uh the first is a function and the second is a list the map function will return the list that is the result of the call uh calling the past and function on every element that is passed in list okay what function is passed into the map it it's the anonymous function created by the pound me Daddy which implies uh which simply calls a multiply on its duplicated duplicated first argument percent sign me and Bob we were tight we literally are identical and we could just figure it out now range range must be a function that every time you call every time you pull a value it simply increments it right uh what is let's see what is the list in the second argument it's the result of calling the map function the map function X oh we already did that uh what is the what list is passed into map it is the list returned by calling the range function the range function simply returns a list of all non-negative integers that is a uh that list is lazy so only the integer is required by the Upstream function will actually be generated some folks don't like the complication of the percent syntax so we can recreate the square function as follows uh Define Square x x me print Ln take 25 map Square range boom so many percent uh parentheses so many of them uh the the def end function uh defines a new function named Square the brackets work just like parenthesis except for they Define the different kind of list called a vector lists have a runtime complexity of a linked list vectors have a runtime complexity of arrays sort of porque Maria uh anyways in this case the vector tells death and that the square function requires one argument named X the rest you should be able to infer yep okay uh this makes the second uh line a little nicer the map functions simply invokes Square now you've seen about 90 of the syntax of closure now let's compare the equivalent to a Java program uh public class square of integers public static void main string args four and where's my parentheses squirrely brace system dot out I times I where's my spaces where's my ending squirrely brace what kind of language is this who would write this um this is my least favorite aspect of go did you know that go enforces this I think that that kind of syntax is the literal devil and I think that whoever wrote this idea that you should squash everything together should get a firm slapping around okay my version of development experience is that these things are separated by white space my DX not your DX mighty X also if you don't put squirrely braces because it's one line you're actually the devil okay you are the devil in your own code base this is the this is honestly the worst programming practice ever created and the fact that it still is being propelled forward in some languages is actually awful I hate this I hate this because every time I want to put a little print statement in there I'm like I'm gonna put a little print statement right you just jump in here and you're just like ah I think the bug's right here I'm a good programmer I'm gonna jump in here and I'm gonna go like this I'm gonna go oh gosh I can't even handle this as system.out.printel and uh some uh something about debugging and I'm like nobody's actually going to be a jackass acid forget squirrely braces run the program and everything breaks or it breaks on compile and I'm just like Maria why did that happen and then I see this and then I go like this get blame and I look at it and when I look at it I go this person's the devil then I go on slack and I take a picture of the code then I put squirrely braces in the code I make a meme about them being the dunny Krueger with the guy crying in the IQ bell curve and say this is you stop being an this is considerably more wordy even if you don't count the enclosing classes more to point however is that it covers a covers perhaps five percent of the syntax of java and don't get me started in the comparison with C plus plus uh now I don't want the belabor the point I could go on with comparison after comparison with language after language the bottom line is that clojure has a much smaller syntax than most languages the minimal syntax means that I can express problems clearly and directly with much less effort uh and contortion than most other languages look I was not an easy sell I was am a C plus plus programmer more than that I was and am no longer AC plus a language lawyer foreign sorry twitch loves the AIDS I won't be able to keep keep going a C plus plus language lawyer Uncle Bob is getting senile time for him to find a Home by the way C plus plus 20 uh ranges are blah blah blah definitely a lazy evaluation so good C plus plus apologist curly braces equal good uh parenthesis equal bad I do agree with that I've reveled in the heavyweight syntax of the language I was enthralled by all of its lovely Fidelity bits I found the transition to Java 20 years ago to be rather meh it was just a slimmed down C plus plus and it's gotten a bit more uh corpulent sense I'm not sure what the word corpulent means but I'm gonna assume it's negative by my transition to clojure was an eye-opener based on the lightweight syntax I expected it to be suitable for a few classroom exercises but not for building large systems in my mind large systems equated to large syntax boy was I wrong this is actually a shot okay completely real I don't care how bad or how good a developer is if you've been doing something for 40 years and you use something completely different okay I just want to just take a moment here you use something completely different you go into it and you try to learn it the best you can and you come out with a changed idea there is just so much respect on that for me uh it's just a it's just such a huge respect and the thing is is that you got to think about this imagine being in a c based language land for 40 years and then finally trying to make the transition to a lisp based one there's a lot of respect there and not only that but you just gotta think maybe you know I always come back to this maybe my idea about DX what I think is actually good is not actually good it's why I'm willing to explore things like oh camel maybe I should try closure just for fun just to see what it is just to build a couple small Tools in it this is why I explore other things is because what I think is good is really what I think is familiar and all of us fall into this trap it's the inevitable program trap which is good equates to familiar and bad equates to unfamiliar bad is d a bad DX bad DX is because I don't know it and therefore it's bad because when I try it I don't understand it it's clearly complicated no it's not complicated you're just ignorant and that's okay I'm ignorant too we're all ignorant of things we don't understand that's literally the definition and that means you just have to take the time to understand it but I feel like in the modern day era if it's not typescript if it's not rust if it's not go then it's just clearly bad and maybe just maybe we're all being a bit ignorant there uh what I found instead was that the minimal syntax of closure is far more conducive to building large systems than the heavier syntax of java and C plus plus in fact it's no contest building large systems enclosure is just simpler and easier than any other language I've used and as I've pointed out in the beginning I've used a lot of languages uh but what about so you've probably got some complaints questions objections Etc let me see if I can anticipate them oh my gosh all those parentheses how how old are you look here's a function uh call f of x now here's a corresponding function call in Java enclosure f of x do you see any extra parentheses there get wrecked by Uncle Bob okay that's not entirely Fair what do you wind up with a few more parentheses uh but that's just because we intend to Nest function calls look at the squares of integers program above and you'll see why don't fret though if you really don't like the nested syntax you can always use the threading macros uh let the reader understand I didn't understand I assume there's just some way to pipe instead like an O camel you can just pipe and it just makes it nicer right uh but isn't it slow no cloture is not slow oh look it's not C it's not assembler if nanoseconds are your concern then probably don't want to use closure in your innermost Loops you are probably you probably also don't want to use Java or C sharp but 99 of the software we write nowadays has no need for nanosecond performance I've built a real-time GUI based animated space war game using closure uh I could keep the frame rates up in the high 20s even with hundreds of objects on the screen closure is not slow it's an odd measurement Uncle Bob I'm going to give you an uh you know Uncle Bob I'm going to toss in a l on that this entire statement uh slow is is is not a per is not based on human perception it's based on uh language comparison so is closure slow yeah it's slow but the purpose is good building just like JavaScript JavaScript slow python is slow we still use them I'm not saying it's bad to use them I'm just saying using the term slow and fast should be a relative measurement between what is really fast C and what is really slow say closure or JavaScript or python or any of those right it's simple uh what about JavaScript closure script compiles right down to JavaScript and runs in the browser just fine indeed the space war program I mentioned above was compiled using closure script and ran in the browser at even higher frame rates than in Native mode I'm still trying to figure that out JavaScript is faster is what that means but it's dynamically typed you don't write tests don't uh you you do write tests don't you and as a part of those tests you can employ the closure spec library to uh specify the schema of your types I hate I hate tests that specify types I think that that is a failure uh yeah and do Dynamic chopping checking with preconditions and post conditions designed by contract style to your heart Delight but it's dynamically typed declaring types requires syntax syntax reduces economy of expression incoming ooh but damn it it's dynamically typed I'm on this team okay I get it you like static typing fine use a nice statically typed language and I'll use closure and I'll be in Scotland before Yi okay okay okay okay okay okay okay okay okay okay what about Ides IntelliJ with uh cursive plug-in doesn't uh does very nicely I hate ending uh sentences with adverbs uh most closure programmers use emacs though of course they do this is literally true I in fact I just saw who was it that just quit oh uh Athena dude Fina the legendary vimt uh Vim conference speaker thina has gotten into lisp and uh he switched to emacs for the sole's sake of being able to write lisp uh what about refactoring IntelliJ with cursive has some nice refactorings although they don't have extract method yet come on guys uh what about iava interrupt no brainer closure programs can call Java directly Java programs can call closure programs with only a little bit of uh fuss Interruption not be your concern come on man Java it was designed for the web it's web scale of course it can interact uh where do I find closure programmers they're out there uh dozens of them just dozens of them waiting but you are better off making them uh the syntax is Trivial the Java platform you likely already know uh the Java platform you likely already know okay that sentence is fusing just decide to build your next system enclosure and spend a week or two getting used to the language then start oh by the time you're a couple months in you'll realize how primitive your early stuff was and you'll be tempted to clean it up but what else is new yeah that's reasonable what about a new language over there what's it called um Gazoo yes there's new languages every month every week every day and we have no lack of new languages the thing about those new languages is that there's nothing new in any of them they're just made up of uh made up of the pieces of old languages that they cut up and shook in a jar and then dumped out in a game of Yahtzee this is actually an incredible point which is kind of like there's this thing that we do as humans where we actually try to we try to fix problems right and the thing is is there's nothing new Under the Sun everything that has existed still just keeps on existing we're just simply we're just simply trying to like re-fix the problem right for whatever reason the ground is cursed when you program it's just simply cursed everything you do falls apart somehow you don't touch code and it gets worse nobody knows why it just does it literally just gets worse we don't know why just entropy exists in the static language assets and nobody understands why and it's true all these languages that are coming out rust is just simply oh camel smashed with C like it's not like it's some magical new thing that has never existed before it's just a reshaking of no wait a second if we optimize here then it will finally solve the fact that programming sucks it's like no programming will forever suck that's all there is to it it's just always going to suck why are you trying to make it not suck just accept the suck and determine which version of suck you would like to suck on okay that's not entirely Fair there's still some good ideas percolating in the language space but none of those ideas are revolutionary we've encour we've entered the era of tweaking I don't find any of the new languages nearly as compelling as closure simply because of the extra syntax virtually all of them carry other languages have minimal syntax why not one of them yes that's true fourth had a tiny syntax so did small talk but those two languages had baggage of their own fourth was rever uh was a reverse polish stack Language Academy of expression is not uh the phrase I would use for fourth though I find it fascinating that PostScript was based on it a small talk was a small and elegant beautiful it spawned the design patterns Revolution it's on the refactoring revolution it spawned the tdd revolution it helped to spawn the agile Revolution Small Talk was the language's tremendous impact take it Twitter it tweet it paste it quote it Uncle Bob now we know who to blame and tweet it back to the article Small Talk was also image based uh language very few programmers have ever wrapped their minds around what that really meant so unfortunately the language that languished compared to the text file based languages I don't even know what that means what do you mean images what do you mean we're looking at images I don't want to look at a JPEG okay what is this nft programming I don't want to be a part of that lisp is older by far than small talk or fourth it was created in 1957 from the concepts that came out in the 30s and it has never languished in this uh way small talk or fourth half indeed it's the language that refuses to die we've tried to kill it many times but like the annoying neighborhood stray cat it keeps coming back not if you use a gun uh finally lisp is functional the future is looking very functional to me you know I love this article I I must say that Bob Uncle Bob if you hear this this was a great article there's lots of things to take from this that I absolutely love hey maybe I'm even becoming a fan not of your takes but of the things you write I think this was really great Insight the name is the primagen the reason why I went so fast there is I'm literally gonna pee my pants okay gotta pee ah
Info
Channel: ThePrimeTime
Views: 114,131
Rating: undefined out of 5
Keywords: programming, computer, software, software engineer, software engineering, program, development, developing, developer, developers, web design, web developer, web development, programmer humor, humor, memes, software memes, engineer, engineering, Regex, regexs, regexes, netflix, vscode, vscode engineer, vscode plugins, Lenovo, customer service
Id: GcJgGy-dfvE
Channel Id: undefined
Length: 22min 59sec (1379 seconds)
Published: Sat Aug 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.