0:00:18.740,0:00:19.869 DAVID HEINEMEIER HANSSON: That any better? 0:00:19.869,0:00:22.460 Oh, there we go. Woo. 0:00:22.460,0:00:27.090 Software's hard, as you can see. Hardware,[br]too. 0:00:27.090,0:00:33.270 So last year I had the personal pleasure of 0:00:33.270,0:00:36.620 celebrating ten years of working with Ruby[br]and ten 0:00:36.620,0:00:40.420 years of working with Rails. But this year,[br]I 0:00:40.420,0:00:44.360 have a much more interesting anniversary,[br]which is ten 0:00:44.360,0:00:48.210 years of sharing Ruby on Rails with all of 0:00:48.210,0:00:51.239 you and everyone who's been using it over[br]the 0:00:51.239,0:00:55.000 past decade. 0:00:55.000,0:00:56.920 The picture in the background is actually[br]from almost 0:00:56.920,0:00:59.030 exactly this time, where I gave the very first 0:00:59.030,0:01:03.769 presentation on Ruby on Rails at a Danish[br]university 0:01:03.769,0:01:06.100 ten years ago. 0:01:06.100,0:01:07.780 Ten years ago, I had to talk a lot 0:01:07.780,0:01:12.210 about what is MVC, for example. Today, not[br]so 0:01:12.210,0:01:14.409 much. There's a lot of things that over the 0:01:14.409,0:01:17.979 past ten years, things we were worried about[br]in 0:01:17.979,0:01:20.920 the beginning, sort of leveling up as a community 0:01:20.920,0:01:23.630 and as, as programmers, that just aren't relevant[br]anymore. 0:01:23.630,0:01:25.280 We're just taking all that stuff for granted. 0:01:25.280,0:01:27.530 Which is awesome. We get to care about a 0:01:27.530,0:01:30.189 lot of other stuff. 0:01:30.189,0:01:32.090 But as I look back over the past ten 0:01:32.090,0:01:35.460 years, which is pretty much the majority of[br]my 0:01:35.460,0:01:40.079 adult life, I've been working on Ruby on Rails. 0:01:40.079,0:01:42.780 It's fun to look back even further. I think 0:01:42.780,0:01:49.520 there's a common misconception that anybody[br]who ends up 0:01:49.520,0:01:52.700 creating something like Rails or 0:01:52.700,0:01:54.869 doing something else within 0:01:54.869,0:01:56.530 software development or computer science, 0:01:56.530,0:01:57.249 well, they must have 0:01:57.249,0:02:00.689 been programming since they were five years[br]old, right. 0:02:00.689,0:02:03.719 The whole notion of a hacker is somebody who, 0:02:03.719,0:02:07.670 who sort of got their first computer twenty[br]years 0:02:07.670,0:02:11.900 ago and was just programming the entire time.[br]Well. 0:02:11.900,0:02:13.310 That wasn't me. 0:02:13.310,0:02:15.650 I did not learn to program when I was 0:02:15.650,0:02:19.260 five years old. I didn't learn to program[br]until 0:02:19.260,0:02:23.580 I was closer to twenty. I'd been interested[br]in 0:02:23.580,0:02:25.850 computers for a long time, but it wasn't really 0:02:25.850,0:02:30.480 until the late '90s, early 2000 that I dove 0:02:30.480,0:02:32.510 into computer programming as something that[br]I was going 0:02:32.510,0:02:32.780 to do. 0:02:32.780,0:02:34.120 I had a lot of friends who were doing 0:02:34.120,0:02:37.750 it. I knew a lot of programmers. But somehow 0:02:37.750,0:02:41.860 it, it sort of never, never caught on. Before 0:02:41.860,0:02:44.380 I started writing software that I needed for[br]myself, 0:02:44.380,0:02:47.190 and before I found sort of a place in 0:02:47.190,0:02:49.730 the software world for that to happen. 0:02:49.730,0:02:53.220 And the reason I, I say that is, is 0:02:53.220,0:02:56.080 I've seen a number of essays of like, what 0:02:56.080,0:02:58.300 is a true hacker, and, and as a true 0:02:58.300,0:03:01.640 hacker, one of the things that keeps being[br]thrown 0:03:01.640,0:03:03.530 out is those ten years, right. You should[br]have 0:03:03.530,0:03:05.450 been programming for ten years already, 0:03:05.450,0:03:07.150 otherwise you're way behind. 0:03:07.150,0:03:11.740 Well, I learned to program about three years[br]before 0:03:11.740,0:03:17.300 I released Ruby on Rails. Turned out fine. 0:03:17.300,0:03:23.150 And I don't say that as, like, it was 0:03:23.150,0:03:24.960 because I grew up on a farm and didn't 0:03:24.960,0:03:30.820 know what a computer was. This is me in, 0:03:30.820,0:03:33.760 in the center there with the stick, and the 0:03:33.760,0:03:39.010 blue shirt in 1985. These are the kids that 0:03:39.010,0:03:41.200 were living in my neighborhood. 0:03:41.200,0:03:43.560 In 1985 I got introduced to my, my first 0:03:43.560,0:03:49.680 computer. And I was about five years old.[br]And 0:03:49.680,0:03:54.210 I got introduced to computers through gaming.[br]Sort of, 0:03:54.210,0:03:56.940 we were playing ninjas in the streets around[br]our 0:03:56.940,0:04:02.270 houses, and then we'd play ninjas on the box. 0:04:02.270,0:04:03.790 And I found it fascinating right from the[br]get 0:04:03.790,0:04:06.200 go, right. Computers were really 0:04:06.200,0:04:08.070 fascinating and games really 0:04:08.070,0:04:12.480 captured my imagination early on. I remember,[br]at, at 0:04:12.480,0:04:14.500 that time, there were certain, lots of parents[br]were 0:04:14.500,0:04:15.860 like, well make sure you get out and play 0:04:15.860,0:04:18.228 a lot. Because you don't want to spend your, 0:04:18.228,0:04:19.418 or wasting your time, that was the, that was 0:04:19.418,0:04:22.220 the word, wasting your time in front of computers 0:04:22.220,0:04:23.340 inside, right. 0:04:23.340,0:04:25.720 Well, I really did want to waste my time 0:04:25.720,0:04:27.949 in front of computers. And this was the computer 0:04:27.949,0:04:34.470 to have in 1985, in our neighborhood. But[br]we 0:04:34.470,0:04:36.419 couldn't afford a computer like that. There[br]was only 0:04:36.419,0:04:37.840 one guy in the whole neighborhood that had[br]a 0:04:37.840,0:04:39.409 computer like that. So we all shared it and 0:04:39.409,0:04:43.330 we all played Yeah, Kung Fu, in turn. 0:04:43.330,0:04:47.999 But then the next year, so, I, I couldn't 0:04:47.999,0:04:52.400 afford this computer, but my dad somehow,[br]he was 0:04:52.400,0:04:56.550 fixing TVs and stereos, he traded a stereo[br]with 0:04:56.550,0:05:00.030 this guy for this other weird computer, which[br]was 0:05:00.030,0:05:04.139 an Abstraught 646. 0:05:04.139,0:05:06.419 And I was really excited. It didn't actually[br]play 0:05:06.419,0:05:08.300 Yeah, Kung Fu. I was a little disappointed[br]by 0:05:08.300,0:05:10.689 that, but it had some other crappier games.[br]Anyway, 0:05:10.689,0:05:12.569 it was a computer. And that was sort of 0:05:12.569,0:05:15.210 my first introduction to, to computers, six[br]years old. 0:05:15.210,0:05:17.550 And, and I tried to learn programming. 0:05:17.550,0:05:20.840 I, I got a magazine and, at the back 0:05:20.840,0:05:22.689 of these magazines back then, there were programs[br]you 0:05:22.689,0:05:24.960 could type in. And I was like, wow, this 0:05:24.960,0:05:27.050 is, this is amazing. I can control this computer. 0:05:27.050,0:05:31.249 So I built my first information technology[br]system. 0:05:31.249,0:05:36.539 It was messages to my mom of where I 0:05:36.539,0:05:38.300 went, where, I had this clever system that[br]would 0:05:38.300,0:05:41.460 really optimize the fact that writing a message[br]of 0:05:41.460,0:05:43.180 where I went and, and when I was going 0:05:43.180,0:05:45.080 to be home, it was too complicated. It would 0:05:45.080,0:05:46.840 be much easier if I just wrote a little 0:05:46.840,0:05:49.729 note where I gave her the location on the 0:05:49.729,0:05:52.419 tape that she had to fast forward to, and 0:05:52.419,0:05:54.370 then she could read where I was. 0:05:54.370,0:05:56.509 I thought, man this is so clever. I just 0:05:56.509,0:05:59.050 have to write down two twenty-eight, and then[br]I 0:05:59.050,0:06:01.259 could preprogram that note, and she'll never[br]know I 0:06:01.259,0:06:07.409 was over at Peter's house playing Yeah, Kung[br]Fu. 0:06:07.409,0:06:10.360 That really wasn't programming, right. I just[br]typed some 0:06:10.360,0:06:12.069 stuff in. I didn't know what the hell I 0:06:12.069,0:06:14.919 was doing. I just somehow figured out print,[br]OK, 0:06:14.919,0:06:16.809 that puts stuff up on the screen. That was, 0:06:16.809,0:06:18.259 that was the extent of it, right. But it 0:06:18.259,0:06:20.849 was my first stab at programming. And I, and 0:06:20.849,0:06:22.819 I, it kind of failed. 0:06:22.819,0:06:25.309 That was the extent of my programming, that[br]I 0:06:25.309,0:06:28.719 knew how to fast-forward to a pre-recorded[br]message. 0:06:28.719,0:06:31.360 Not that great. 0:06:31.360,0:06:36.069 So a couple years later, late 80s, I saw 0:06:36.069,0:06:39.229 this game for the first time. Battle Squadrant.[br]And 0:06:39.229,0:06:43.499 I remember thinking, holy shit, these graphics[br]are amazing. 0:06:43.499,0:06:47.050 How can they make this? This looks so good, 0:06:47.050,0:06:50.629 when you were used to a Commodore 64, the 0:06:50.629,0:06:53.800 graphics of the Amiga 500, which is mind blowing, 0:06:53.800,0:06:56.529 right. And once again, I felt this, like,[br]wow, 0:06:56.529,0:06:58.620 wouldn't it be amazing to be part of that? 0:06:58.620,0:07:00.719 To be able to create something like that? 0:07:00.719,0:07:03.050 I'd love to make games. 0:07:03.050,0:07:06.240 So I sort of started looking around, and,[br]and 0:07:06.240,0:07:08.389 I found this thing called Amus. I don't know, 0:07:08.389,0:07:12.659 has anybody here ever programmed in Amus?[br]Not a 0:07:12.659,0:07:16.430 single hand. OK. Must have been a very European 0:07:16.430,0:07:16.849 thing. 0:07:16.849,0:07:18.900 But it was sort of a real programming environment, 0:07:18.900,0:07:21.800 and, and I got the box, and sort of 0:07:21.800,0:07:23.990 my English was a little, not that great, so 0:07:23.990,0:07:25.889 I was sort of just reading through it and 0:07:25.889,0:07:27.309 trying to find the code. And it was all 0:07:27.309,0:07:30.930 about sprites and vectors and ifs and variables,[br]and 0:07:30.930,0:07:32.569 it, it didn't make any sense to me at 0:07:32.569,0:07:32.809 all. 0:07:32.809,0:07:34.779 So I thought, eh this is a little bit 0:07:34.779,0:07:37.550 too hard. Thankfully, there was something[br]called Easy Amos, 0:07:37.550,0:07:40.589 right. Oh, wow, that's gonna be great. This[br]other 0:07:40.589,0:07:42.009 one was too hard. Now I just have to 0:07:42.009,0:07:43.430 do the easy one. 0:07:43.430,0:07:46.939 Unfortunately, in Easy Amos, it was still[br]programming, and 0:07:46.939,0:07:49.330 it still had conditionals and variables and[br]all these 0:07:49.330,0:07:52.099 other things I just did not understand. I,[br]it's 0:07:52.099,0:07:55.099 so funny, because, once you learn something,[br]it can 0:07:55.099,0:07:56.749 sometimes be hard to go back and think, like, 0:07:56.749,0:07:58.339 how was it before I knew how to do 0:07:58.339,0:08:02.129 this? But I distinctly remember, why would[br]you have 0:08:02.129,0:08:03.129 a variable? 0:08:03.129,0:08:05.139 Like, if you just assign something once, why[br]would 0:08:05.139,0:08:06.699 you ever sort of want to change that? Why 0:08:06.699,0:08:08.279 does it have to be a space. Why can't 0:08:08.279,0:08:09.539 it just be the thing. Like, I did not 0:08:09.539,0:08:11.849 get the concept of variables. 0:08:11.849,0:08:14.539 And this is at, I don't know, age ten 0:08:14.539,0:08:17.599 or whatever. So, still not getting programming.[br]It's still 0:08:17.599,0:08:21.860 not making any sense to me. So I gave 0:08:21.860,0:08:24.509 up on that, too. 0:08:24.509,0:08:28.659 Then, in 1993, I went to something called[br]the 0:08:28.659,0:08:32.799 Gathering. The Gathering three, which was[br]a big demo 0:08:32.799,0:08:37.339 party in Denmark, where people from all over[br]Europe, 0:08:37.339,0:08:39.419 maybe some from the U.S. as well, would gather 0:08:39.419,0:08:42.289 to, to show off their skills of creating these 0:08:42.289,0:08:43.190 demos. 0:08:43.190,0:08:46.990 And demos were basically just, like, little[br]music videos 0:08:46.990,0:08:49.670 with computer graphics. And I thought that[br]was really 0:08:49.670,0:08:52.680 awesome. And, again, I got this sensation[br]of, wow, 0:08:52.680,0:08:56.040 that's amazing. People are creating these[br]sequences, they look 0:08:56.040,0:08:58.430 really good. This is, this is awesome. I'd[br]love 0:08:58.430,0:08:59.540 to be a part of that. 0:08:59.540,0:09:03.040 This is '93, so I'm, I'm fourteen. And this 0:09:03.040,0:09:06.120 demo party, and then I met pretty much everybody 0:09:06.120,0:09:08.600 I knew for the next ten years in, in 0:09:08.600,0:09:12.850 computer software, including Allen of TextMate[br]fame. I was 0:09:12.850,0:09:14.170 fourteen and he was part of one of these 0:09:14.170,0:09:18.370 demo groups, and we got talking, and then[br]ten 0:09:18.370,0:09:22.829 years later, I'd help him release Textmate,[br]and this 0:09:22.829,0:09:24.639 is now twenty years ago. 0:09:24.639,0:09:25.810 Anyway. 0:09:25.810,0:09:27.709 I still didn't get the concept, right. Like,[br]it 0:09:27.709,0:09:29.949 was all, it was Assembler. So it was even 0:09:29.949,0:09:35.050 harder and weirder to figure out than Amos[br]was. 0:09:35.050,0:09:37.269 It was vectors, it was math, it was, it 0:09:37.269,0:09:40.720 was just really hard. So once again, this[br]is 0:09:40.720,0:09:43.509 the third time I tried to sort of figure 0:09:43.509,0:09:45.620 out programming, because I want to build stuff. 0:09:45.620,0:09:49.630 And the third time, it failed. 0:09:49.630,0:09:52.000 So I ended up building another information[br]system. At 0:09:52.000,0:09:57.310 that time, there's something called BBS's.[br]So pre-internet, you 0:09:57.310,0:10:01.040 dialed up to basically every web site individually[br]through 0:10:01.040,0:10:04.360 a modem, and I ran one of those things. 0:10:04.360,0:10:05.790 At that time, it was, it was called a 0:10:05.790,0:10:08.420 Where's BBS, which is where we traded all[br]the 0:10:08.420,0:10:11.620 illegal software that we couldn't afford,[br]and games, and 0:10:11.620,0:10:11.970 demos. 0:10:11.970,0:10:14.100 And I had a lot of fun doing that. 0:10:14.100,0:10:16.480 I was fifteen and I was, I was working 0:10:16.480,0:10:18.269 at a grocery store, and I spent all my 0:10:18.269,0:10:22.839 money buying modems and phone lines. 0:10:22.839,0:10:27.259 But sort of the long and the short of 0:10:27.259,0:10:30.910 that is that I failed to identify with programming 0:10:30.910,0:10:33.779 under the computer-science paradigm. 0:10:33.779,0:10:37.089 Computer science, in itself, just didn't really[br]appeal to 0:10:37.089,0:10:40.389 me. Like, it didn't make sense to me. Learning 0:10:40.389,0:10:44.860 programming through sort of the lens, the[br]prism of, 0:10:44.860,0:10:49.220 of hard science just, it didn't really, it[br]just 0:10:49.220,0:10:52.800 didn't click. And I was actually pretty disappointed[br]for 0:10:52.800,0:10:55.370 awhile. I had tried to learn programming three[br]or 0:10:55.370,0:10:58.060 four times over the past ten years of my, 0:10:58.060,0:11:02.970 my life, and it just, it wasn't clicking. 0:11:02.970,0:11:07.529 No surprise to sort of my teachers. This is 0:11:07.529,0:11:10.720 my high school diploma, part of it, and it 0:11:10.720,0:11:16.300 says math, final exam, F. And, and English,[br]I 0:11:16.300,0:11:19.920 got an A. But math was just never my 0:11:19.920,0:11:21.910 thing. Physics never, was never my thing. 0:11:21.910,0:11:24.779 Any of the hard sciences were just never my 0:11:24.779,0:11:27.339 thing. And you say, oh, well that explains[br]a 0:11:27.339,0:11:29.779 lot. That's why Rails is so fucking slow. 0:11:29.779,0:11:34.690 But it, it's true. It just never appealed[br]to 0:11:34.690,0:11:39.149 me. But, I think it also inoculated me with 0:11:39.149,0:11:42.110 something really early on, which was, it disabused[br]me 0:11:42.110,0:11:44.620 of the thinking that I was a computer scientist. 0:11:44.620,0:11:46.529 That I was ever going to come up with 0:11:46.529,0:11:50.000 an algorithm. That I was ever going to make 0:11:50.000,0:11:55.199 any ground-breaking discoveries at the low-level[br]of, of computer 0:11:55.199,0:11:57.160 science. 0:11:57.160,0:11:59.920 And that was actually really a relief. Because[br]when 0:11:59.920,0:12:03.000 I finally got into programming, I knew that[br]was 0:12:03.000,0:12:04.209 just not what I was going to do with 0:12:04.209,0:12:06.819 it. That was never, it wasn't my idol, it 0:12:06.819,0:12:09.810 was not what I was chasing. I wanted to 0:12:09.810,0:12:12.509 build information systems. Like all these[br]attempts I had 0:12:12.509,0:12:15.029 over the years, they were all about information[br]systems. 0:12:15.029,0:12:18.069 They were about using the computer to build[br]something 0:12:18.069,0:12:20.220 else that really didn't have much to do with 0:12:20.220,0:12:24.560 the underlying things. That there were people,[br]smart people, 0:12:24.560,0:12:27.079 who had come up with algorithms underneath[br]to, to 0:12:27.079,0:12:30.699 make it all work, wonderful. I'm not one of 0:12:30.699,0:12:31.129 them. 0:12:31.129,0:12:33.170 And that's fine. 0:12:33.170,0:12:39.060 I think as an industry, very few people have 0:12:39.060,0:12:42.389 gotten to that realization. Even if it is,[br]that 0:12:42.389,0:12:45.779 they, on a daily basis, build information[br]systems. Even 0:12:45.779,0:12:48.300 if it is that they're working on yet another 0:12:48.300,0:12:52.129 social network for sock puppets, or horror,[br]in my 0:12:52.129,0:12:57.360 case, yet another fucking to-do list. The[br]aspiration of 0:12:57.360,0:12:59.550 the whole industry, everyone in it, is that[br]we're 0:12:59.550,0:13:01.379 all programmers. 0:13:01.379,0:13:02.339 Right? 0:13:02.339,0:13:09.339 No we're not. I am nothing like Linus, right. 0:13:09.670,0:13:12.410 He's actually a real computer scientist. To[br]figure out 0:13:12.410,0:13:14.560 how to, I don't know, fucking improve the[br]scheduler 0:13:14.560,0:13:20.819 in the kernel. Shew. No clue. No interest.[br]All 0:13:20.819,0:13:21.569 good. 0:13:21.569,0:13:25.220 I am ever in debt that there are people 0:13:25.220,0:13:28.610 like that out there who can do this stuff. 0:13:28.610,0:13:30.149 So I don't have to do it. So I 0:13:30.149,0:13:33.980 can focus on something else. But I think most 0:13:33.980,0:13:36.540 programmers think that, oh yeah, that, that's[br]what I 0:13:36.540,0:13:39.899 do. Yeah, I work information systems, but,[br]we're kind 0:13:39.899,0:13:42.290 of colleagues, right? Me and Linus here. 0:13:42.290,0:13:45.720 I'm pretty sure that he would tell you, fuck 0:13:45.720,0:13:49.480 you. We're nothing alike. We are not colleagues.[br]What 0:13:49.480,0:13:52.620 you do is making another fucking to do list. 0:13:52.620,0:13:57.410 I'm improving the fucking kernel of Linux.[br]Far more 0:13:57.410,0:14:00.620 important work. He would disabuse you of your[br]delusions 0:14:00.620,0:14:06.600 of grandeur real quick. 0:14:06.600,0:14:08.360 And I think that's a real shame. I think 0:14:08.360,0:14:12.350 it's a real shame that if you sort of 0:14:12.350,0:14:15.970 pick your heroes in such a impossible fashion,[br]that 0:14:15.970,0:14:17.850 they're actually nothing like you and you[br]will be 0:14:17.850,0:14:20.050 nothing like them, you're gonna set yourself[br]up for 0:14:20.050,0:14:22.189 a bad time for the whole ride. 0:14:22.189,0:14:27.389 The truth of the matter is that most information 0:14:27.389,0:14:31.550 system development has very little to do with[br]science. 0:14:31.550,0:14:35.439 Yes, it's all built on top of computer science. 0:14:35.439,0:14:38.329 Yes, computer science is what makes it possible[br]for 0:14:38.329,0:14:40.730 us to do what it is that we do. 0:14:40.730,0:14:44.610 But it doesn't define what we do. 0:14:44.610,0:14:46.699 And I think in many ways that prism of 0:14:46.699,0:14:50.850 computer science is harmful to the development[br]of information 0:14:50.850,0:14:55.000 systems. It's actually not a good view on[br]the 0:14:55.000,0:14:59.089 world to have. Just because you can make,[br]you're 0:14:59.089,0:15:00.610 Steingraeber and Sohne, and you can make the[br]best 0:15:00.610,0:15:02.610 piano in the world, that doesn't make you[br]a 0:15:02.610,0:15:05.579 great pianist. It doesn't mean you can play[br]wonderful 0:15:05.579,0:15:08.529 tunes. Just because you can create the foundations[br]of 0:15:08.529,0:15:12.480 which other people can build upon, just because[br]you're 0:15:12.480,0:15:15.800 a great computer scientist, doesn't mean you're[br]a great 0:15:15.800,0:15:18.360 software writer. 0:15:18.360,0:15:22.300 Doesn't mean you're a great programmer of[br]information systems. 0:15:22.300,0:15:25.519 And most of all, if you are committed to 0:15:25.519,0:15:28.129 building information systems, and I am wholly[br]committed to 0:15:28.129,0:15:30.910 building information systems, I've given up[br]the notion, long 0:15:30.910,0:15:33.399 ago, that I was going to get into games 0:15:33.399,0:15:37.149 programming or vector programming or anything[br]else that sounds 0:15:37.149,0:15:41.139 like hard science and is hard. 0:15:41.139,0:15:42.639 I think you're gonna be much better off. But 0:15:42.639,0:15:45.389 I think it's also really tough, because I[br]think 0:15:45.389,0:15:49.160 most of the paths, the celebrated paths into[br]programming 0:15:49.160,0:15:53.009 go through courses called computer science.[br]So you're sort 0:15:53.009,0:15:56.079 of taught right from the get go that computer 0:15:56.079,0:16:00.189 science, like that is the ultimate ideal,[br]and what 0:16:00.189,0:16:02.379 you're doing here is just sort of piddling[br]along 0:16:02.379,0:16:05.300 until you can get to this top of the 0:16:05.300,0:16:06.620 mountain. 0:16:06.620,0:16:08.360 Even worse, if you actually have a degree[br]in 0:16:08.360,0:16:13.749 computer science, right, and now you're slumming[br]it, with 0:16:13.749,0:16:16.439 yet another social network, or, yet another[br]fucking to-do 0:16:16.439,0:16:19.649 list. I mean, that's a recipe for self-loathing[br]if 0:16:19.649,0:16:21.749 I ever knew one. 0:16:21.749,0:16:24.589 But, as I say, this is mostly about the 0:16:24.589,0:16:27.240 prism of how you're looking at programming,[br]what is 0:16:27.240,0:16:30.480 programming, what is writing software. What[br]is that we 0:16:30.480,0:16:34.610 do every day when we create information systems? 0:16:34.610,0:16:36.519 And if you look at it from this prism 0:16:36.519,0:16:41.459 of the hard sciences, you think, well, Law[br]of 0:16:41.459,0:16:45.310 Thermodynamics. Physics. This is, this is[br]the real serious 0:16:45.310,0:16:48.800 hard stuff, right. You will laugh at French[br]poetry. 0:16:48.800,0:16:51.899 Ha, ha, ha, ha! They're all just, what, analyzing 0:16:51.899,0:16:54.889 what some schmuck in the 1700s did, and there's 0:16:54.889,0:16:58.249 a thousand different interpretations of, of[br]what that person 0:16:58.249,0:17:00.819 actually wrote and what does that actually[br]mean? Like, 0:17:00.819,0:17:04.490 that's pathetic, right. You can't arrive at[br]any ultimate, 0:17:04.490,0:17:06.430 clear, universal truths. 0:17:06.430,0:17:11.339 Math! There's a truth. There's a final result.[br]Physics. 0:17:11.339,0:17:14.119 There's a truth. We're knowing more about[br]the natural 0:17:14.119,0:17:18.500 world in a way where we can be completely 0:17:18.500,0:17:22.900 confident. Mostly. In what we know. Certainly[br]in math, 0:17:22.900,0:17:23.380 right. 0:17:23.380,0:17:28.539 If you carry that over into programming, you[br]end 0:17:28.539,0:17:35.100 up with shit like this. Law of Demeter. Practices 0:17:35.100,0:17:40.860 and principles who sort of project that they're[br]universal 0:17:40.860,0:17:44.590 truths about the natural world, that this[br]is how 0:17:44.590,0:17:47.159 good programs are made, and this is not really 0:17:47.159,0:17:50.320 an argument. The only argument is whether[br]you're professional 0:17:50.320,0:17:53.370 and following the laws, or you're an amateur[br]and 0:17:53.370,0:17:58.070 you're breaking them. 0:17:58.070,0:17:59.990 When I look at computer programming, and when[br]I 0:17:59.990,0:18:04.000 reach most, read most programs, I'm not reading[br]hard 0:18:04.000,0:18:07.470 sciences. It is much more like studying 17th[br]century 0:18:07.470,0:18:10.020 French poetry. What the fuck did this guy[br]mean? 0:18:10.020,0:18:13.210 Like, I can't follow this at all. Like, is 0:18:13.210,0:18:16.909 this some weird reference to some play somewhere?[br]What's 0:18:16.909,0:18:18.090 going on here? 0:18:18.090,0:18:20.950 It's actually more like forensics. It's more[br]like analysis. 0:18:20.950,0:18:24.010 It's much more subjective. Like, what is actually[br]going 0:18:24.010,0:18:27.650 on? What were they trying to communicate?[br]What's just 0:18:27.650,0:18:29.840 going on here, right? 0:18:29.840,0:18:32.860 So, I find it so funny that, that programmers 0:18:32.860,0:18:37.380 who work in programming, and they laugh at[br]all 0:18:37.380,0:18:40.960 these subjective fields of endeavor, when[br]that is what 0:18:40.960,0:18:44.570 they do every day. They just, no, what I'm 0:18:44.570,0:18:48.580 doing is computer science. This is empirical[br]truth, blah, 0:18:48.580,0:18:52.110 blah, blah, we have laws, blah, blah, blah. 0:18:52.110,0:18:54.190 I think the, the bottom line is that is 0:18:54.190,0:18:55.799 when you go in with that notion, when you 0:18:55.799,0:18:57.549 go in with the notion that we can actually 0:18:57.549,0:19:02.120 discover laws of programming, like, Law of[br]Demeter, of 0:19:02.120,0:19:04.620 how we should be creating our programs, you[br]lull 0:19:04.620,0:19:10.200 yourself into this belief that there are some[br]practices 0:19:10.200,0:19:13.200 that are just true. They're not up for debate. 0:19:13.200,0:19:15.210 They're not up for discussion. 0:19:15.210,0:19:19.890 They're science. That what we do is science.[br]Well, 0:19:19.890,0:19:22.230 I think there's another word for, sort of,[br]those 0:19:22.230,0:19:29.230 delusions. Pseudoscience. When people think[br]they're doing science and 0:19:30.159,0:19:34.460 they're not actually doing science. That's[br]pseudoscience. I think 0:19:34.460,0:19:38.380 a lot of what's going on in software, methodology, 0:19:38.380,0:19:41.610 practices, is pseudoscience. 0:19:41.610,0:19:43.640 Which would be fine if people would accept[br]that 0:19:43.640,0:19:46.190 and say, yes, what I'm doing is pseudo science. 0:19:46.190,0:19:48.520 Like, I'm not finding any grand truths here,[br]but 0:19:48.520,0:19:51.690 they're not, right. They're ex-pouting that[br]this is, this 0:19:51.690,0:19:52.640 is the truth. 0:19:52.640,0:19:59.640 Well, here's another pseudoscience. Diet schemes.[br]I think diets 0:20:00.270,0:20:06.429 are actually incredibly similar to most software[br]methodology approaches. 0:20:06.429,0:20:10.900 They all sort of espouse that I have the 0:20:10.900,0:20:13.610 truth, what you need to get slim and healthy 0:20:13.610,0:20:17.210 is the ten-day green smoothie cleanse. 0:20:17.210,0:20:18.539 That is the truth. That's how you get it, 0:20:18.539,0:20:22.210 right. And then you, shit, that, that's, OK,[br]smoothies. 0:20:22.210,0:20:25.340 Sounds good. But what about this super shred[br]diet? 0:20:25.340,0:20:28.260 Like, I lose twenty pounds in four weeks?[br]That's 0:20:28.260,0:20:30.640 certainly better than ten pounds in, I don't[br]know, 0:20:30.640,0:20:33.279 ten weeks, or whatever that hungry diet girl[br]is 0:20:33.279,0:20:35.820 promising. I'll go with that super shred guy,[br]like 0:20:35.820,0:20:37.970 he's got to have the truth, right. 0:20:37.970,0:20:40.620 And it's so funny, if you read any diet 0:20:40.620,0:20:42.289 books, and diet books are incredibly popular.[br]If you 0:20:42.289,0:20:44.270 look at the most popular book on Amazon, the 0:20:44.270,0:20:46.270 top one hundred list, a lot of them are 0:20:46.270,0:20:50.529 diet books. People want to be told how they 0:20:50.529,0:20:53.899 can cheat the basics. I think software development[br]is 0:20:53.899,0:20:55.529 exactly like that. 0:20:55.529,0:20:58.779 I think software developers are exactly like[br]people trying 0:20:58.779,0:21:03.870 to lose ten pounds and thinking, you know[br]what, 0:21:03.870,0:21:07.210 all this exercising, just eating healthier,[br]that's a little 0:21:07.210,0:21:09.330 too hard. Let's, let's listen to this super[br]shred 0:21:09.330,0:21:09.960 guy. 0:21:09.960,0:21:11.600 He's got to have the answer. An answer that's 0:21:11.600,0:21:16.649 less painful, less simple and basic. There's[br]got to 0:21:16.649,0:21:19.370 be some grand secret I just don't know yet. 0:21:19.370,0:21:21.909 If I can just learn the secret then everything's 0:21:21.909,0:21:25.159 gonna be great, right. But it's pseudoscience.[br]Those diets 0:21:25.159,0:21:31.260 are based on anecdotes. They're based on one[br]guy 0:21:31.260,0:21:33.360 trying something, or, or looking at a few[br]people, 0:21:33.360,0:21:37.980 a tiny sample size, it's just pure, poor,[br]pure 0:21:37.980,0:21:39.860 poor science. 0:21:39.860,0:21:44.049 External variables, uncontrolled experiments[br]that run for too long. 0:21:44.049,0:21:46.480 You can't derive any absolute truths from[br]it. But 0:21:46.480,0:21:51.860 people keep arriving at absolute truths. 0:21:51.860,0:21:55.909 And just like feeling a little overweight,[br]and most 0:21:55.909,0:21:58.070 people do at some point in their life. Everybody 0:21:58.070,0:22:00.179 wants to lose whatever it is. They want to 0:22:00.179,0:22:02.080 feel healthier even if they are at the correct 0:22:02.080,0:22:04.549 weight. They want to be in better shape. All 0:22:04.549,0:22:07.230 our code bases are exactly like that. 0:22:07.230,0:22:09.090 Everyone has like, oh I'd love that this part 0:22:09.090,0:22:11.230 of the code base, it's not that clean, right. 0:22:11.230,0:22:13.779 So we have that same feeling of being a 0:22:13.779,0:22:19.220 little insecure about our quote code quality,[br]just like 0:22:19.220,0:22:21.510 most people are a little insecure, at least[br]at 0:22:21.510,0:22:25.279 certain times in their life, about their body,[br]right. 0:22:25.279,0:22:27.789 So we're ripe for somebody to come in and 0:22:27.789,0:22:32.260 tell us what's wrong. To fix it for us 0:22:32.260,0:22:34.100 by just saying, oh, no, no, no, you don't 0:22:34.100,0:22:35.960 have to do any of the hard stuff. Writing 0:22:35.960,0:22:37.320 good code, do you know what that's about?[br]It's 0:22:37.320,0:22:40.970 about this one practice. This one secret that[br]they 0:22:40.970,0:22:42.750 don't want you to know. 0:22:42.750,0:22:45.880 If I teach you that, then all your code 0:22:45.880,0:22:48.679 is going to be wonderful. But right now, you're 0:22:48.679,0:22:52.360 not a professional. You're an amateur. You're[br]writing dirty 0:22:52.360,0:22:56.429 code. You should feel really bad about that.[br]You 0:22:56.429,0:22:58.039 have sinned. 0:22:58.039,0:23:02.149 But, I will give you absolution. I have the 0:23:02.149,0:23:06.059 pathway to clean code. 0:23:06.059,0:23:10.850 And it hits a lot of people right in 0:23:10.850,0:23:14.830 the impostor plexus. Like, ugh, you're saying[br]my code 0:23:14.830,0:23:17.020 is dirty? Yeah, I guess it is a little 0:23:17.020,0:23:19.710 dirty. There's this one part that's, like,[br]shit, maybe 0:23:19.710,0:23:22.789 I'm not really a computer scientist. Maybe[br]it doesn't 0:23:22.789,0:23:26.690 really, I don't really belong here amongst[br]the programmers. 0:23:26.690,0:23:28.710 Can you please tell me, how do I get 0:23:28.710,0:23:32.270 to be a computer scientist? 0:23:32.270,0:23:36.600 How can I get to belong amongst the esteemed 0:23:36.600,0:23:41.059 professional programmers? Can you tell me[br]how? And there 0:23:41.059,0:23:44.090 are lots of people willing to tell you how. 0:23:44.090,0:23:46.679 That the salvation will come through these[br]patterns and 0:23:46.679,0:23:49.159 practices, and as long as you follow these[br]ten 0:23:49.159,0:23:54.659 commandments of good code, all shall be well. 0:23:54.659,0:23:56.990 OK. 0:23:56.990,0:24:00.450 I think the most popular commandment, I'm[br]gonna spend 0:24:00.450,0:24:02.950 some time on that, the most popular practice,[br]the 0:24:02.950,0:24:06.570 most popular pattern for making people feel[br]shitty about 0:24:06.570,0:24:09.049 their code and shitty about themselves and[br]shitty about 0:24:09.049,0:24:16.049 their path through programming, is TDD. 0:24:17.960,0:24:23.370 TDD is the most successful software diet of[br]all 0:24:23.370,0:24:30.370 times. It's so alluring, it has such an appeal 0:24:31.380,0:24:34.679 in its basic principles, that everyone gets[br]wrapped up 0:24:34.679,0:24:37.100 in it. I got wrapped up in it for 0:24:37.100,0:24:41.860 quite awhile. I got wrapped up in the storytelling 0:24:41.860,0:24:47.149 that all software before TDD was shit and[br]unprofessional. 0:24:47.149,0:24:49.039 And that the only way to arrive at clean 0:24:49.039,0:24:54.269 code was to follow the principles of TDD. 0:24:54.269,0:24:57.190 And the principles of TDD, mind you, are not 0:24:57.190,0:25:02.130 about the tests. It's about test first. It's[br]about 0:25:02.130,0:25:07.370 test-driven design, right. That we have tests[br]afterwards, that's 0:25:07.370,0:25:12.760 just an accidental side-effect. A benefit,[br]if you will, 0:25:12.760,0:25:15.179 after the fact. And it's the perfect diet. 0:25:15.179,0:25:20.080 I tried multiple times, which is usually how[br]it 0:25:20.080,0:25:22.269 goes with diets, we try one and it doesn't 0:25:22.269,0:25:25.110 really work and we fall off the wagon and 0:25:25.110,0:25:26.610 then a few months later you try again and 0:25:26.610,0:25:28.190 you feel bad about it the whole time and 0:25:28.190,0:25:29.419 that's how I felt about TDD for a long 0:25:29.419,0:25:29.740 time. 0:25:29.740,0:25:32.169 I felt like TDD was what I was supposed 0:25:32.169,0:25:34.809 to do. I was supposed to write all my 0:25:34.809,0:25:37.669 tests first, and then I would be allowed to 0:25:37.669,0:25:42.279 write my code. And it just didn't work. I 0:25:42.279,0:25:45.059 kept just feeling like, this is not, I'm not 0:25:45.059,0:25:48.340 arriving at something better here. When I'm[br]driving my 0:25:48.340,0:25:51.510 design by writing my tests first, the code[br]I 0:25:51.510,0:25:55.809 look at afterwards, it's not better. It's[br]not cleaner. 0:25:55.809,0:26:00.500 The dirty code I wrote without being test-driven[br]first, 0:26:00.500,0:26:02.390 it actually looks better. 0:26:02.390,0:26:06.519 But, so successful has TDD been, that for[br]the 0:26:06.519,0:26:09.919 longest time, until actually fairly recently,[br]I just thought, 0:26:09.919,0:26:12.070 well, I'm the wrong-doer. I'm the one doing[br]it 0:26:12.070,0:26:16.399 wrong. TDD is not at fault, right. Just because 0:26:16.399,0:26:19.190 everybody's doing TDD wrong, doesn't mean[br]that there's anything 0:26:19.190,0:26:21.710 wrong with TDD. There's just something wrong[br]with all 0:26:21.710,0:26:23.890 of you. That's the problem. 0:26:23.890,0:26:26.399 If you would just be more faithful to the 0:26:26.399,0:26:28.730 practices, then everything would be great. 0:26:28.730,0:26:31.100 And that's what makes it such a great diet. 0:26:31.100,0:26:33.500 That it keeps people in the perpetual state[br]of 0:26:33.500,0:26:37.659 feeling inadequate. So, you keep having to[br]buy more 0:26:37.659,0:26:42.519 books, and attend more conference talks, and[br]attend more 0:26:42.519,0:26:44.940 workshops, and hire more consultants, to teach[br]you to 0:26:44.940,0:26:50.909 be truer to the religion of TDD. Hogwash. 0:26:50.909,0:26:54.380 Let's look at some code. So here's a very 0:26:54.380,0:26:58.570 simple piece of code. Person has an age method, 0:26:58.570,0:27:01.570 that calculates how old somebody is. And we[br]have 0:27:01.570,0:27:04.880 a test for it. This piece of code depends 0:27:04.880,0:27:06.220 on the world. 0:27:06.220,0:27:11.110 It directly refers to date today. It's a explicit 0:27:11.110,0:27:13.649 dependency. You cannot change it in there.[br]Well, in 0:27:13.649,0:27:15.750 a lot of languages, that's a problem. Like,[br]how 0:27:15.750,0:27:17.679 are you actually going to test this if you 0:27:17.679,0:27:19.419 can't somehow figure out how to change the[br]date 0:27:19.419,0:27:21.470 of today. Like, every time you run your test 0:27:21.470,0:27:23.490 it might be a different day and it might 0:27:23.490,0:27:24.279 be broken. 0:27:24.279,0:27:27.019 Well, in Ruby it's really easy. We just stop 0:27:27.019,0:27:29.059 that constant and make it work. That's what[br]the 0:27:29.059,0:27:32.000 travel-to method is about, right. 0:27:32.000,0:27:34.299 Proponents of TDD will look at that code and 0:27:34.299,0:27:41.299 say, dirty, dirty code. Explicit dependencies[br]hidden inside. You're 0:27:41.360,0:27:44.980 mocking a global object? What the fuck? 0:27:44.980,0:27:48.360 You need to shape up. Here's the shaped up 0:27:48.360,0:27:52.029 version. We inject our dependency, so we have[br]a 0:27:52.029,0:27:55.490 default of date.today, but we can put in our 0:27:55.490,0:27:57.600 own, in the test, we can put in our 0:27:57.600,0:28:00.870 own date, right. This is much cleaner. Right.[br]No. 0:28:00.870,0:28:03.779 Great. We improved our code base. 0:28:03.779,0:28:07.610 Did we? Is this a better code base? Is 0:28:07.610,0:28:10.720 this method better than what we just had there? 0:28:10.720,0:28:13.720 Is it simpler? Is it clearer? No. It's easier 0:28:13.720,0:28:18.029 to test. And that's the important point, right.[br]That's 0:28:18.029,0:28:19.549 the important point in all of these debates,[br]is 0:28:19.549,0:28:21.519 just, is it easier to test? 0:28:21.519,0:28:23.559 That's the measure of success. I think that's[br]a 0:28:23.559,0:28:26.419 shitty measure of success. I think there are[br]much 0:28:26.419,0:28:29.769 higher ideals than just whether something[br]is easy to 0:28:29.769,0:28:34.169 test. But it gets worse. 0:28:34.169,0:28:36.159 Here's another example. If you actually have[br]a method 0:28:36.159,0:28:39.169 that depends on another method, we have to[br]inject 0:28:39.169,0:28:41.500 the dependency all the way down, now you're[br]really 0:28:41.500,0:28:43.510 muddying things up and now the code is really 0:28:43.510,0:28:45.929 starting to get nasty. And this is such a 0:28:45.929,0:28:49.200 simple example. I've actually posted this[br]example online before 0:28:49.200,0:28:51.809 and had arguments with TDD proponents about[br]that. 0:28:51.809,0:28:53.380 And, yes, this is, I'm like, well, what does 0:28:53.380,0:28:57.029 it matter? You're just injecting one dependency,[br]what does 0:28:57.029,0:28:58.740 it matter? It's not that big of a deal, 0:28:58.740,0:29:00.090 right? Yes it is. 0:29:00.090,0:29:02.820 Because this is exactly the type of thinking[br]that 0:29:02.820,0:29:05.899 leads you down a really nasty path. Let's[br]look 0:29:05.899,0:29:07.019 at another example. 0:29:07.019,0:29:11.929 Here's a standard Rails controller. It has[br]reliance on 0:29:11.929,0:29:14.429 the world. It relies on a before action that 0:29:14.429,0:29:19.389 ensures permissions. It sets up a new object[br]and 0:29:19.389,0:29:21.630 sends out an email and then it responds to 0:29:21.630,0:29:24.330 something, right. The whole purpose of the[br]controller in 0:29:24.330,0:29:27.470 Rails is to sort of direct the world. It's 0:29:27.470,0:29:28.880 to interact with the world. 0:29:28.880,0:29:31.730 But how do you unit test that, right? That's 0:29:31.730,0:29:34.159 really hard. It's relying on the entire world.[br]If 0:29:34.159,0:29:37.500 we're following this scientific approach of[br]unit testing where 0:29:37.500,0:29:40.480 we're isolating all the variables, holding[br]everything else constant 0:29:40.480,0:29:43.269 except for these two things, what goes in,[br]what 0:29:43.269,0:29:49.740 goes out. This is bad, right. 0:29:49.740,0:29:53.519 If we instead put in something like a person 0:29:53.519,0:29:56.269 creation command and hide away all the actual[br]doing 0:29:56.269,0:29:58.149 of the control and then we inject all the 0:29:58.149,0:30:00.990 stuff that it depends on we can test person 0:30:00.990,0:30:04.190 creation command really well. 0:30:04.190,0:30:07.470 Is that code better? Is that code simpler?[br]Is 0:30:07.470,0:30:09.510 it clearer? Would you rather look at this[br]and 0:30:09.510,0:30:11.080 then understand what the system does or would[br]you 0:30:11.080,0:30:13.299 rather look at this and try to figure out 0:30:13.299,0:30:16.149 where does this thing go? 0:30:16.149,0:30:21.639 And that's the consequence of this chase of[br]test-first. 0:30:21.639,0:30:23.960 It leads you down a path where the gospel 0:30:23.960,0:30:28.139 of test-driven design is that anything that's[br]easier to 0:30:28.139,0:30:32.549 test is better. That's it. That's the measure[br]of 0:30:32.549,0:30:35.590 quality. If you can test it easily it's better. 0:30:35.590,0:30:39.059 If you can't test it easily, it's worse. 0:30:39.059,0:30:43.010 Boo. Exactly right. Boo. 0:30:43.010,0:30:45.830 It's not better. We're losing sight of what[br]we're 0:30:45.830,0:30:48.659 actually trying to do. Tests were supposed[br]to support 0:30:48.659,0:30:53.950 us. They weren't supposed to be the main thing. 0:30:53.950,0:30:55.289 And I think this is leading to a lot 0:30:55.289,0:31:00.889 of Zombie astronautic architectures. Things[br]that I thought we 0:31:00.889,0:31:04.480 moved past long ago. If you look at, at 0:31:04.480,0:31:07.980 this person create command, that reminds me[br]very much 0:31:07.980,0:31:11.010 about Struts 1 point 2, and how they had 0:31:11.010,0:31:12.880 every action as their own object. And that[br]it 0:31:12.880,0:31:15.169 was great because it was easy to test, and 0:31:15.169,0:31:16.169 it was shit when you were trying to put 0:31:16.169,0:31:19.179 a whole architecture together, because you[br]had all these 0:31:19.179,0:31:20.409 create commands and all of the sudden you[br]had 0:31:20.409,0:31:22.250 a million objects. Yes, they were easier to[br]test, 0:31:22.250,0:31:26.340 but the system was much harder to reason about. 0:31:26.340,0:31:28.669 You see the same thing around ActiveRecord,[br]for example. 0:31:28.669,0:31:32.200 You see, well ActiveRecord should just be[br]data access 0:31:32.200,0:31:34.080 objects. They shouldn't actually have any[br]logic. They should 0:31:34.080,0:31:36.139 just be about interfacing with the database,[br]because then 0:31:36.139,0:31:38.340 we can split out everything else. Our domain[br]logic, 0:31:38.340,0:31:40.720 it's just that it doesn't have to touch the 0:31:40.720,0:31:43.009 database, so that our tests can be simple,[br]so 0:31:43.009,0:31:46.070 that our tests can be fast, right? 0:31:46.070,0:31:52.919 Again. Order of priority. Test, test fast,[br]oh, your 0:31:52.919,0:31:58.519 architecture. That'll just fall from that,[br]right? 0:31:58.519,0:32:02.880 I recently read James Coplien, has a great[br]paper 0:32:02.880,0:32:06.220 out called "Why Most Unit Testing is Waste."[br]And 0:32:06.220,0:32:09.809 for me, this is the money quote. Splitting[br]up 0:32:09.809,0:32:13.639 functions to support the testing process,[br]destroys your system 0:32:13.639,0:32:17.809 architecture and code comprehension along[br]with it. Test at 0:32:17.809,0:32:22.330 a coarser level of granularity. 0:32:22.330,0:32:28.740 TDD is focused on the unit. The unit is 0:32:28.740,0:32:31.440 the sacred piece, because that's the science[br]piece. That's 0:32:31.440,0:32:33.419 what we can control all of the variables.[br]We're 0:32:33.419,0:32:35.950 just looking at these few pieces, right. 0:32:35.950,0:32:39.230 What James is saying, maybe that's not the[br]right 0:32:39.230,0:32:44.009 level. Maybe testing, the role it should have,[br]shouldn't 0:32:44.009,0:32:47.779 be about the unit most of the time. And, 0:32:47.779,0:32:50.019 I sort of alluded to this awhile back, I 0:32:50.019,0:32:54.220 wrote a post called Testing Like the TSA,[br]and 0:32:54.220,0:32:56.470 the main thing about that was about over-testing[br]and 0:32:56.470,0:32:58.480 sort of this testing theater that goes on.[br]But 0:32:58.480,0:33:02.360 I hadn't really made the switch that it, the 0:33:02.360,0:33:03.980 problem is that we're trying to test at the 0:33:03.980,0:33:05.059 wrong level. 0:33:05.059,0:33:07.110 It's not testing itself. Testing is great.[br]I'm not 0:33:07.110,0:33:10.399 advocating that we shouldn't have tests. I'm[br]advocating that 0:33:10.399,0:33:14.080 driving your design from unit tests is actually[br]not 0:33:14.080,0:33:17.559 a good idea. That you actually end up destroying 0:33:17.559,0:33:20.039 your system architecture and your code comprehension[br]along with 0:33:20.039,0:33:21.559 it. 0:33:21.559,0:33:26.019 So if unit tests aren't the thing, what could 0:33:26.019,0:33:26.850 we do instead? 0:33:26.850,0:33:29.620 Well, I think there are higher levels of testing. 0:33:29.620,0:33:31.269 We've already sort of moved to that in Rails. 0:33:31.269,0:33:33.659 It's no longer called test unit, where you[br]place 0:33:33.659,0:33:37.090 your tests, it's called test models. That's[br]already one 0:33:37.090,0:33:40.399 step up. That sort of frees you from feeling 0:33:40.399,0:33:42.570 bad about the fact that your, your model tests 0:33:42.570,0:33:44.970 actually touch the database. That's not a[br]bad thing. 0:33:44.970,0:33:46.950 Yes. They run slower. But they also test more 0:33:46.950,0:33:47.690 things. 0:33:47.690,0:33:49.179 You can make anything fast if it doesn't have 0:33:49.179,0:33:52.009 to work. 0:33:52.009,0:33:53.880 And I think that's the problem with testing[br]in 0:33:53.880,0:33:55.139 a lot of cases. We recently had a really 0:33:55.139,0:33:57.330 bad bug on base kim where we actually lost 0:33:57.330,0:34:01.009 some data for real customers. And it was incredibly 0:34:01.009,0:34:05.779 well-tested at the unit level. And all the[br]tests 0:34:05.779,0:34:08.179 passed. And still we lost data. How the fuck 0:34:08.179,0:34:09.918 did that happen? 0:34:09.918,0:34:11.750 It happened because we were so focused on[br]driving 0:34:11.750,0:34:14.190 our design from the unit test level, we didn't 0:34:14.190,0:34:17.050 have any system tests for that particular[br]thing. And 0:34:17.050,0:34:18.580 it was a really simple thing. It was like, 0:34:18.580,0:34:21.110 if you were editing an object and you were 0:34:21.110,0:34:22.520 editing the attachments, you could lose an[br]attachment. And 0:34:22.520,0:34:25.560 we lost some attachments and it was a terrible 0:34:25.560,0:34:26.679 thing. 0:34:26.679,0:34:29.949 And after that, sort of thought, wait a minute. 0:34:29.949,0:34:33.210 All these unit tests are just focusing on[br]these 0:34:33.210,0:34:36.139 core objects in the system. These individual[br]unit pieces. 0:34:36.139,0:34:38.179 It doesn't say anything about whether the[br]whole system 0:34:38.179,0:34:38.829 works. 0:34:38.829,0:34:42.899 Most TDD proponents, I find, are much more[br]focused 0:34:42.899,0:34:45.159 on the unit level, because that's where they're[br]driving 0:34:45.159,0:34:47.219 their design. And they're not very much focused[br]on 0:34:47.219,0:34:49.149 the system level at all, which is what people 0:34:49.149,0:34:50.190 actually give a shit about. 0:34:50.190,0:34:52.649 Does the system work? I don't care about whether 0:34:52.649,0:34:55.750 your units work. Does the whole thing work?[br]That's 0:34:55.750,0:34:57.760 what matters. 0:34:57.760,0:35:00.450 So that kind of freed my mind up a 0:35:00.450,0:35:03.230 little bit. That if we give up this need 0:35:03.230,0:35:05.240 for hard science experience, where we have[br]to control 0:35:05.240,0:35:07.140 all the variables and boil everything down[br]to a 0:35:07.140,0:35:09.220 single unit that can be tested, we can float 0:35:09.220,0:35:11.900 freely with the world. 0:35:11.900,0:35:13.530 Awesome. 0:35:13.530,0:35:18.140 This realization, I came to realize, was why[br]people 0:35:18.140,0:35:22.740 hate fixtures. So fixtures in, in Rails is[br]about 0:35:22.740,0:35:27.390 spinning up a world, it's about setting up,[br]sort 0:35:27.390,0:35:33.540 of, small size version of the whole world.[br]Where 0:35:33.540,0:35:36.780 most approaches, they focus on just one unit. 0:35:36.780,0:35:38.660 I don't want to have an account in here 0:35:38.660,0:35:40.300 and a project in here if I'm just testing 0:35:40.300,0:35:42.560 my message. I just want to test this one 0:35:42.560,0:35:44.970 single thing, right. And if you're doing that,[br]yeah, 0:35:44.970,0:35:46.510 fixtures are probably not a good thing. It[br]doesn't 0:35:46.510,0:35:47.670 really work for that. 0:35:47.670,0:35:50.730 It works really well when you're not concerned[br]about 0:35:50.730,0:35:53.700 the hard science focus on unit tests. It works 0:35:53.700,0:35:57.300 really well when you're focused on a larger[br]level. 0:35:57.300,0:35:58.810 When you're focused on models, when you're[br]focused on 0:35:58.810,0:36:03.319 controllers, and most importantly when you're[br]focused on systems. 0:36:03.319,0:36:09.410 But all that is sort of usually swept away 0:36:09.410,0:36:14.970 by the holy trinity of test metrics. Coverage,[br]ratio, 0:36:14.970,0:36:17.230 and speed. 0:36:17.230,0:36:23.920 I've been in a lot of internet arguments lately. 0:36:23.920,0:36:28.250 In such esteemed establishments as Hacker[br]News, and, and 0:36:28.250,0:36:31.970 elsewhere, and I find it really interesting,[br]because each 0:36:31.970,0:36:35.410 individual argument will make me rage, but[br]then the 0:36:35.410,0:36:38.400 larger set of all arguments, like a meta study, 0:36:38.400,0:36:41.060 actually reveals really interesting things[br]about what people care 0:36:41.060,0:36:42.400 about. What they value. 0:36:42.400,0:36:44.849 And what I find is, in most discussions about 0:36:44.849,0:36:48.210 design, especially around Rails, what people[br]care about these 0:36:48.210,0:36:51.520 things, and these things only. It's about[br]the test 0:36:51.520,0:36:53.750 coverage. It's about the test ratio. And it's[br]about 0:36:53.750,0:36:55.650 how fast your tests run. 0:36:55.650,0:36:59.630 Like, that's the pedestal. That's the holy[br]grail. What 0:36:59.630,0:37:03.730 actually happens underneath, the design of[br]the rest of 0:37:03.730,0:37:07.140 the application is, eh. Doesn't really matter. 0:37:07.140,0:37:10.000 And thus, a lot of people come to celebrate, 0:37:10.000,0:37:12.670 oh, I have a one to four test ratio. 0:37:12.670,0:37:14.530 For every line of production code, I have[br]four 0:37:14.530,0:37:18.630 lines of test. Oh yeah. 0:37:18.630,0:37:22.569 And they say that with pride. And I'm like, 0:37:22.569,0:37:25.230 what? So you're saying for every line of production 0:37:25.230,0:37:26.890 code you write, you have to write four lines 0:37:26.890,0:37:29.140 of code? And that somehow makes you a hero? 0:37:29.140,0:37:31.400 How, how does that work? 0:37:31.400,0:37:34.109 So your system is now five times as large, 0:37:34.109,0:37:35.770 reasoning about the whole system is now five[br]times 0:37:35.770,0:37:38.760 as complex, and you're proud of this, why?[br]Well, 0:37:38.760,0:37:41.839 of course, because I have a hundred percent[br]coverage. 0:37:41.839,0:37:44.980 My five thousand tests run incredibly fast[br]because they 0:37:44.980,0:37:47.069 never actually test very much. 0:37:47.069,0:37:49.420 They certainly do not test the system. They[br]test 0:37:49.420,0:37:52.800 all these little slices of unit. Wonderful. 0:37:52.800,0:37:56.099 It's not wonderful. You have anemic fucking[br]tests. They 0:37:56.099,0:37:57.970 don't prove shit. You're gonna have the same[br]bug 0:37:57.970,0:38:00.119 that we have on base camp, and the system 0:38:00.119,0:38:01.960 is not going to work even though you've proudly 0:38:01.960,0:38:05.540 proclaimed, oh, well, your units are working. 0:38:05.540,0:38:10.240 Well, whoopity-doo. This decoupling is now[br]free. People think 0:38:10.240,0:38:13.810 that, oh, this is like that saying, like,[br]quality's 0:38:13.810,0:38:16.510 free. Right. Testing is free. Not when you're[br]doing 0:38:16.510,0:38:21.020 it like this. It's not free. 0:38:21.020,0:38:22.760 And most importantly, it's not free, not so[br]much 0:38:22.760,0:38:27.460 in time, but in conceptual overhead. Understanding[br]a system 0:38:27.460,0:38:32.780 that has been test-driven designed from the[br]unit perspective 0:38:32.780,0:38:36.400 is really hard. Because you have all these[br]levels 0:38:36.400,0:38:40.170 of indirection. You have all these levels[br]of intermediation. 0:38:40.170,0:38:45.240 To separate the tests from slow things, like[br]HTML 0:38:45.240,0:38:47.760 or the database or, any of the other parts 0:38:47.760,0:38:50.460 of the system that actually makes up your[br]system. 0:38:50.460,0:38:53.800 And they focus just on that one thing. So 0:38:53.800,0:38:56.060 they can be very fast, if they don't have 0:38:56.060,0:38:57.650 to work. They don't actually have to test[br]your 0:38:57.650,0:38:58.990 system. 0:38:58.990,0:39:01.280 So that's sort of two charges in one. It's 0:39:01.280,0:39:04.089 a charge first that your design is not going 0:39:04.089,0:39:07.260 to improve. Your design is going to deteriorate[br]by 0:39:07.260,0:39:11.069 doing test first programming, because you're[br]going to construct 0:39:11.069,0:39:15.440 your units of testing, your methods, in a[br]different 0:39:15.440,0:39:16.980 way, like we say with the age example. You're 0:39:16.980,0:39:19.970 going to inject all your dependencies in a[br]way 0:39:19.970,0:39:21.980 that does not prove things. 0:39:21.980,0:39:23.609 And second of all, you're not gonna get the 0:39:23.609,0:39:26.530 benefit of great coverage. You might have[br]a lot 0:39:26.530,0:39:28.470 of tests, but they don't test your system.[br]It 0:39:28.470,0:39:33.140 doesn't improve your confidence in actually[br]the whole thing 0:39:33.140,0:39:35.849 working, and then what good is it? 0:39:35.849,0:39:40.900 Well, I thought about this for a long time 0:39:40.900,0:39:44.950 and thought, like, this is not really, it[br]doesn't 0:39:44.950,0:39:47.589 seem like that great of a revelation. Why,[br]why 0:39:47.589,0:39:50.369 do I keep having these arguments over and[br]over 0:39:50.369,0:39:52.920 again? Why are people focused so hard and[br]so 0:39:52.920,0:39:57.690 intensely on this trinity of test metrics?[br]How did 0:39:57.690,0:40:00.510 that come to be the main thing that people 0:40:00.510,0:40:01.530 are arguing about? 0:40:01.530,0:40:03.230 How did that come to be the main decider 0:40:03.230,0:40:05.670 of what's good design and what's bad design?[br]Really, 0:40:05.670,0:40:09.760 couldn't really figure it out. Until I started[br]thinking 0:40:09.760,0:40:11.700 back of like, what is this prism we're looking 0:40:11.700,0:40:17.630 through? We're looking through computer science.[br]Engineering. Professionalism. 0:40:17.630,0:40:21.550 James Harrington wrote a bunch of books on[br]quality 0:40:21.550,0:40:23.940 of engineering, and he has a great quote here. 0:40:23.940,0:40:26.890 If you can't measure something, you can't[br]understand it. 0:40:26.890,0:40:28.950 If you can't understand it, you can't control[br]it. 0:40:28.950,0:40:31.280 If you can't control it, you can't improve[br]it. 0:40:31.280,0:40:36.309 That makes a lot of sense. Cause like, yeah, 0:40:36.309,0:40:38.079 yeah, that makes sense. That's gotta be why.[br]And 0:40:38.079,0:40:40.510 then I got another great quote. Just because[br]you 0:40:40.510,0:40:43.040 can, just because something is easy to measure[br]doesn't 0:40:43.040,0:40:44.180 mean it's important. 0:40:44.180,0:40:48.990 This, I think, is exactly what's going on[br]here. 0:40:48.990,0:40:52.809 Programming of information systems is a lot[br]more like 0:40:52.809,0:40:57.609 French poetry than it is like physics. But[br]programmers 0:40:57.609,0:41:00.280 grow up thinking that they're computer scientists,[br]so they 0:41:00.280,0:41:03.210 want it really badly to be like physics. They 0:41:03.210,0:41:06.710 want it really badly to be a hard, professional 0:41:06.710,0:41:07.819 science. 0:41:07.819,0:41:13.589 And coverage, ratio, and speed. You can get[br]that 0:41:13.589,0:41:18.329 fucking thing down to six decimals. Like,[br]that, I 0:41:18.329,0:41:20.349 can be so precise about how fast my test 0:41:20.349,0:41:26.300 runs, eighty-four point seven percent coverage,[br]boom. Got it. 0:41:26.300,0:41:28.020 Doesn't say anything about whether or not[br]that's actually 0:41:28.020,0:41:31.750 important. Doesn't say anything about whether[br]that's actually producing 0:41:31.750,0:41:33.550 a good system. Doesn't say anything about[br]whether the 0:41:33.550,0:41:36.280 person after you, or you yourself, three months[br]from 0:41:36.280,0:41:38.369 now, can understand what the hell is going[br]on 0:41:38.369,0:41:41.260 in this code base. 0:41:41.260,0:41:43.480 You haven't necessarily made anything any[br]clearer. You've made 0:41:43.480,0:41:47.880 it very easy to produce metrics. And if there's 0:41:47.880,0:41:51.480 one thing we love with, with science, it's[br]clear 0:41:51.480,0:41:58.329 concise objective truths and coverage and[br]ratio and speed 0:41:58.329,0:42:00.690 fit that bill. So we adopted them with open 0:42:00.690,0:42:03.910 arms, even though they were not that important. 0:42:03.910,0:42:08.450 Second part of it. Cost is not value. A 0:42:08.450,0:42:12.180 lot of people have invested so much in building 0:42:12.180,0:42:17.609 up their expertise, their time, their four-to-one[br]ratio in 0:42:17.609,0:42:22.079 tests. The investment is massive. Well, of[br]course they're 0:42:22.079,0:42:25.010 gonna be defensive about it. Like, you've[br]invested so 0:42:25.010,0:42:28.319 much of your ego and your time and your 0:42:28.319,0:42:31.069 resources on this project, into testing. So[br]of course 0:42:31.069,0:42:33.369 it must be valuable. Of course it must be 0:42:33.369,0:42:33.780 important. 0:42:33.780,0:42:36.650 That's not how it works. Just because something[br]is 0:42:36.650,0:42:39.410 really expensive, just because something takes[br]a lot of 0:42:39.410,0:42:42.609 your time doesn't mean it's valuable. Doesn't[br]mean it's 0:42:42.609,0:42:47.619 important. 0:42:47.619,0:42:52.440 So I was sort of giving a brief description 0:42:52.440,0:42:57.079 of this talk yesterday at dinner with Aaron[br]Patterson, 0:42:57.079,0:43:01.369 and he trolled me right back and said, TL;DR, 0:43:01.369,0:43:03.940 just don't test, right. Like, that's what[br]I'm supposed 0:43:03.940,0:43:06.990 to get out of this. 0:43:06.990,0:43:12.430 No. No. Testing absolutely has value. Regression[br]testing absolutely 0:43:12.430,0:43:18.089 has value. Driving your design through test[br]first? In 0:43:18.089,0:43:23.040 my mind, rarely has value. Not never. There[br]are 0:43:23.040,0:43:25.010 times where I'll write my tests first, usually[br]when 0:43:25.010,0:43:29.210 it's something like a translator of some kind,[br]where 0:43:29.210,0:43:30.550 I know exactly what's going in and I know 0:43:30.550,0:43:31.720 exactly what I want out. 0:43:31.720,0:43:33.809 That could be a good case to start with 0:43:33.809,0:43:37.000 test first. Most information system design[br]is not like 0:43:37.000,0:43:38.640 that. I'm trying to figure out and sell what 0:43:38.640,0:43:41.829 the system is supposed to do. What I'm going 0:43:41.829,0:43:44.240 to arrive at is the test, is this set 0:43:44.240,0:43:46.619 of tests, it's a set of regression tests,[br]that 0:43:46.619,0:43:47.960 make me feel good about that after the fact, 0:43:47.960,0:43:50.430 that I can still change my system and not 0:43:50.430,0:43:56.230 break it, right. 0:43:56.230,0:44:03.230 So TDD. Kent Beck. Main proponent behind TDD[br]has 0:44:05.839,0:44:08.869 a very sensible quote that goes exactly along[br]these 0:44:08.869,0:44:12.210 lines. I get paid for code that works, not 0:44:12.210,0:44:15.079 for tests, so my philosophy is to test as 0:44:15.079,0:44:18.890 little as possible to reach a given level[br]of 0:44:18.890,0:44:19.579 confidence. 0:44:19.579,0:44:24.369 Immensely sensible. I find that that's actually[br]often the 0:44:24.369,0:44:27.890 case with these things that get taken too[br]far. 0:44:27.890,0:44:32.579 TDD started out as a pretty sensible thing.[br]Kent 0:44:32.579,0:44:35.390 has an even more sensible perception of it[br]now, 0:44:35.390,0:44:39.270 I think, than when he wrote the test-driven[br]book 0:44:39.270,0:44:42.710 originally. But that's not what most people[br]take away. 0:44:42.710,0:44:44.839 That's not what most people run with if they 0:44:44.839,0:44:46.950 want to build a career on making people feel 0:44:46.950,0:44:50.180 shitty about their code bases and their dirty,[br]dirty 0:44:50.180,0:44:50.690 code. 0:44:50.690,0:44:54.450 They take a much more extremist approach,[br]that unless 0:44:54.450,0:44:59.440 you're doing test-first, you're not a professional.[br]Certainly not 0:44:59.440,0:45:01.839 what Kent's saying. 0:45:01.839,0:45:06.619 OK. So for me, this really boils down to, 0:45:06.619,0:45:09.950 we're, we're trying to wear the wrong hat[br]the 0:45:09.950,0:45:13.089 majority of the time. Thinking of yourself[br]as a 0:45:13.089,0:45:18.130 software engineer will lead you down the path[br]of 0:45:18.130,0:45:24.150 coverage, speed, metrics, hard sciences - all[br]these things 0:45:24.150,0:45:29.260 we can measure and it leave you laughing at 0:45:29.260,0:45:34.720 shit like interpretation of French poetry.[br]Of subjective evaluations 0:45:34.720,0:45:36.880 of a design in the system, even though these 0:45:36.880,0:45:39.640 are the only tools that we have. 0:45:39.640,0:45:43.349 So this has taken me awhile to arrive at 0:45:43.349,0:45:45.960 this conclusion. I've hated the word software[br]engineer for 0:45:45.960,0:45:48.660 quite awhile. Cause I never felt it fit me. 0:45:48.660,0:45:51.510 I never thought of myself as a software engineer. 0:45:51.510,0:45:53.670 I kind of tried to be one, a few 0:45:53.670,0:45:55.750 times, and I failed all the time. And by 0:45:55.750,0:45:58.359 the time I finally arrived at programming[br]as something 0:45:58.359,0:46:00.280 that I wanted to do, it sure as shit 0:46:00.280,0:46:02.569 wasn't software engineering. 0:46:02.569,0:46:06.230 Yes. It's a hard hat that I wear occasionally, 0:46:06.230,0:46:10.559 when I do performance optimization. That's[br]hard science. You 0:46:10.559,0:46:13.220 make a change. You measure it. Was it an 0:46:13.220,0:46:19.040 improvement? If not, revert. If yes, deploy.[br]Very scientific. 0:46:19.040,0:46:20.790 Very good. 0:46:20.790,0:46:23.859 Great to wear the hard hat when that fits. 0:46:23.859,0:46:25.680 Is what, that what I do the majority of 0:46:25.680,0:46:27.480 the time? Is that how I think of myself 0:46:27.480,0:46:29.480 when I write most of the things that I 0:46:29.480,0:46:31.300 write? When I add a new feature to base 0:46:31.300,0:46:34.109 camp or do forensics to figure out how a 0:46:34.109,0:46:37.119 bug came about, or what somebody meant when[br]they 0:46:37.119,0:46:39.280 wrote a bug in or something? No. That's not 0:46:39.280,0:46:40.710 what I do. 0:46:40.710,0:46:42.369 So I don't try to think of myself as 0:46:42.369,0:46:43.530 a software engineer. 0:46:43.530,0:46:48.040 OK. If we're not software engineers, most[br]of the 0:46:48.040,0:46:51.619 time when we make information systems, what[br]are we 0:46:51.619,0:46:55.059 then? What other hat should we try to wear? 0:46:55.059,0:46:58.520 What other identity should we try to aspire[br]to? 0:46:58.520,0:47:01.109 I think we had it all along. I think 0:47:01.109,0:47:04.000 we had it in the language all along. We're 0:47:04.000,0:47:10.319 software writers. Writing is a much more apt[br]metaphor 0:47:10.319,0:47:12.510 for what we do most of the time, than 0:47:12.510,0:47:19.510 engineering is. Writing is about clarity.[br]It's about presenting 0:47:22.339,0:47:28.460 information and motivations in a clear-to-follow[br]manner so that 0:47:28.460,0:47:29.640 anybody can understand it. 0:47:29.640,0:47:33.770 There are not bonus points for making something[br]convoluted, 0:47:33.770,0:47:37.349 as there often is with engineering and with[br]test-first 0:47:37.349,0:47:40.390 design. Making things more convoluted gives[br]you the benefits 0:47:40.390,0:47:44.000 of, perhaps, easier to test. They don't give[br]you 0:47:44.000,0:47:49.160 clarity. So those things are often in opposition. 0:47:49.160,0:47:52.640 Clarity is all about being succinct without[br]being terse. 0:47:52.640,0:47:56.140 WE can write things using as small words as 0:47:56.140,0:47:59.670 we know how, using as little complication[br]as we 0:47:59.670,0:48:03.299 know how, using as little conceptual overhead[br]as we 0:48:03.299,0:48:06.950 know how to get the job done. 0:48:06.950,0:48:10.140 That's a much better approach. And I think[br]it 0:48:10.140,0:48:14.170 comes very easy if you think of software development 0:48:14.170,0:48:16.760 as writing. If you look at a piece of 0:48:16.760,0:48:18.680 writing that somebody has written and it's[br]kind of 0:48:18.680,0:48:21.690 convoluted, can't really follow the argument,[br]and paragraphs are 0:48:21.690,0:48:24.020 not broken up neatly, is the first thing you're 0:48:24.020,0:48:25.500 gonna say, you know what the problem with[br]this 0:48:25.500,0:48:28.760 is? You're not using big enough words. 0:48:28.760,0:48:30.829 If we just shoved some bigger words into this 0:48:30.829,0:48:34.980 text, it's gonna be there. That's good. Oh.[br]The 0:48:34.980,0:48:37.750 problem here is like, like your sentences[br]are too 0:48:37.750,0:48:41.619 clear. If you just insert a sentence in the 0:48:41.619,0:48:43.920 middle, that'd be great. Oh, do you know what? 0:48:43.920,0:48:46.799 This needs more semicolons. That's what this[br]needs. If 0:48:46.799,0:48:50.910 this has more semicolons, boom. You got clarity. 0:48:50.910,0:48:54.000 No. More indirection. More third-person. These[br]are not the 0:48:54.000,0:48:57.049 things that make for great, clear writing.[br]And that's 0:48:57.049,0:48:59.630 obvious when we talk about things like writing.[br]SO 0:48:59.630,0:49:02.869 if we talk about software development as writing,[br]I 0:49:02.869,0:49:05.869 think it'll be obvious too. I think if we 0:49:05.869,0:49:10.960 supplant the high ideal of what matters for[br]design 0:49:10.960,0:49:12.430 is how easy it is to test, how easy 0:49:12.430,0:49:16.170 it is to make engineering driven, and put[br]clarity 0:49:16.170,0:49:20.240 of the code base above all else, we're gonna 0:49:20.240,0:49:22.660 be much better off. And arguments are gonna[br]be 0:49:22.660,0:49:25.890 settled much easier. And it's gonna be much[br]easier 0:49:25.890,0:49:27.670 to read the fucking code you wrote three months 0:49:27.670,0:49:30.099 ago, because you had that in mind. 0:49:30.099,0:49:31.680 That was your motivation. That was what you[br]were 0:49:31.680,0:49:33.839 going for. 0:49:33.839,0:49:38.010 So what is clarity? How do you figure that 0:49:38.010,0:49:40.540 out, right? That's real easy to say, oh it's 0:49:40.540,0:49:46.190 just clarity. Boom. It's open to interpretation,[br]right. It's 0:49:46.190,0:49:47.910 not as clear as just saying, oh if you 0:49:47.910,0:49:50.270 can just get your code coverage above 85%[br]then 0:49:50.270,0:49:51.619 you're gold, right. 0:49:51.619,0:49:53.599 Clarity doesn't work like that. There's not[br]a metric 0:49:53.599,0:49:56.490 we can just apply, because, again, it's not[br]hard 0:49:56.490,0:50:01.079 science. Clarity of writing is not hard science. 0:50:01.079,0:50:05.290 So the easy answer is, I know when I 0:50:05.290,0:50:08.640 see it. Right? There's not just gonna be a 0:50:08.640,0:50:11.960 list of principles and practices that somebody[br]can be 0:50:11.960,0:50:15.380 taught and then they will automatically produce[br]clear writing 0:50:15.380,0:50:19.849 every time. Right? If you want to be a 0:50:19.849,0:50:21.970 good writer, is it enough just to sit and 0:50:21.970,0:50:28.160 memorize the dictionary? No. Just knowing[br]the words available 0:50:28.160,0:50:30.480 to you, knowing the patterns of development[br]is not 0:50:30.480,0:50:32.799 gonna make you a good developer. 0:50:32.799,0:50:37.309 You have to develop an eye. You have to 0:50:37.309,0:50:39.849 develop an eye for clarity, which means first[br]of 0:50:39.849,0:50:41.450 all, you have to decide that that's important[br]to 0:50:41.450,0:50:43.950 you. So that's the first step. If you're still 0:50:43.950,0:50:46.450 stuck in, the most important thing about my[br]system 0:50:46.450,0:50:49.040 is how fast my tests run, and how many 0:50:49.040,0:50:51.609 of them I have, well. Forget about it. You're 0:50:51.609,0:50:52.740 not gonna get to this point. 0:50:52.740,0:50:54.440 You have to decide that the most important[br]thing 0:50:54.440,0:50:59.130 for your system is clarity. When you do decide 0:50:59.130,0:51:02.420 that, you can start developing an eye. I started 0:51:02.420,0:51:07.540 getting into photography maybe six years ago.[br]When I 0:51:07.540,0:51:10.250 first got into photography, like, I would[br]look at 0:51:10.250,0:51:12.530 a picture and it was like, well, looks like 0:51:12.530,0:51:13.349 a good picture. 0:51:13.349,0:51:15.170 Now, I've been looking at thousands of pictures.[br]I've 0:51:15.170,0:51:18.040 been taking thousands of pictures. And I've[br]developed an 0:51:18.040,0:51:20.270 eye. I can see when the white balance is 0:51:20.270,0:51:23.280 off. I can see, oh, this has a blue 0:51:23.280,0:51:25.420 tint. Oh, this actually, if we crop it just 0:51:25.420,0:51:27.839 a little bit more, only the subjects we want 0:51:27.839,0:51:29.329 to have in focus are in focus. Oh, this 0:51:29.329,0:51:31.920 would actually be better in black and white. 0:51:31.920,0:51:36.309 That eye just came from doing it. A lot. 0:51:36.309,0:51:37.890 It didn't come from just sitting down and[br]reading 0:51:37.890,0:51:42.170 a lot of photography books. And I think it's 0:51:42.170,0:51:44.089 the same thing with code. I think a lot 0:51:44.089,0:51:47.990 of programmers, coming at it from a software[br]engineering 0:51:47.990,0:51:50.020 angle, thing that just all they have to do 0:51:50.020,0:51:55.270 is learn the practices, learn the patterns,[br]memorize them 0:51:55.270,0:51:57.619 all, and then they will be good programmers. 0:51:57.619,0:52:00.640 No, they won't. The only way to become a 0:52:00.640,0:52:04.099 good programmer, where, by definition, I define[br]good programmers 0:52:04.099,0:52:07.410 as somebody who programs, who writes software[br]with clarity, 0:52:07.410,0:52:10.450 is to read a lot of software, write a 0:52:10.450,0:52:12.569 lot of software. 0:52:12.569,0:52:13.859 Just like how do you become a good photographer? 0:52:13.859,0:52:15.950 You take a lot of pictures. And you look 0:52:15.950,0:52:18.020 at them. And you practice. And you practice.[br]And 0:52:18.020,0:52:20.220 you practice. 0:52:20.220,0:52:22.150 I think it's quite similar to the problem[br]with 0:52:22.150,0:52:26.460 diets, right. The fundamental truth with diets[br]is to 0:52:26.460,0:52:29.339 be healthy you should probably exercise regularly,[br]you should 0:52:29.339,0:52:32.849 probably eat a reasonable amount and it should[br]be 0:52:32.849,0:52:37.440 good stuff. Like, that's three things. Incredibly[br]hard to 0:52:37.440,0:52:41.240 do. Most people do not do that, right. Figuring 0:52:41.240,0:52:43.770 out how to write good software: read a lot 0:52:43.770,0:52:47.660 of software, write a lot of software, aim[br]for 0:52:47.660,0:52:49.270 clarity. It sounds too simple. 0:52:49.270,0:52:51.460 Why is it simple? Because there's not just[br]a 0:52:51.460,0:52:53.730 secret. There's not just one answer somebody[br]can give 0:52:53.730,0:52:57.210 you. The only way you can get there is 0:52:57.210,0:53:01.520 by doing it. So when I first started developing 0:53:01.520,0:53:06.470 Rails, I read a ton of software. I read 0:53:06.470,0:53:10.579 the entire Ruby standard library. Partly because[br]documentation of 0:53:10.579,0:53:12.559 Ruby at that time was pretty poor, and the 0:53:12.559,0:53:13.510 only way to figure out how it worked was 0:53:13.510,0:53:15.549 to actually look at the code. But that was 0:53:15.549,0:53:17.760 also where I learned so much. 0:53:17.760,0:53:22.349 Today, we have it so much easier. Bundle open 0:53:22.349,0:53:24.799 name of any gem, and it'll open, boom, right 0:53:24.799,0:53:26.170 up in your text editor. You can look at 0:53:26.170,0:53:28.770 any code. 0:53:28.770,0:53:31.599 How many of you have read through a complete 0:53:31.599,0:53:37.490 gem recently. Something you did not write.[br]Awesome. That's 0:53:37.490,0:53:39.390 actually really encouraging. I thought it[br]would be much 0:53:39.390,0:53:40.470 less. 0:53:40.470,0:53:42.119 I think that is exactly the path you need 0:53:42.119,0:53:44.119 to take. You need to read a shit ton 0:53:44.119,0:53:45.839 of code. And it's not so much just because 0:53:45.839,0:53:47.430 you read this code and then, oh that's all 0:53:47.430,0:53:50.910 great stuff. Just as important as it is to, 0:53:50.910,0:53:53.200 to develop your sense of writing by reading[br]a 0:53:53.200,0:53:57.670 lot of shit writing, so is it with code. 0:53:57.670,0:53:58.809 And I think you will find that that is 0:53:58.809,0:54:01.619 actually very easy. Because a lot of things[br]you'll 0:54:01.619,0:54:07.150 do bundle open on will follow Sturgeon's Revelation.[br]90% 0:54:07.150,0:54:08.780 of everything is crap. 0:54:08.780,0:54:12.970 Well, at least you know you have company if 0:54:12.970,0:54:15.170 you write crap software and I certainly do[br]from 0:54:15.170,0:54:17.980 time to time. And that's a great way to 0:54:17.980,0:54:20.970 learn. I actually find that I learn the most 0:54:20.970,0:54:23.410 about software and learn the most about what[br]matters 0:54:23.410,0:54:25.579 to me, I learn the most about what clarity 0:54:25.579,0:54:28.309 is when I read poor software. 0:54:28.309,0:54:30.359 Because what I do is, I take a piece 0:54:30.359,0:54:33.819 of software, I take a class or method, and 0:54:33.819,0:54:35.940 then I look at it, how could this be 0:54:35.940,0:54:37.460 clearer? Like this is, I think this is poorly 0:54:37.460,0:54:41.109 written. I think this smells. How can I rewrite 0:54:41.109,0:54:41.990 it? 0:54:41.990,0:54:43.640 So by just sitting down and going through[br]that 0:54:43.640,0:54:46.150 exercise and rewriting it, I find I learn[br]a 0:54:46.150,0:54:49.000 whole lot about what I care about. So that's 0:54:49.000,0:54:51.700 what I've been doing lately. Engaging in a[br]lot 0:54:51.700,0:54:54.150 of these internet arguments. Somebody will[br]submit a piece 0:54:54.150,0:54:58.890 of code, and usually the submission will come[br]along 0:54:58.890,0:55:00.319 with the proposed solution, too, right. 0:55:00.319,0:55:02.730 I have this shitty piece of code. Then I 0:55:02.730,0:55:06.619 learned about these three patterns. And now[br]it's wonderful. 0:55:06.619,0:55:09.280 And what I have found every single time, and 0:55:09.280,0:55:11.180 I've only done this maybe a handful of times, 0:55:11.180,0:55:13.660 maybe a little more, is that every single[br]time, 0:55:13.660,0:55:15.130 you just took the shitty code and you stuck 0:55:15.130,0:55:16.520 it into some different boxes. 0:55:16.520,0:55:19.049 Like, it didn't actually improve. Applying[br]the pattern to 0:55:19.049,0:55:21.799 it did not improve the underlying clarity[br]of the 0:55:21.799,0:55:25.329 code, because you just wrote it poorly. Like,[br]the 0:55:25.329,0:55:27.020 problem with the code was not that it was 0:55:27.020,0:55:29.920 missing patterns. The problem with the code[br]was that 0:55:29.920,0:55:32.880 it was crap. That it just had to be 0:55:32.880,0:55:34.730 rewritten. 0:55:34.730,0:55:41.730 Now, that leads us to sort of a mission, 0:55:42.480,0:55:44.990 in some ways, from Rails is and what Ruby 0:55:44.990,0:55:48.700 is, and it leads also to clarify some of 0:55:48.700,0:55:50.400 the arguments we've had in the Rails community[br]for 0:55:50.400,0:55:54.299 awhile. Readability is incredibly important[br]to Ruby. We have 0:55:54.299,0:55:57.309 a lot of duplicated methods that do exactly[br]the 0:55:57.309,0:56:01.349 same thing, just so we can improve readability. 0:56:01.349,0:56:04.950 I remember the first time I saw unless, when 0:56:04.950,0:56:06.920 I was learning about Ruby. That was one of 0:56:06.920,0:56:09.760 those light bulb moments. It's like, wait[br]a minute. 0:56:09.760,0:56:13.990 Unless is exactly the same as if not, but 0:56:13.990,0:56:18.740 it's a different keyword. Huh. 0:56:18.740,0:56:21.500 Right? It was not just about making the most 0:56:21.500,0:56:28.500 efficient, compact language. It was about[br]readability. Poof! 0:56:30.200,0:56:32.559 Mind blown. 0:56:32.559,0:56:37.270 And decade-long love-affair with Ruby established.[br]And I think 0:56:37.270,0:56:40.539 that this is what we're trying to achieve[br]constantly 0:56:40.539,0:56:43.079 in Rails as well. A lot of people will 0:56:43.079,0:56:46.170 gripe about, oh, ActiveRecord is too big or[br]something 0:56:46.170,0:56:49.140 is too big, or have too many methods. The 0:56:49.140,0:56:51.799 surface area is too big or there's, whatever[br]it 0:56:51.799,0:56:52.450 is, right. 0:56:52.450,0:56:55.099 Like, who gives a shit? Is it more readable? 0:56:55.099,0:56:57.480 Is it more clear? That's the only thing that 0:56:57.480,0:56:59.839 matters. What do I care whether the surface[br]area 0:56:59.839,0:57:02.490 of a method is a hundred methods or it's 0:57:02.490,0:57:04.520 two hundred methods? I don't give a shit about 0:57:04.520,0:57:05.690 that. The only thing I give a shit about 0:57:05.690,0:57:07.670 is whether, is the code I'm actually reading,[br]is 0:57:07.670,0:57:10.210 the system I'm trying to understand, is that[br]more 0:57:10.210,0:57:12.680 clear. When you put clarity as your number[br]one 0:57:12.680,0:57:15.410 mission, a lot of concerns just fall by the 0:57:15.410,0:57:15.520 wayside. 0:57:15.520,0:57:21.510 It just doesn't matter anymore. And it's liberating. 0:57:21.510,0:57:24.430 So, I think this actually comes from sort[br]of 0:57:24.430,0:57:26.109 the same rope. I didn't have time to write 0:57:26.109,0:57:27.950 a short letter, so I wrote a long one 0:57:27.950,0:57:32.160 instead. I think that describes about eighty[br]percent of 0:57:32.160,0:57:34.559 all that ninety percent of shitty code. 0:57:34.559,0:57:39.200 Most people did not take the time to write 0:57:39.200,0:57:40.680 a short piece of code, so they wrote a 0:57:40.680,0:57:42.900 long one instead. And then they wrote that[br]long 0:57:42.900,0:57:45.359 one, piece of code, and they like, pulled[br]out 0:57:45.359,0:57:47.960 their suspenders and like, oh yeah, I'm done.[br]My 0:57:47.960,0:57:49.059 tests pass. 0:57:49.059,0:57:52.400 Boom. Right? Or they look at it and decide, 0:57:52.400,0:57:54.180 oh shit, this is too long. I must be 0:57:54.180,0:57:57.869 missing some patterns. I just sprinkle some[br]patterns over 0:57:57.869,0:58:03.430 this. Wonders, right? No. What you wrote was[br]a 0:58:03.430,0:58:05.930 draft. 0:58:05.930,0:58:08.740 This was just a first draft, right. Any piece 0:58:08.740,0:58:12.099 of code you write down is just a draft. 0:58:12.099,0:58:16.230 Mark Twain actually had the hard job, right.[br]He 0:58:16.230,0:58:18.420 wrote in ink. If you actually had to change 0:58:18.420,0:58:20.579 that, well that was kind of hard, right. So 0:58:20.579,0:58:23.410 his drafts were a lot more complicated. Ours?[br]We 0:58:23.410,0:58:25.960 have it so easy. A text editor? You just 0:58:25.960,0:58:28.430 delete stuff. And you don't need any of the 0:58:28.430,0:58:30.109 little stuff that you, you fill over the page 0:58:30.109,0:58:33.049 and you spill it everywhere and so forth.[br]An 0:58:33.049,0:58:33.839 eraser. 0:58:33.839,0:58:36.250 You can just delete stuff. Like that's my[br]favorite 0:58:36.250,0:58:40.890 key. The delete key. It's the number one tool 0:58:40.890,0:58:47.539 for improving code. Delete key. 0:58:47.539,0:58:52.650 So when I was in high school, I submitted 0:58:52.650,0:58:56.670 a bunch of first drafts as essays, and they 0:58:56.670,0:58:58.539 were really shitty. And of course they were.[br]They 0:58:58.539,0:59:00.809 were the first draft. And my teacher at the 0:59:00.809,0:59:03.319 time said, oh, all right, all right, this[br]is 0:59:03.319,0:59:05.890 actually not bad. You just told me the step 0:59:05.890,0:59:07.440 one. If you have something on your mind, you 0:59:07.440,0:59:08.680 should write it down. 0:59:08.680,0:59:10.349 That's what I did. I, I wrote it down. 0:59:10.349,0:59:12.809 And then I handed it in. Oh, if you've 0:59:12.809,0:59:15.480 written something down, you should rewrite[br]it. 0:59:15.480,0:59:18.460 Oh. That was the step I missed. And I 0:59:18.460,0:59:20.530 think that's the step most people miss when[br]they 0:59:20.530,0:59:22.910 write down code. Cause they're focused on[br]all these 0:59:22.910,0:59:24.970 other things. They're not focused on the clarity,[br]because 0:59:24.970,0:59:26.359 when you are focused on the clarity, you will 0:59:26.359,0:59:30.740 realize that all your first drafts are terrible. 0:59:30.740,0:59:33.380 All my first drafts are terrible. All my first 0:59:33.380,0:59:36.240 attempts at writing a good class are poor.[br]They're 0:59:36.240,0:59:39.569 too long. They're not at the same level of 0:59:39.569,0:59:42.770 abstraction. They're not clear. And that's[br]OK. I wrote 0:59:42.770,0:59:44.089 something down. I was trying to figure out[br]what 0:59:44.089,0:59:47.049 the system was supposed to do. 0:59:47.049,0:59:48.950 That's hard work. And often times you don't[br]get 0:59:48.950,0:59:50.589 perfect code out of that when you're still[br]trying 0:59:50.589,0:59:53.099 to figure out what it is that you're writing. 0:59:53.099,0:59:55.710 But once you've written it down, you should[br]rewrite 0:59:55.710,0:59:57.559 it. 0:59:57.559,1:00:03.480 And I think the key part of rewriting is 1:00:03.480,1:00:06.730 omitting needless words when it comes to regular[br]writing. 1:00:06.730,1:00:10.970 When it comes to programming, it's omitting[br]needless concepts. 1:00:10.970,1:00:14.920 It's omitting needless patterns. It's omitting[br]needless practices. It's 1:00:14.920,1:00:21.260 omitting needless classes. It's omitting all[br]these extra things 1:00:21.260,1:00:25.130 that aren't getting you closer to clarity,[br]right. 1:00:25.130,1:00:27.099 How do you know? You develop an eye for 1:00:27.099,1:00:28.960 it. How do you develop an eye? You read 1:00:28.960,1:00:30.099 a lot of code. You write a lot of 1:00:30.099,1:00:32.980 code. You rewrite a lot of code. And you 1:00:32.980,1:00:36.809 forget about fucking patterns for awhile.[br]You forget about 1:00:36.809,1:00:39.930 fucking TDD for awhile. And you focus on just 1:00:39.930,1:00:42.250 what's in front of you. The piece of code. 1:00:42.250,1:00:44.640 How can I write it simpler? 1:00:44.640,1:00:48.219 Write software well. Thank you very much.