caption

George Hotz | Programming | advent of scala | Advent of Code | Scala | ChatGPT | Twitter | Part 1

substream all right hang on where we got the mobile streaming setup today so you know it's not as good like let me get my I had to find the cable to plug my phone in so I can have chat up my phone oh I came with my new airpods I got new airpods and they're they're fire bro um I don't know why it's red on here Red's gotta mean something fresh new lightning cable love the smell of crispy Cable in the morning let's go uh yeah we trust this computer now we don't trust shit all right I'm good um my channel hello hi everyone hey uh morning okay good we got Chad over here we got we got the mobile streaming set up today because we're in shitty San Francisco welcome to shitty San Francisco where everything's shitty and I'm scared to go outside uh no I'm really I'm in San Diego I miss Alex and I do have a nice cup of tea though so that's that's like a nice guy we're gonna we're gonna we're gonna sip t um and we're gonna do Advent of code but I'm gonna have any code this year I've been very busy you know you got to be a hardcore engineer if you want to make it at elon's Twitter uh so you know we've been a hardcore uh and I'm still terrible at Scala so you know you guys can all make fun of me hang on we got we gotta we gotta we gotta turn on we gotta disable auto lock for our luck never okay um what are my plans for today uh well my friend just got sideswiped so you know uh he's gonna deal with that it's annoying uh no plans man no plans I got a dinner tomorrow group house you know of course you know it's just like these people are running it all back these people are running back the same shitty culture that got Tech to where it is today man moved to San Diego chill make our Technologies are um is Scala only a framework for microservices no Scala is a full programming language based on the jvm okay so let's Scala all right so this is my input uh I copied the cookie into Chrome okay we have to figure out the elf carrying the most calories so let's go what should I call it what should I call it Go dot Scala okay Scala read file all right all right fine uh oh I can't log in oh oh that's annoying hang on I gotta hide the let me hide this no this while I log in to open Ai and we can use chat EBT to help us out all right that will that make everyone happy if we use chat GPT was it chat.openai.com log in with your openai account okay I this is a research preview okay I can bring that back all right we're good we go we go very good all right let's make this a little smaller all right all right um how do I read a file in Scala this looks pretty nice I do not care at all about the ball game Scala go.com print Ln lines should I do this in a wrap up illegal start of top level definition longer explanation available when compiling with explained do I need a main method that was useless um Scala illegal start of top inside another definition what what am I doing wrong guys the main method is an entry point into scholar wait I can just make anything main if I do at Main does that work all right we read some we read some stuff in Scala um they end up with the following list so there's going to be some empty ones that seems good yeah I'm sure we could copy it from chat gbt but uh also that's where I am so we have to move me hang on I'm going to be using over there so we'll put me down here now we'll put me up here I'm small no but that's a waste of okay right there maybe his best okay okay um get lines to list all right we have to we have to find the empty lines wow this is so bad I'm so bad at Scala boys string to in Scala uh we could do map X all right VAR nums no but this doesn't work because we have to separate it based on the elves oh this is hard this is hard uh there's a partition function in Scala no it only returns two that's not gonna work I'm going to split sequences into subsets ah Group by okay let's try that split at no I'm not in the Twitter bedrooms I have an apartment I'm not a Savage all right no that's not what I want I don't want to split at no never mind uh Group by I really just want the type no that's not what I want either split at groups two oh you see what I'm trying to do why is it so hard okay we could recursively partition a partition that returns a list of lists okay let's try lines dot partition we need a function that returns a Boolean actually I think I can just do this uh and we'll say about F God so wait oh is it so that actually does not work at all I think it's dot I think it's that to access a single one okay never mind partition did not do what I wanted um all right all right you get subscriber only chat that's right Lana Lux thank you for the raid good to see you well we'll let non-subscribers talk in honor of of of of Lana lux's raid um guys I'm really bad at Scala like Twitter should fire me you know who thinks Twitter should fire me okay Group by split at partition [Music] no this isn't what I want okay maybe we don't want to get lines maybe we first want to how do I split Scala split this split available on Scala and Java string objects so where's my chat GPT that told me how to read a file so maybe instead of make lines we'll do make string and then we'll do dot split that what is that going to return that's not going to return a list of oh it is going to return a list of strings okay we'll call it animals found array string required list what's the difference Scala that's as Chachi if you take Scott what's that difference between Scala array and Scholar list I think one's mutable and one's not eraser mutable okay good okay great we get an L Java Lang string great uh you gotta love oh man don't you love Java no okay uh I think it's l Sub Zero will get me the first elf okay cool okay and now we can do elves.map we're going to map by the way if you're calling something in Scala that only has one argument you don't need a parentheses thing so let's do split n dot map uh two inch I think that's right Okay now what's the type going to be uh the type is going to be array array it elves two I found two int okay Scala to int how do I convert a string to an integer oh it has to be an argument so I think I can say da okay good uh now of course I don't want to raise I want lists um can I say that that'll give me the first one okay good now we're in our place ready to solve this um they like to know how many calories is being carried by the elf carrying the most calories bro if I had to actually do this I'd be fucked right now do people solve this in like 30 seconds we'll call this elves stir and we'll call this elves because we it's important to use good names we'll call this elves strength because that's a very Java looking thing right I don't know I'm not a Java programmer okay um actually we want some so there's got to be a way to just sum them okay we've read in the stuff now we can say elves dot map um array sum Scala oh it's a list Method All right well let's hope it's uh let's map dot sum elf total Gray all right let's just go for this is there a Max method there's some chance that just works great just the right answer let's try it uh most calories how much calories that's the right answer I'm one gold star okay um might have run out of snacks by the top three okay the top three elves the sum of the calories of the top three okay so we can't use max anymore we need to sort Scala sort uh sorted now we need a slice um Scala list slice great from index until index so let's try slice zero two I don't know if that's inclusive because we actually need three is that going to give me three great it's gonna be bullshit all right cool let's check the length of that I'm like that's the right method I think it's length of course it's drama you have to spell everything out really long two okay so that's not right we actually want that and then we can do dot sum and that's the solution oh oh because we have to sort and reverse uh Scala sort reverse yeah I should have checked because that just didn't make any sense okay uh dot reverse so that number looks bigger now it's going to be like you have to wait be patient I have 35 seconds left to wait okay let's let's find let's want to actually check this uh can I do is there like a two list okay good that seems reasonable I'm not a league code bro I'm calling in Scala boys it's difficult okay you know but there's six seconds left to wait all right remind me not to get the wrong answer anymore I also ordered some meatballs so maybe they'll be here that'd be nice where's my fucking meatballs bro okay return to my advent calendar wait I have I solved this doesn't it where's my stars where are my gold stars oh I'm not logged in for some reason I don't know whatever okay uh the owls begin to set up camp on the beach a giant rock paper scissors tournament is already in progress fetch two then copy one go dot Scala first round I don't understand okay let's take a look at the data so I kind of understand that okay so it's just basically which ones I I couldn't understand um so let's first parse this as we can use the other thing we can read the lines let's read the lines let's read the lines boys what are the lines let's copy this at a chat GPT oh to list what if I don't do two lists it's an array import.txt okay we have lines um the score for a single round is the score for the shape you selected okay X for rock one for paper so let's just make a function called score that takes in a string and returns an end so that's not how I write that it's just this right so we want to do x dot split I really want to split that's pretty expensive can I just get like well eventually I want to say lines.map score um that's um but actually let's not do some first let's just print out on that and let's also make small input which is just that we can check on the small input uh Scala go dot Scala now we wait for the jvm to load okay uh what'd I do wrong I was mad because it doesn't return it in okay return zero just Returns the oh great oh you gotta set because sequels toxic chat today bro don't be toxic bro value get is not a member of string okay how do I get the character app okay that might be right can you tell me what type this is I should really just be doing this in a rebel okay good um let's make a map I don't know there's nine combinations here should we just write them all out you have to pay for free speech here that's right Freedom isn't free boys Freedom isn't free oh man you know how fast I'd be at this in Python oh so fast shape you selected so there is this component of it well here so we should be able to make a map um map X okay so there's two components to the score there's this component which says you get one two and three uh do I have to do dot get on the map okay so this is one component of the score let's just return that component of the score and see if it's right um let's also print out an X uh found options why is that option um I don't want it to be an option I wanted to assert I think I can just dot get in order to do that non.get no that's not right oh because it's probably not the the skull I have like a character type which is like this the thing is I don't know what type that is I mean I've seen that in other languages maybe that's right okay cool okay great so that's right um now we need the other one we need to figure out who the winner is okay um this is kind of ugly but I could just do this plus equals valid and Scala okay uh a draw is if x zero equals equals x two um we need a Scala in line if if then I'll do this we need parentheses no matter what three else zero expression expected but if found that is a fucking expression fuck you scar great I don't have any draws there uh we should have a draw CC should be a draw I don't understand that should add three oh no it doesn't actually equal we have to like map it back oh all right um fix fix dot dot dot get an extra comma there that's right now we also have to check for winning um so what's winning draw base win okay um if X Sub 0 equals no there's I really should just map these to integers and then check the integers right um Rock if my opponent played Rock and is it and or is it like that and I played paper uh actually you know what I should probably do I should probably just invert this and write or plus equals three sorry like I'm so bad in this language that score plus equals three okay so that's if the opponent played Rock and I played paper the opponent played paper and I paid played scissors and if I played uh scissors and the opponent played with the opponent plate scissors and I played Rock the total score would be 15.

