1 00:00:09,446 --> 00:00:13,046 Lee: Hello and welcome to Software Architecture Insights, your go-to 2 00:00:13,046 --> 00:00:17,186 resource for empowering software architects and aspiring professionals 3 00:00:17,456 --> 00:00:21,686 with the knowledge and tools they require to navigate the complex 4 00:00:21,686 --> 00:00:24,476 landscape of modern software design. 5 00:00:27,500 --> 00:00:31,530 In March of 2024, I wrote about a report from a company called GitClear. 6 00:00:32,610 --> 00:00:38,360 They had analyzed 153 million lines of changed code, looking 7 00:00:38,360 --> 00:00:42,389 at what happened to code quality as AI assistance went mainstream. 8 00:00:43,750 --> 00:00:48,259 In that article, I said the early numbers were worrying and that AI-generated 9 00:00:48,260 --> 00:00:50,329 code needed human moderation. 10 00:00:51,259 --> 00:00:52,939 That was two and a half years ago. 11 00:00:53,439 --> 00:00:55,129 GitClear kept counting. 12 00:00:55,359 --> 00:01:01,019 Their newest report covers 623 million changes running through 13 00:01:01,020 --> 00:01:02,779 the first half of this year. 14 00:01:03,480 --> 00:01:09,389 So today, a check on my own words, what I got right, what I got wrong, and 15 00:01:09,389 --> 00:01:15,729 the thing I missed completely Here's what the 2024 article I wrote argued. 16 00:01:16,559 --> 00:01:19,689 There's a link to the original article in the show notes. 17 00:01:20,959 --> 00:01:24,699 GitHub had published research saying developers write code 18 00:01:24,729 --> 00:01:27,439 55% faster with Copilot. 19 00:01:28,129 --> 00:01:31,649 My question was whether faster also meant better. 20 00:01:32,509 --> 00:01:35,589 The report gave two answers, and neither one of them was good. 21 00:01:36,589 --> 00:01:39,329 First, code churn was climbing. 22 00:01:40,139 --> 00:01:43,589 Churn meaning code that gets changed or reverted within 23 00:01:43,629 --> 00:01:45,019 two weeks of being written. 24 00:01:46,049 --> 00:01:51,259 GitClear projected it would double in 2024 against the 2021 baseline. 25 00:01:52,269 --> 00:01:54,989 Second, code was getting less dry. 26 00:01:55,769 --> 00:01:58,599 More copy and paste, less reuse. 27 00:01:59,189 --> 00:02:02,239 My conclusion was that AI code generation works when it's 28 00:02:02,269 --> 00:02:05,839 balanced against the humans who have to maintain what it produces. 29 00:02:06,579 --> 00:02:08,669 Use AI in moderation. 30 00:02:09,669 --> 00:02:16,189 I'd give that a passing grade, barely, and not for the reasons I expected Starting 31 00:02:16,239 --> 00:02:21,009 with the part I got wrong, since I led the original article with this point. 32 00:02:21,639 --> 00:02:22,209 Churn. 33 00:02:23,109 --> 00:02:26,419 I put it first because doubling is a dramatic number, 34 00:02:26,499 --> 00:02:28,319 and it was easy to explain. 35 00:02:28,899 --> 00:02:30,149 Well, it didn't double. 36 00:02:30,549 --> 00:02:36,129 The newer data has two-week churn up about 15% against 2022. 37 00:02:36,869 --> 00:02:41,109 Now, that's real, and it's worth watching, but it was nowhere near 38 00:02:41,109 --> 00:02:45,899 the story that I made of it at the time Projections do that sometimes. 39 00:02:46,029 --> 00:02:50,769 A curve that's steep for two years gets drawn out to four and then ends up 40 00:02:50,789 --> 00:02:52,429 being something completely different. 41 00:02:52,729 --> 00:02:56,889 So the metric I led with turned out to be the least alarming one in the entire 42 00:02:56,889 --> 00:03:00,429 report But the dry concern held up. 43 00:03:00,649 --> 00:03:03,149 It held up harder than I wanted it to. 44 00:03:04,279 --> 00:03:09,249 Duplicated blocks are up 81% from the 2023 baseline. 45 00:03:09,959 --> 00:03:16,649 Copy and paste has gone from about 9% of changed lines in 2022 to nearly 16% 46 00:03:16,649 --> 00:03:18,319 in the first half of this year alone. 47 00:03:19,249 --> 00:03:23,019 And there's a number in the new report I had no way to see back then. 48 00:03:23,859 --> 00:03:27,559 Calls to functions in other files are down 35% since 2023. 49 00:03:27,559 --> 00:03:27,599 Now, the last one 50 00:03:30,909 --> 00:03:33,889 is the clearest signal in the whole report. 51 00:03:34,429 --> 00:03:39,589 A cross-file function call is what reuse looks like in a code base. 52 00:03:39,999 --> 00:03:43,969 Somebody needs something, found it already written, and called it. 53 00:03:45,309 --> 00:03:50,249 Down one-third in three years, which means people are finding it 54 00:03:50,319 --> 00:03:56,069 easier to have an AI model write a new function rather than find an 55 00:03:56,069 --> 00:03:58,079 existing one that does the same work. 56 00:03:59,079 --> 00:04:01,819 Now, the thing I didn't see coming at all back then, refactoring 57 00:04:04,404 --> 00:04:06,034 has collapsed. 58 00:04:07,114 --> 00:04:13,727 In 2022, about 21% of changed lines of code were moved code. 59 00:04:14,277 --> 00:04:18,047 Moving code is the signature of a cleanup operation. 60 00:04:18,837 --> 00:04:22,897 Pulling something into a shared place, splitting a file, 61 00:04:23,297 --> 00:04:25,227 reorganizing what's already there. 62 00:04:25,707 --> 00:04:28,157 That's what refactoring looks like. 63 00:04:29,157 --> 00:04:31,467 This year, it's under 4%. 64 00:04:32,537 --> 00:04:35,907 21% now down to 4%. 65 00:04:37,047 --> 00:04:40,757 Copy and paste is now about four times more common than refactoring. 66 00:04:41,387 --> 00:04:43,557 Four years ago, it was the other way around. 67 00:04:43,617 --> 00:04:47,397 Refactoring ran more than twice the copy and paste rate. 68 00:04:48,397 --> 00:04:49,537 There's a matching number. 69 00:04:50,207 --> 00:04:58,337 Updates to code that hasn't been touched in a year or more are down 74% since 2023. 70 00:04:59,207 --> 00:05:04,867 Whatever landed in your code base last year is mostly still just sitting there. 71 00:05:06,067 --> 00:05:12,017 I spent the 2024 article asking whether AI writes good code, and 72 00:05:12,097 --> 00:05:15,477 almost everyone in the industry is asking that question as well. 73 00:05:16,227 --> 00:05:18,777 But that's actually the wrong question. 74 00:05:19,767 --> 00:05:21,837 The code AI writes is fine. 75 00:05:22,757 --> 00:05:27,507 It compiles, it passes reviews, it does its thing. 76 00:05:28,527 --> 00:05:31,677 What's stopped happening is everything that goes around the code. 77 00:05:33,147 --> 00:05:37,527 The mechanism isn't mysterious once you look at it as a price change. 78 00:05:38,337 --> 00:05:41,037 AI made writing new code nearly free. 79 00:05:41,857 --> 00:05:46,397 It did not make refactoring any cheaper because refactoring means understanding 80 00:05:46,397 --> 00:05:51,127 what's already there, and understanding is the part that hasn't gotten any faster. 81 00:05:52,127 --> 00:05:55,977 Change the relative price of two activities, and you get more 82 00:05:55,977 --> 00:05:58,127 of the cheaper one every time. 83 00:05:59,057 --> 00:06:02,387 So a developer under schedule pressure hits a problem that 84 00:06:02,387 --> 00:06:03,817 a shared helper would solve. 85 00:06:04,447 --> 00:06:08,267 The old cost of finding that helper, reading it, and adapting 86 00:06:08,267 --> 00:06:10,607 it was maybe 20 minutes. 87 00:06:11,197 --> 00:06:13,757 Generating a fresh one is 20 seconds. 88 00:06:15,037 --> 00:06:16,977 Nobody made a bad decision there. 89 00:06:17,637 --> 00:06:22,107 They made the cheap one 40 times a week for three years. 90 00:06:22,967 --> 00:06:28,557 That's how a code base gets 81% more duplication without a single engineer 91 00:06:28,597 --> 00:06:33,467 ever deciding to write duplicate code Two objections to this, and I think 92 00:06:33,477 --> 00:06:35,117 one of them is a fair objection. 93 00:06:35,527 --> 00:06:37,017 The first is about the metric. 94 00:06:37,627 --> 00:06:42,227 GitClear counts lines and line-level measures have never 95 00:06:42,227 --> 00:06:44,037 been a great proxy for quality. 96 00:06:44,917 --> 00:06:48,197 A duplicated block might be the right call. 97 00:06:49,027 --> 00:06:52,367 Some copy and paste is actually cheaper than the wrong abstraction. 98 00:06:53,487 --> 00:06:58,077 All of that is true, and it's why I'd focus less on the absolute numbers and 99 00:06:58,077 --> 00:07:00,197 more on the direction of the arrow. 100 00:07:01,547 --> 00:07:06,117 Every signal in the report moves the same way over three years. 101 00:07:07,007 --> 00:07:13,857 Duplication's up, reuse down, refactoring down, old code untouched. 102 00:07:14,427 --> 00:07:20,097 When six measurements that could disagree all agree, something 103 00:07:20,097 --> 00:07:21,887 real is happening underneath them. 104 00:07:22,887 --> 00:07:24,917 The second objection is the interesting one. 105 00:07:25,427 --> 00:07:30,517 If AI made writing code nearly free, why can't it do the refactoring as well? 106 00:07:31,397 --> 00:07:33,537 Well, it can, sometimes. 107 00:07:33,827 --> 00:07:36,727 I've watched it do a good job on a mechanical extraction 108 00:07:36,727 --> 00:07:38,257 across a handful of files. 109 00:07:39,017 --> 00:07:42,107 But refactoring isn't mostly a typing problem. 110 00:07:42,537 --> 00:07:47,447 It's a decision about what the code should have been made by someone who knows what 111 00:07:47,447 --> 00:07:52,327 the system is for and what other changes might be coming in the next two quarters. 112 00:07:53,147 --> 00:07:57,637 The model doesn't know any of that, and the person under schedule pressure 113 00:07:57,647 --> 00:07:59,377 isn't going to stop and explain it 114 00:08:00,377 --> 00:08:05,037 So the AI code tooling is getting better at the part that was already 115 00:08:05,037 --> 00:08:09,127 fast, and it isn't helping at all for the parts that are tough. 116 00:08:10,587 --> 00:08:14,977 Which means use it in moderation was too soft of a statement. 117 00:08:15,577 --> 00:08:19,847 It puts the weight on individual restraint, and this isn't an 118 00:08:19,857 --> 00:08:21,767 individual discipline problem. 119 00:08:23,087 --> 00:08:26,307 If I wrote that article today, I'd say things differently. 120 00:08:26,867 --> 00:08:28,497 Here's what I'd say instead. 121 00:08:28,967 --> 00:08:29,827 Three things. 122 00:08:30,117 --> 00:08:32,787 One, measure your own ratio. 123 00:08:33,767 --> 00:08:39,577 Take a month of commits in one repository and compare lines added to lines moved. 124 00:08:40,177 --> 00:08:44,327 If moved is under five percent, you have the industry-wide problem in 125 00:08:44,327 --> 00:08:48,377 your own code base, and now you have a number to watch and support it. 126 00:08:49,587 --> 00:08:56,147 Two, put cleanup on the roadmap as a real line item, not as something teams do when 127 00:08:56,147 --> 00:09:00,087 there's slack, because there hasn't been any slack since nineteen ninety-eight. 128 00:09:00,857 --> 00:09:05,817 If refactoring is the activity whose price didn't fall, it's the one that 129 00:09:05,817 --> 00:09:07,867 needs to be budgeted more than ever. 130 00:09:09,007 --> 00:09:12,707 And three, change what code review is looking for. 131 00:09:13,047 --> 00:09:16,637 Code reviews are good at catching a bad line of code. 132 00:09:17,317 --> 00:09:21,337 Code reviews are bad at catching the third copy of a function that already 133 00:09:21,337 --> 00:09:25,767 exists twice Because the third copy looks perfectly fine on its own. 134 00:09:26,647 --> 00:09:31,517 It's only wrong in the context of a code base nobody is reading as a whole. 135 00:09:32,787 --> 00:09:39,077 I'd rather see a team reject one duplicate a week than install another linter. 136 00:09:40,077 --> 00:09:43,177 What I'd keep from my twenty twenty-four article is the ending. 137 00:09:43,807 --> 00:09:48,717 AI generation is a tool that assists developers in building better systems, 138 00:09:49,197 --> 00:09:55,347 And the assist only works when somebody, some person owns the result. 139 00:09:56,347 --> 00:09:59,857 Two and a half years of data hasn't changed that. 140 00:10:00,447 --> 00:10:03,827 In fact, it's made it even more expensive to ignore. 141 00:10:05,097 --> 00:10:09,307 We're several years into a stretch where code bases are growing faster 142 00:10:09,317 --> 00:10:10,877 than anyone is maintaining them. 143 00:10:11,987 --> 00:10:14,657 The bill for that doesn't show up as an outage. 144 00:10:15,117 --> 00:10:18,977 It shows up as a team that can't ship a change to a system 145 00:10:19,267 --> 00:10:20,987 nobody understands anymore. 146 00:10:22,067 --> 00:10:28,817 And that's a slow failure, which is why it doesn't get a postmortem of its own Here's 147 00:10:28,827 --> 00:10:30,617 something you can start with this week. 148 00:10:31,707 --> 00:10:35,117 Pull the last month's commit for one repository. 149 00:10:36,267 --> 00:10:41,097 Compute two numbers, lines added and lines moved. 150 00:10:42,267 --> 00:10:46,237 Look at the ratio of those two numbers and decide whether you're comfortable with it. 151 00:10:47,127 --> 00:10:49,987 If you're not, you don't need a policy. 152 00:10:50,017 --> 00:10:55,154 You need one recurring item on the roadmap And a reviewer who's allowed to say, "We 153 00:10:55,154 --> 00:11:00,214 already have one of those The original 2024 article is linked in the show 154 00:11:00,214 --> 00:11:05,564 notes along with both GitClear reports, the one I read then and the new one 155 00:11:24,118 --> 00:11:27,028 Lee: Thank you for joining us on Software Architecture Insights. 156 00:11:27,628 --> 00:11:31,738 If you found this episode interesting, please tell your friends and colleagues. 157 00:11:32,158 --> 00:11:34,768 You can listen to Software Architecture Insights on all 158 00:11:34,768 --> 00:11:36,688 of the major podcast platforms. 159 00:11:37,708 --> 00:11:41,628 And if you want more from me, take a look at some of my many articles 160 00:11:41,628 --> 00:11:44,488 at softwarearchitectureinsights.com. 161 00:11:44,488 --> 00:11:50,388 And while you're there, join the 2000 people who have subscribed to my 162 00:11:50,388 --> 00:11:55,248 newsletter, so you always get my latest content as soon as it's available. 163 00:12:00,455 --> 00:12:03,305 Thank you for listening to Software Architecture Insights.