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