the fact that Twitter is predominantly written skull is an Evidence of why this whole quiet quitting entitled culture in Silicon Valley is a problem oh it's really not I think so I I think that the choice of skull and Twitter was was less dumb than you think I did like I found like the guy who like really wrote all of it the code the a lot of the Scala is very nice there's not that much of a problem with it and also remember it wasn't chosen today it's better than Java what would you use instead of scholar okay and then we can just do some here and then let's run this is my answer right let's find out yay I got a gold star anyway the second column y means you need to the second column says how the round needs to end oh I see okay that's difficult all right get ready for difficult work ill oh leeches is written in Scala interesting you would use Java or python Java is really disgusting yeah I don't think kotlin existed right like let's figure out when kotlin came around it looks very much wait this just looks like Scala hmm yeah and it first showed up too late okay well you can't use Python do you understand how slow python is like python is not a serious choice for any sort of uh wait I gotta check where my food is hang on where's my food oh wait what did it arrive is it downstairs I hate when they put it downstairs where's my food because meatballs aren't at my door I'm gonna be mad foreign oh guys I gotta go downstairs and get my food I don't even understand like it like disappeared enjoy your order call Renee if you can't find your order was my fucking order spaghetti with meatballs cost thirty four dollars this is insane oh wait how did this cost thirty four dollars and I can't view the receipt yeah just so something's got to be done I hate this city all right I gotta go find my I'll be back I go find my I gotta go find my food foreign foreign no food bro oh let me make sure I didn't do anything stupid did I order to this why can't I see the receipt okay I ordered to the right address get help can't help this is crazy it sounds no I'm just more help select help with my past order conversation you delivered my order today my order never arrived we're sorry to hear you never received your order foreign the thing see I can't call back because I have my phone silenced all up all right silence on on callers off okay now I go here and okay cancel uh no receipt available get help connect me as a person all right now I get a call from spam Uber will not ask for any confidential or private information and you should be careful when sharing information with a third party press one to connect the call to the other person this is a call from Uber please leave your message for four one five bro we got rugged bro we got we got what we got we got we got rugged no this is insane help with a past order my order never arrived next oh here I can get my refund I don't want fucking Uber cash I want my original payment method honestly did the driver just eat my food may take three to ten business days how satisfied would you with the support I received sad face oh now it's going to tell me why thanks PM oh what's the primary reason for your fuck PMS man fuck PMS I'm hungry and there's no food ah best we can do is [Music] all right is there any food in this apartment I found tea coffee sponge Tide Pods oh maybe there's some food in here all right smarter snacking oh here we go all right all right good we got a box of snacks all right so well you can't you can't you can't call it Scala on an empty stomach oh sweet potato chips white cheddar popcorn or Lacroix all right we'll eat the potato chips is that a beer Still Water not all right so really where is my pasta it was 34 anyway let's get our money back all right 220 calories of chips sweet potato chips foreign Twitter was originally in Ruby foreign let's just write the transformer for this um all right you know what let's just write this map okay ax means we need to lose so this should be we should have done this with numbers that was a smart way to do this that's why I would have done it in Python but I heard a noise outside there's some chance that's my meatballs keep awesome no meatballs I don't want to like instacart or something get some real food up in here we also have some white cheddar popcorn to eat next yeah you get the food and your money back that's winning if I need to lose given Rock I need to choose scissors um I'm going to lose here I'm going to choose that and that and then if I need to draw and if I need a win this is just going to be um b c a hey on the map we want to get x sub 2 we want to call get again and then we want to say Val C2 that 12.

