Talks

Keynote: The Case Of The Vanished Variable - A Ruby Mystery Story

After a stressful couple of days at work, Deirdre Bug is looking forward to a quiet evening in. But her plans are thwarted when the phone rings. “I know I’m the last person you want to hear from…but...I need your help!” Follow Deirdre as she embarks on an adventure that features a looming Demo Day with serious prize money up for grabs, a trip inside the walls of one of the Ruby community’s most revered institutions, and some broken code that appears to be much more simple than meets the eye.

RubyConf 2022

00:00:00.000 ready for takeoff
00:00:17.600 hello it's such an honor to be keynoting rubyconf thank you to the organizers for
00:00:23.880 having me do this so I'm Nadia odorayo and I'm the founder and CEO of a company called the
00:00:31.380 storygraph a Reading Tracker and book recommendations app we help you to choose your next book
00:00:38.579 based on your mood and your favorite topics and themes we've got a whole range of stats where
00:00:45.719 you can learn about your reading habits and see how they develop over time we've got machine learning powered
00:00:52.620 personal recommendations it's like a trusted go-to friend who knows your preferences but whose brain
00:00:59.160 is also a book Encyclopedia you can find your next perfect read by
00:01:05.519 filtering lists of books by mood Pace fiction versus non-fiction genre book
00:01:11.100 size and more you can also read alongside friends
00:01:16.560 adding live reactions to specific parts of the book and the comments remain locked until your friends reach that
00:01:23.460 specific part in their reading and there's a whole lot more on offer
00:01:30.420 we have three million unique monthly visitors 36 million page views per month
00:01:37.740 and each month we serve 110 million requests
00:01:43.320 so people often ask me what is story golf built in and I love that I can say
00:01:50.460 Ruby on Rails okay thanks
00:01:58.259 and with all of this website and app activity we get a lot of customer feedback feature requests and Bug
00:02:03.960 reports given that I run the company's Instagram and Twitter accounts I'll often receive
00:02:10.140 messages that include something like if you could pass this on to your Dev team that would be great
00:02:17.160 now while I have an absolutely awesome co-founder in Rob freelo
00:02:22.800 the web and app Dev team is made up of just me
00:02:28.080 in fact I recently gave a talk about this at the inaugural rails SAS conference run by Andrew Culver in LA in
00:02:36.360 October and my talk was titled getting to 1 million users as a one-woman Dev team
00:02:44.099 I spoke about the ups and downs in Building Story graph and there were some real stressful moments in this journey
00:02:50.580 some very dark times where I felt stuck and where I questioned whether I could keep going
00:02:57.300 and as the talk blurb says it was a personal intimate story
00:03:03.480 but I saved the real intimate details for
00:03:10.260 you the rubyconf audience I have a secret
00:03:16.440 don't tell anybody you see despite all of the focus hard
00:03:21.900 work and stress that went into building storygraph into what it is today I couldn't help but keep up a little
00:03:28.800 side gig I'm not just the founder CEO and solo
00:03:34.080 developer of the story graph I'm also a private investigator
00:03:41.940 and what is it I investigate you ask Ruby crimes
00:03:48.239 not Jewel theft I investigate crimes and Mysteries relating to our favorite
00:03:53.519 programming language why did I go into private investigating
00:03:58.799 wow they've been really misshading there's been rumors circulating of a shady Mastermind causing havoc and confusion
00:04:05.580 amongst Ruby developers worldwide with his constant meddling in the source code
00:04:10.980 and I wanted to be the one to put a stop to him and I'm sure all of us here know just
00:04:16.859 how lucrative the world of Ruby private investigating is and I decided that I couldn't do this
00:04:23.820 gig under my normal name no I needed to protect my identity
00:04:29.040 so I decided to call my Ruby private investigating Alter Ego Deidre buck
00:04:35.580 D for short why well isn't it rather obvious
00:04:43.020 now I've got several stories from my years of doing this work
00:04:48.180 but for today's keynote I thought I should tell you all about a case that happened within the very walls of one of
00:04:54.120 our communities most revered beloved institutions this is the case of the vanished
00:05:00.720 variable chapter one it was June of last year
00:05:07.800 I'd had an incredibly stressful couple of days at storygraph Rob and I had just finished dealing with
00:05:14.699 our first experience of serious online controversy around our product our content warnings feature had come
00:05:21.479 under Fire after a series of well-known authors brought to light that inaccurate warnings were being attached to their
00:05:28.259 books things were going wild on Twitter
00:05:35.400 Robin I stayed calm and mollified the Twitter situation before coming up with
00:05:40.440 a proposal for adjusting our system we sought feedback from the community and after our ideas were received
00:05:47.820 positively I coded all day and night to implement the changes it was a wild and stressful time but we
00:05:54.900 pulled through being the sole software developer though
00:06:00.000 this had really wiped me out despite knowing that wasn't the case I'd felt personally attacked in all of this
00:06:08.220 I needed a break from storygraph and I was in the process of planning a relaxed evening when the phone rang
00:06:16.500 immediately upon answering I heard a breathless anxious voice say I know I'm the last person you want to hear from
00:06:22.979 but I need your help oh I recognize that voice how could I forget it
00:06:29.039 Jenny who's Jenny some of you may be wondering she was 29
00:06:35.520 a seasoned Ruby developer who was obsessed with all things rails she also betrayed her best friend once
00:06:42.900 during one of my earlier cases by giving him faulty information about how Ruby method lookup worked
00:06:49.500 I'd heard through the grapevine that she'd learned the error of her ways and was on a good path now but I was
00:06:55.199 hesitant to trust her Jenny worked for the famous world-renowned Ruby Institute of
00:07:01.680 professionals the organization whose whole reason for existing was to see to it that the Ruby
00:07:07.500 language and Community stayed Alive and Kicking forever slightly unfortunate logo
00:07:13.740 anyway it was a job related issue that had Jenny calling me that day
00:07:19.020 you see the rip had started up this new internal incubator a competition of sorts
00:07:24.780 all within the organization's aim of improving Ruby's image and usage worldwide
00:07:30.419 people within the organization could get into teams and submit various startup ideas
00:07:36.060 the winning team would win a 500 000 investment and the opportunity to work
00:07:41.280 on their startup full-time fully supported by the rip and for the very first round of this
00:07:48.539 Jenny's team had made it into the final two we're building a platform that assigns
00:07:54.720 grants from a pool of money that the rip has available for this kind of thing they'd go to fund Ruby developers and
00:08:01.199 organizations there are three different types of award on offer that vary in Grant size and can
00:08:07.319 go towards different types of projects for our demo we simulate an automated draw for the grants including doing
00:08:14.220 multiple redraws until the maximum number of Grants has been assigned but the number of awarded grants came
00:08:20.879 out incorrectly in the semi-final today which was embarrassing we thought we'd be out but the judges
00:08:26.580 put us through it's so close between the final two teams that the judges will be looking
00:08:31.979 for any reason to disqualify one of us but here's the problem and Jenny side heavily at this point
00:08:39.479 our lead Dev Alex is now very stressed and he won't admit that he needs a second pair of eyes
00:08:45.420 with only two devs on the team and not only do I have other jobs to get on with I really hate working with him
00:08:52.980 the final is tomorrow and there's only a few hours left to get to the bottom of this we need you she finished
00:09:01.080 I was quiet while I thought about it Not only was I wary of helping Jenny out
00:09:06.660 knowing her dishonest past after my incredibly stressful couple of days at storygraph I was meant to be
00:09:13.680 relaxing but well debug can never resist a challenge
00:09:19.920 and it's never a good idea to pass up an opportunity to go into the rip
00:09:24.959 after all I was sure they'd pay me handsomely for this work
00:09:30.779 I agree to take on the case chapter two
00:09:36.839 I don't need help Alex said bluntly after listening to Jenny's explanation of why I was there
00:09:43.140 he sat in his office chair with his arms crossed a mix between sulking and glaring
00:09:49.560 Jenny started to protest but I had an idea I dealt with this type several times
00:09:55.080 before you know the self-proclaimed 10x hero developer who knew everything and
00:10:01.320 declared that they could solve all of the company's problems in an afternoon if only people would leave them alone
00:10:07.440 I knew what would loosen him up a little I'll tell you what Alex I said I won't
00:10:13.440 distract you I won't say much I won't touch the keyboard I'll just sit next to you and be your
00:10:20.279 rubber duck you can just talk me through the code and the bug bounce ideas off of
00:10:25.380 me and of course you'll find the solution by yourself and you'll get all the credit but this way you'll find the
00:10:31.740 bug quicker we're all silent well Alex thinks about it frowning
00:10:38.040 before finally saying fine Alex had already turned back to his
00:10:43.860 keyboard as Jenny gives me a subtle triumphant fist pump and says she'll leave us to it
00:10:49.500 as I go to take my seat next to Alex though he briskly puts an arm out to stop me
00:10:54.720 I've just realized I can't show you the code base as is he says there's confidential code in here from
00:11:00.360 some of Rip's clients and partners let me get rid of it I was wary that a couple of hours had
00:11:06.540 already passed since Jenny's call but I couldn't really argue with the issue of me seeing potentially sensitive client
00:11:12.240 information so I pulled up a chair a couple of seats down from Alex and I decided to make the
00:11:18.360 best use of the time by opening up Duolingo after all there was no way I was going to take
00:11:24.959 down the Shady Mastermind if I didn't stay on top of my Japanese right
00:11:30.540 40 minutes later and Alex is finally ready to show me the code now I'm only showing you a simplified
00:11:36.839 version of what I saw on that day first each award type had its own file
00:11:42.720 that looked like this here Alex had defined a class named
00:11:48.360 award a which inherited from another class called Grant then there was a class instance variable
00:11:54.540 called award count which was set to zero there was a class method also called
00:12:00.300 award count which returned the value of the class instance variable then there was a class method called
00:12:06.779 assign which incremented the award count class instance variable by one
00:12:12.480 and Alex quickly showed me how the files of the other two award types were exactly the same except for a change in
00:12:20.040 class name and then there was the grant class itself
00:12:25.560 there was a constant called Max grants which was set to 100. the grant class had its own award count
00:12:31.980 class instance variable which didn't seem to be being used anywhere the grant class also had its own award
00:12:38.760 count class method which added up the award count on all three award types
00:12:44.160 then there was an awards remaining class method which was used in the redraw to figure out how many awards still needed
00:12:50.940 to be assigned it took the maximum number of Grants permitted and subtracted the number of
00:12:56.579 awards that had already been given out then there were scripts that assigned some awards 50 lots of award a 30 lots
00:13:05.519 of award B and 20 lots of award C and finally a script that checked how
00:13:12.060 many prizes were left and then performed a redraw if necessary so remember in the code that Alex showed
00:13:18.959 me there were a maximum of 100 grants that could be awarded and 50 plus 30
00:13:24.899 plus 20 equals 100 which equals the maximum number of grants that were
00:13:30.300 available are you following so far or do you need me to go over it again Alex asked
00:13:36.839 no I got it I told him if anything I've been holding back from suggesting
00:13:42.360 places where his code could have done with some improvements I mean that wasn't my style
00:13:47.579 usually I just focus on the problem at hand and avoid making quick judgments about the quality of unfamiliar code
00:13:53.399 bases but Alex's Behavior was frustrating anyway on the whole his code looked
00:14:00.779 straightforward I couldn't see what could go wrong Alex ran the scripts
00:14:17.279 what 300 Grants awarded maximum number of Grants exceeded
00:14:26.220 what a mystery chapter 3
00:14:31.980 I spent a few moments feeling baffled before I remembered that I was the great debug a private investigator I had to
00:14:40.260 stay calm and focused and I had to play my cards with Alex carefully he seemed to be opening up to me so my
00:14:47.639 strategy was to let him keep driving and to slowly nudge him into what would hopefully turn out to be the right
00:14:53.579 direction something had stuck out to me during the code demo the class instance variables
00:14:59.940 now I thought the class instance variables belong to one specific class only
00:15:05.639 but the four classes all had one with the same name given that the three award classes all
00:15:12.300 inherited from Grant and we had three times as many awards being assigned I wondered if some overwriting was
00:15:18.720 occurring what if I said cautiously to Alex each class were to have a differently
00:15:25.440 named class instance variable perhaps they're all conflicting with one another
00:15:30.779 Alex glared at his display as if he hadn't heard me but then he Shrugged and said sure we can try that
00:15:38.639 and so he took each award class and adapted the name of their class instance variable to include some reference to
00:15:45.240 its type like so he then ran the program again
00:15:59.040 same result so it wasn't the fact that the class
00:16:04.500 instance variables with the same name in one inheritance chain were interfering with one another
00:16:10.440 they did in fact as I'd understood to stick to their own classes I was wondering what to suggest next
00:16:16.740 when we were interrupted by one of Alex's colleagues Alex he said you'll never guess who's in
00:16:23.399 the office we both turned up to look at him maths
00:16:29.519 maths Lots mats mats everybody loved him but I knew different
00:16:38.279 I knew he was not to be trusted but in that moment his appearance worked
00:16:43.920 in my favor because the way Alex jumped up and sprinted away from the computer towards wherever Max was you'd think
00:16:51.180 he'd heard that somebody had dropped a billion dollars on the floor and the first person to pick it up got to keep it
00:16:57.000 but I didn't care because finally I could get my hands on the keyboard
00:17:03.660 Alex's fancy clacky keyboard with no labels on the keycaps didn't phase me oh
00:17:09.720 no now I could finally do what I did best
00:17:15.959 solve this mystery while I'm all over what to try I
00:17:21.600 immediately out of habit because of my excellent get hygiene if I do say so myself
00:17:27.600 type get status into the terminal there are changes in the repo so I type
00:17:32.700 in get diff and I'm casually looking over the output before it hits me that oops I probably shouldn't be looking at
00:17:39.960 this there might be client data in here that the rip don't want me to see so I quickly exit but not before
00:17:47.160 something catches my eye 151 lines added to this simple script
00:17:53.880 that Alex had created to demonstrate the bug but the file that we've been looking at
00:17:59.100 had been only a few lines long I quickly tabbed over to the filing
00:18:05.280 question hit command and the down arrow to jump to the bottom of the file and this is what I see
00:18:12.660 the grant class had been reopened the class instance variable award count had be overwritten to be 300 and the class
00:18:19.919 method Now read from the class instance variable directly no wonder the what are you looking at
00:18:26.760 Alex had returned and wasn't too happy to see me sitting in his chair touching his keyboard
00:18:32.400 he looks over my shoulder at the screen and sees what I'm looking at he looked a little alarmed at first but
00:18:38.460 for confusion took over uh where did you get my old code from he
00:18:44.220 asks suspiciously that's from an old demo well it was right at the bottom of this
00:18:50.820 file I say and all of a sudden Alex looks incredibly embarrassed like he wants the
00:18:56.580 ground to swallow him up he explains how when he was getting the repo ready for me he'd been making quick edits copied
00:19:03.660 and pasted a bunch of code from one place to the next by selecting the whole file then deleting horse waves of it I
00:19:09.900 must not have noticed this bit of code being left behind in his haste but I say
00:19:16.320 this code must have been hanging around for a while surely you would have noticed it unless
00:19:21.780 you never do partial commits
00:19:28.860 now copy and paste errors can happen to the best of us I certainly be called out
00:19:33.900 by them before but I have to admit though after his behavior throughout the day it was
00:19:40.020 rather nice seeing Alex humbled a bit but however trivial the bug a case isn't
00:19:46.260 over until I see the code working and so I deleted the code from the bottom of the script and ran the program again
00:20:02.340 while it didn't end up being a meaty problem to sink my teeth into and distract me from my stressful story
00:20:08.340 graph situation the case was closed my work here was done
00:20:14.460 chapter four I was on my way out of the rip building when I hear someone call my name
00:20:22.080 it's Jenny I've just heard from Alex that the two of you have figured out what the issue
00:20:27.120 is she says he's gone off to go and implement the changes now
00:20:32.460 I'm not the Told You So type but it was the class variables wasn't it
00:20:37.559 I knew that him using them was a bad idea you mean class instance variables I say
00:20:44.580 no class variables this is Jenny you don't mean class instance variables
00:20:51.179 I ask because there wasn't a single class variable in sight Jenny only class
00:20:57.120 instance variables and I don't much like the expression that Jenny starts to give me
00:21:04.980 do you have time to come back upstairs please she asks I'm not I want to get to the bottom of this
00:21:11.100 confusion we head to her desk where she starts to fetch the latest code from GitHub
00:21:17.039 and I tell her to be careful so that I don't see any confidential code and she says what
00:21:22.799 there's nothing confident in here we started up a whole new code base just for this project
00:21:29.460 and now it's my turn to raise my eyebrow but it's not long before the expression
00:21:34.620 on my face turns into one of shock because Jenny is now showing me the code and it looks exactly the same as the
00:21:41.820 code that Alex showed me except for the fact that all of the class instance variables in the award classes are in
00:21:48.299 fact class variables and the grant method no longer has its
00:21:53.340 class instance variable apart from that it looked the same
00:21:58.620 let's run the code I say
00:22:12.600 okay so it still works but hey check this out I say to Jenny pointing at
00:22:19.799 something in the web browser tab that's visible behind the terminal Alex had made a commit 14 minutes ago it
00:22:27.419 was a one-line change he'd removed a line from the grant class
00:22:33.120 so before his last commit the grant class instead of looking like this
00:22:38.520 looked like this the grant class also had a class variable
00:22:45.179 let's run this code I say I had my suspicions
00:22:59.460 and they were proven correct this code fails in exactly the same way as the earlier bug that Alex had
00:23:07.020 presented to me and now I'm really confused because there was in fact a bug
00:23:14.400 but Alex knew how to fix it all along but didn't tell his teammates and then
00:23:19.440 gave me a fake problem to solve when I came in let's go and find Alex and get to the
00:23:25.200 bottom of this Jenny suggests it's past 8pm and there's hardly anybody left in the
00:23:31.020 office Alex is not at his desk he's not in the kitchen he's not playing ping pong
00:23:37.799 maths has gone so we know that he's not somewhere fawning over him I spot the quality could come over
00:23:43.799 earlier we asked if he's seen Alex anywhere I just saw him
00:23:49.200 he was trying to find a quiet corner to take a personal call we hurried off in the rough direction
00:23:54.780 that the colleague had gestured to planning to grab Alex as soon as he came off the phone
00:24:00.720 we were about to turn a corner when we heard snatches of hushed dialogue
00:24:05.900 Zoe they almost caught me even brought in a private investigator
00:24:14.159 faked some code for fun and to buy time Jenny will be nosy so I fixed the real
00:24:20.760 code for now but don't worry honey I'll put the bug back in before the
00:24:26.700 final tomorrow my eyes widened Jenny gaped at me
00:24:32.100 before we rounded the corner to confront Alex and then it was his turn to look absolutely mortified
00:24:40.380 chapter five it's two hours later and I'm sitting with Jenny at her desk
00:24:46.500 thinking over everything that I managed to piece together after my interrogation of Alex
00:24:52.980 so Alex is dating another one of your colleagues Zoe and Zoe isn't the team
00:24:59.100 competing with yours for the final 500 000 prize at some point throughout this whole thing Alex became fed up with your
00:25:06.059 team and your idea much prefers Zoe's team's idea which he had a hand in coming up with and he wants them to win
00:25:12.720 so that he can go and work on that team alongside his girlfriend and so he set out to sabotage his own team by
00:25:19.440 introducing a bug to the code but anybody who had a chance to look at the code would have immediately suspected
00:25:25.140 the class variables and so he sent me on a wild goose chase and a bid to waste time instead
00:25:32.220 yep wow
00:25:37.279 so much Ruby drama here I was trying to escape drama in my
00:25:44.159 day job and instead I ended up yet again in another mess during my side gig
00:25:51.779 I said goodbye to Jenny and headed home knowing that despite the hour my night wasn't over
00:25:58.380 as soon as I got in I went straight to my computer and opened up a prize session I had things to investigate
00:26:06.600 first I created a class called Grant which had a class variable called type which returned Grant
00:26:13.799 I also defined a class method called type which returned the value of the class variable
00:26:19.919 then I created an award a class which inherited from Grant and looked exactly the same as its parent class except for
00:26:27.000 the fact that the class variable type was set to a So based on what I'd seen earlier if my
00:26:33.299 suspicions were correct that not only would award a type return a but Grant type would return a to
00:26:44.940 I was indeed correct unlike class instance variables which have their own separate copy no matter
00:26:51.960 the inheritance chain class variables seem to share a value amongst objects in a chain
00:27:00.840 does it matter which direction I go in I wondered I had created a subclass and set a class
00:27:07.440 variable with the same name there what if I reopened Grant's superclass and set the class variable there too
00:27:15.659 I confirmed that Grant superclass was object and then reopened the object class giving it the same class variables
00:27:22.559 and class method as Grant and award a so object type returned object and Grant
00:27:30.840 type returned runtime error class variable type of Grant is
00:27:36.299 overtaken by object what about award a type exactly the same error including the
00:27:43.980 reference to Grant okay so it looks like with class variables of the same name there's
00:27:50.520 definitely only one value shared in The Inheritance chain referred to from only one class in the chain but you can only
00:27:57.840 set them in one direction if you reopen a superclass and define a class variable
00:28:03.240 that's already been defined in any subclass it raises a runtime error in those subclasses
00:28:10.620 I then wondered how far up the inheritance chain Ruby went looking for class variable definitions
00:28:17.039 so I first confirmed that the highest class in Grant's inheritance chain whose basic object before reopening that class
00:28:23.640 and giving it the same class variable and Method as the other classes
00:28:31.020 looks like Ruby goes all the way up to basic object when dealing with class variables
00:28:36.539 now at this point I had a lot in my head and I don't know about you all but I always find diagrams incredibly helpful
00:28:43.860 so it was time to sketch out what I'd piece together and see if it matched up with the behavior in Alex's code
00:28:50.159 first I knew that in the sea Ruby internals for every Ruby class there's a
00:28:55.980 corresponding r-class structure this stores things like a table of the classes methods its attribute names and
00:29:03.779 also a table of class instance variables I assumed that there was also another
00:29:10.380 table for class variables so if I took the grant class from Alex's code we'd have an R class structure that
00:29:18.299 looked like this with an entry for a ward count in the class variables table
00:29:25.140 when the award classes were first defined including the setting of a class variable with the same name there were
00:29:32.039 no problems initially my prior session had indicated that Ruby
00:29:37.080 journeyed up the entire inheritance Chain Looking for the highest superclass that had the same class variable set
00:29:43.080 there and then overwrote the value in Alex's code all of the classes had
00:29:49.260 the same initial value for award count zero but then the scripts had started
00:29:55.559 assigning Awards and this was where the behavior of class variables had started
00:30:00.720 to cause issues every time an award of one type was assigned the value of the award count
00:30:07.860 class variable was incremented by one so after 50 lots of award a had been
00:30:13.799 given out it was the one and only stored value of the of the class variable on the grant
00:30:19.440 class that was being updated so after the first script has been run when the scripts had called the award
00:30:26.279 count class method on award a it had correctly returned 50. but calling the
00:30:32.460 same method on award B and C would also yield the same result despite the fact
00:30:38.460 that we'd not actually awarded any grants of type B or C yet and then we had the script that awarded
00:30:45.419 30 lots of award B and the one copy of the class variable gets incremented 30 more times
00:30:52.559 and by the time we award the final 20 lots of awards C we have this
00:30:58.140 so when the final redraw script was run an award count was called on the grant
00:31:03.179 class which adds up the result of the same method on all three award types
00:31:08.340 three lots of 100 equals 300 which exactly matched the bug in Alex's code
00:31:18.240 I was feeling rather pleased with myself at having pieced this together but I wanted someone a teeny bit wiser
00:31:25.440 than I was to verify that I'd got it exactly right luckily
00:31:31.020 I knew just the person chapter six
00:31:37.080 despite the hour I wasn't surprised that my contact replied straight away saying she'd be up
00:31:43.020 for jumping on a video call with me to talk about class variables who was I speaking to
00:31:49.260 Ellen now who on Earth is Ellen some of you may be wondering
00:31:54.899 she was 45 an experienced freelance developer who had seen many things and
00:32:00.120 who regularly brought what she'd learned on her adventures to the Ruby code base
00:32:05.399 I talked her through my diagrams including the bug I had been dealing with and the general picture I put
00:32:11.159 together on how class variables worked did I get it right I asked
00:32:17.880 yes except for one small thing and then says class instance variables and class
00:32:24.120 variables are actually stored in the same table in the r-class structure
00:32:30.000 the extra at symbol on class variables means that they don't get mixed up
00:32:35.220 okay cool I say but there's been something on my mind
00:32:42.600 class variables only seem to cause a lot of trouble Ellen what are they good for
00:32:48.899 well this is Ellen they're really good for application configuration
00:32:54.299 in fact your favorite framework rails uses them extensively for that very
00:32:59.580 thing okay fine but that's a whole framework I say most
00:33:06.419 of the time the everyday developer building websites and apps doesn't have to worry about them right they could
00:33:13.440 just avoid them well says Ellen let me tell you a story
00:33:21.419 you discovered today during your investigations that when accessing a class variable Ruby will go up the whole
00:33:28.140 inheritance chain all the way up to basic object in order to check which class was the highest to set the
00:33:34.559 variable right well Eileen you should tell of the Rails core
00:33:39.659 team and Aaron Patterson who is on both the rails and Ruby core teams wanted to
00:33:45.120 dig into this fact some more the bug that you dealt with at the rip today only featured an inheritance chain
00:33:52.559 that was two levels deep but Eileen and Aaron with their expert
00:33:57.960 knowledge of rails internals knew that not only did rails make extensive use of class variables
00:34:03.720 The Inheritance changed there went a lot deeper
00:34:11.940 surely Wales is extensive use of class variables was incredibly inefficient it
00:34:18.179 might be having a performance impact on Rails apps everywhere much more efficient would be
00:34:24.599 If instead of Ruby going up the entire entire inheritance chain each time to check for the highest superclass within
00:34:31.379 which a class variable was set there was instead a cache and so that's what they built
00:34:39.359 with the cash instead of Ruby checking every single class in The Inheritance chain when
00:34:44.820 trying to find the value of a class variable the method points to a cache which tells
00:34:50.520 your code exactly where to look for the class variable setter and after testing that there was indeed
00:34:57.180 a performance improvement with this cache Eileen and Aaron submitted a PR for Ruby that got merged in just the
00:35:04.619 other day because these two took the time to understand how things worked under the
00:35:10.440 hood and then develop this change anybody upgrading to Ruby 3.1 will see a
00:35:16.440 six to seven percent request throughput performance increase in their rails apps just like that
00:35:22.079 now why did I tell you this story Ellen asks me
00:35:27.599 well people are always saying things like Ruby is slow
00:35:33.720 Ruby doesn't scale Ruby is dying and I've had a lot of conversations with
00:35:40.440 Eileen about this and I know how she feels about it
00:35:45.720 and I feel the same you see if only more of us everyday developers took the time to learn Ruby
00:35:53.180 really learn Ruby and understand how it works under the hood
00:35:58.619 understand why it is the way it is get to groups with all of its quirks and gotchas
00:36:04.560 then we'd be able to spot pain points and opportunities for us to improve Ruby and make it faster make it great for
00:36:12.060 scaling apps and so much more if we spot things that we don't like about Ruby or think something could be
00:36:18.900 better instead of complaining about it we should be much more like Eileen and
00:36:24.839 Aaron investigating experimenting benchmarking building and fostering
00:36:31.079 conversations in the community we should be doing all of the things that will help keep Ruby alive
00:36:37.920 make Ruby a no-brainer tool of choice for developers and organizations at all
00:36:43.500 stages for decades to come as with any conversation with Ellen
00:36:50.220 I left it feeling super inspired there and then I vowed that whenever I
00:36:57.119 got time away from storygraph however little I would continue striving to understand
00:37:02.460 how we be behaved under the hood and do what extra I could to contribute to the
00:37:08.040 amazing language and community
00:37:17.339 okay