no such element no I don't know we just get for x y c a y there um what did that work c-a-y does the string have like crap after it that I can't see there's a y I don't understand that oh this isn't right this is actually z x y x y z 12. wow great let's return to my Advent calendar wait did it just say I could share on Macedon that's expensive what's LSP as a Twitter employee I'm offended by your suggestion that I share on Mastodon okay rucksack reorganization [Applause] um we definitely want the other type where we read the lines okay see really I should write scripts which automatically like extract that [Applause] so we need to split them find the combination um did I use substring in the other one I feel like I use something else slice um okay that's correct uh now we need to find the one that's the similar in both or the index of Scala we're getting nine minus one okay so S2 dot index of is this algorithm wrong I think this algorithm is unsquared whatever I have a fast computer skull is very fast runs on the jvm um not equal to minus one [Applause] um is it char now we need to do this other look up uh okay one through um yeah they're eating my fucking meatballs it was unbelievable more people should be fired you have one job it was bringing my meatballs and you didn't do it and now I'm eating sweet potato chips and popsy all this disgusting oh now I got chips everywhere which is terrible it's terrible this is terrible I'm I'm so upset I hate San Francisco with my fucking meatballs like ah [Music] do this for free speech that's why we love free speech all right wait we can't remember essentially clean the floor off scholar charger and [Music] um so if it is actually uh our preparation applications come before and ASCII so if V1 um Less Than Zero V2 else V1 233 not right I hate that I can't put two arguments into the print function like a normal print function they use like one of these okay the L's are wrong oh oops wait what why are they showing up multiple times oh they're shot multiple times ah okay they show up multiple times guys I'm eating disgusting food shop flops up I'm triggered ma'am where's my meatballs they took my spaghetti I want you to fix it 157 right they took my spaghetti we can have a different badge item type foreign so basically instead of splitting it in half we need to yes and we need the other kind I'm going to group them by three how do I do that she's an upsetting for Loop the Phillips are too upsetting I can't believe anyone ever used for Loops they're so upsetting how do I skip three OH ZIP zip either data three trip cloth you know Scala is this actually right or you just don't know I'm in a mediocre apartment in a terrible City I don't understand anyone lives here but how do I zip uh no I'm okay okay I guess I could do that if I can slice can I slice I want like the colon colon three right I see how to do it with zap no of course it doesn't work beautifully like python slice every let's not chat TBT Scala every third element in Array you can use the grouped along with the mapped and flat oh grouped oh oh man that's some fire Scala um head flatten wait there's gonna be fire if this works foreign let's do it on small I'm asking you know we don't want to flatten I know what we want to do map let's try that close um I'm gonna flatten we want to concaten we want to join Scala joined string into list or the other way around see how to create a single string oh dot make string fire bro okay now we can do dot grouped two um this isn't exactly right because we have to Scala unzip or I should be able to map that's gonna bitch and tell me some iterator again dot map case x y eval x y mismatch error found x n e y but it's grouped I don't understand slice notation in scholar is that useful to vector or would I ever want a vector I hate vectors let me get the elements actually kind of your Gap value get is not a member of list string I think it's not get it's just scholarly's zero Index right it's not like evil Lua iterator I love iterator 52.

oh that seems right let's do some I'll get 70. 52. wait what the first group all the only type that appears in all three okay never mind we're doing this wrong oh okay we have to find the one that's common in all three so we're close here 70. cool or we're scholar Geniuses bros we're scholar geniuses this food was disgusting should we followed up with a wheat and gluten-free cookie this is a real food normally don't eat this app there's no wheat and there's no gluten what does it have in it you know I'm hangry right now I eat a fucking Snickers that's how hungry I am I like Snickers I don't like peanut butter all right should we try Uber Eats again I'm sorry Chad I haven't interacted with you all the time but hopefully you like that I've been writing Scala instructor and that's what we all like to see on streams right do you like to see me be a noob and struggle [Music] I know many people might work all of them you just gets things because he's famous vaping all right GrubHub doordash really fucks up do I even have a doordash account I'm sorry chat thank you it's pretty more water for my tea the Twitter huge ten times over elon's not a big fan of feeding people granola cookie bake all right fine it's fine we'll eat this oh it just smells bad no I can't I can't oh vaping is my new hobby I Vape I play chess and I go on Twitter all right they're probably the apartment never mind uh what's with the new skinhead haircut I gotta look hardcore man Vape is probably bad for you how bad for you right a lot of things are bad for you smoking is bad for you we have more water for my nice calming tea um I know this is a terrible place this is a terrible place so at you see me in San Diego I'm chill man you know you know magic problem with my favorite words where should Twitter relocate to San Diego man Twitter wants me to stay at work that longer San Diego um San Jose is oh you like San Jose just hold this holder no Austin guys Austin is just San Francisco running it back turbo like it's it's not better you can't have these ultra-left cities like why because people like them because they have like like hipster coffee and stuff like it's not worth it guys it's not worth it the shitty politics of your city will creep into your tech company and you'll end up with the Twitter files all right like these people are like like they think you know these people here are whacked out of their mind man they don't say things like homeless you see what what's like the politically correct word for homeless now it's like unhoused persons right like anyone who talks like that is fucked no I mean everyone knew the Twitter files look like when Snowden came out I mean I thought this is all nothing Burger too like holy shit yeah of course the NSA is spying on all your you know Communications of course they're logging all the metadata right like everyone knew that everyone knew what all the Twitter files were too like yeah Twitter banned you from search like there's a tool online to check this everyone knows this yeah well work from home's another hole why do I want to work from this oh man I'm just agitated you know agitated it's like oh go outside and enjoy something nice no I won't um Twitter files are basic corporate Behavior I mean we had a sort of it's not yes the corporate behavior is broken is basically what I'm gonna say I agree and like look those people are not terrible people you all understand their decisions in isolation but then when you like zoom out and say wait a second what are we building here right that's a lot of the problem Twitter didn't understand what they were building right Elon says all the time this is the Public Square I old Twitter never said that or they might have but you know they just lost their way like what were they actually building they were not trying to build a Public Square they were trying to build uh something actually much more resembling a modern Newsroom oh Google search sucks now not because Google's been captured by ideologues Google search sucks now because there's no more internet to search um what did I get done this week oh I found some very interesting stuff this week like just I'm looking into there and look Elon wants me to fix search and I don't know I mean this isn't secret I'll talk about it like I can do basically one or two things I can ship a bunch of small mediocre features or I can build you a really impressive demo that won't be able to be shipped for two years right like what do you want sorry the best engineer in the world can't like ship this demo um I'm not going to go into the reasons why but like yes you can build incredible demos that use modern large language models use modern image embeddings use like fancy contrast of methods to figure out what you want deploy rlhf in real time yeah like you can do all these things but not in 12 weeks right and a lot of these things require you to build up good infrastructure beforehand I say this all the time at comma the goal is not like solving self-driving cars will be easy Once you build the right infrastructure to do it um no no no no no I can't I can't stay in this city more than 12 weeks man I miss Alex I miss San Diego uh there's nothing about Twitter Twitter's actually pretty nice um though we do need good food good food's important to me common is good food um how many more weeks uh I'm three weeks in to 12 weekend to your chat um yeah the city's just agitation and I I like I remember how I used to feel when I lived here how's the talent generally pretty good actually um you know I think that the people who stayed are exactly sort of the right people uh there's some very good Engineers there right and yeah like you know I am maybe there's a few more to to uh you know not not everyone but most of the people I meet are very good tiling window manager no I'm Italian right there when I stay at Twitter if they move to another city if they move to San Diego I think about it yeah if they move to San Diego I'd think about it and like look I could build some really incredible ml stuff for Twitter but it's going to take a year um and I think there is much more pressing priorities there right so again nothing secret Twitter used to have uh 7 500 people right your code base reflects your organization so when you have an organization that is very clearly overstaffed you have a code base that's very very bloated uh now you know what I would do is spend a lot of time refactoring but you have to make a choice do you want refactoring or do you want features right and you can scream both as loud as you want but you're not going to get both you're going to get probably actually features if you scream that you want both refactors and features you're going to get features uh the slack channels are probably fun though yeah you know they're they're not Bombshells to discover it's all basically what you think um like I said I I promise you the talent bar or Twitter has gone from here to here now the the people currently at Twitter are probably the average Twitter employee now is probably considerably more talented than the average Twitter employee was right the good people they believe um there was a tweet I liked it was like so the greatest entrepreneur uh you know of Our Generation comes and buys your company imagine what you could learn from him imagine the impact you could make imagine the opportunity but no you resign LOL right like um but if I refactor I can guarantee three times performance well can you right you can get there you can get there and refactorings are required refactoring can improve both your performance and your velocity of features but it takes time and there are not obvious results tomorrow so that's sort of the problem um I mean Elon is clearly you know whatever I think maybe elon's doing the wrong thing I do remember that he's a billionaire and I'm not uh so on average his decisions are better than mine right and this is true you can look at it you know it's the same thing in chess right like someone on average who has a higher rating than you is making better moves than you can I share the architecture of Twitter I mean it's mostly public right well for natural and finagle stuff is used um you can you could read all that uh that's like that Mike services how's Advent code I'm not really doing it this year um I don't have time you look at my GitHub my GitHub it's sad my github's not even there's no green on my GitHub right now it's all it's all empty um is Twitter bloated with microservices uh look what Elon said was accurate got to day nine and you're like meh I don't I think microservices are a good idea um for the most part I I think that uh it maybe has been taken to an episode extreme Alice I don't think Scala is a bad choice I think skull is a fine programming language like good luck I mean look look at the code I've been writing right let me clean up all these stupid print statements that's pretty nice actually I don't think I could write it much faster in Python there's there's nothing in Python there's nothing like called grouped in Python is there not that I know of yeah there's no group to buy them um in Python I would do like Zip and then zero colon colon three and then one colon colon three two column three uh why not go Lang I mean yeah golang is probably a better choice for microservices than Scala that's what I would choose today but I I mean I think there are more go Engineers again there's nothing fundamentally wrong with Scala this is your favorite Scala project oh chisel I don't know chisel was written in sky sorry this is gonna be a short stream today I'm uh maybe maybe I'll do one more at that code we have 843 people here all right we'll do some more coding I'm just I'm hungry I'm hungry and I gotta get food all right let's try ordering again should we try Uber Eats part two Getty Istanbul Grill King of Thai Noodle Grandma's homemade pasta I got some from Grandma's homemade pasta it was very mediocre so I tried a different pasta place should we just order the same thing again no it was 30 something dollars so we should probably go out it's raining foreign we'll do one more we'll do we'll do one more problem and then I'm gonna go out and find food order the same thing but say it's for a cop bro I don't think they like cops around here uh look I'll Advocate as much as I can to open source Twitter's infrastructure you know but again when you look at elon's other companies he hasn't really open sourced much it was a struggle to get Tesla to open source the Linux their Linux kernel even which you legally have to um tiny cores and Scholar chisel there's nothing really wrong with uh with Scala yeah I miss tiny grad I missed the tiny Corp all right um day four consider the following section assignment pairs um let me say uh fully contains the other how many assignment pairs does one range fully contain the other okay this is not too hard so we're going to do lines dot split but see it can't be split okay uh [Music] this is the last one guys Can I some Bulls clogbull is probably fine okay so we want x dot [Music] um can I split on two things you can also split based on a regular expression and really what I want to do is like that that might work so in Scala VAR changes Val doesn't true I'm just gonna bitch and be like uh oh yeah I gotta equals here no implicit ordering to find for be fine L Javelin string okay good that works great I know my right Axis okay um we want to figure out if does one range fully contain the uh there so let's map two inch all right and then we can say a sub zero all right so if it fully contains then we have a sub 0 less than or equal to a sub 2 and a sub 3 is less than or equal to a sub 1.

Leave a Reply