LLMs and code duplication

I’m working on a project for which I’m using Go, as well as LLMs, mostly Sonnet 4.5 via Claude Code. I’ve noticed that it is frequently passing up on opportunities to factor out common code. But I’m not at all sure this is a bad thing. Here is an example, which I’ve chosen as relatively short but it illustrates a pattern which is relatively common: if config.DatabaseType == "postgres" { query = ` SELECT p.slug, COALESCE(NULLIF(p.menu_title, ''), p.title) as menu_title FROM pages p INNER JOIN site_pages sp ON sp.page_id = p.id AND sp.site_id = $1 WHERE sp.is_homepage = false AND sp.site_id = $1 ORDER BY p.title ` } else { query = ` SELECT p.slug, COALESCE(NULLIF(p.menu_title, ''), p.title) as menu_title FROM pages p INNER JOIN site_pages sp ON sp.page_id = p.id AND sp.site_id = ? WHERE sp.is_homepage = 0 AND sp.site_id = ? ORDER BY p.title ` } Ignore the fact that there may be better ways to handle differences between database flavours. The point here is that these two queries are almost identical, except for the parameter placeholder and boolean value. A much better way to write this would be to have a single query with the differences parameterized: ...

December 16, 2025

Link: Useful patterns for building HTML tools

Self-recommending absolutely bangning post from Simon Willison regarding combining HTML, Javascript, and CSS into a single file, which can then be served on static hosting. The post itself is obviously worth reading, but additionally you can browse his extensive collection of HTML tools: You can explore my collection on tools.simonwillison.net—the by month view is useful for browsing the entire collection. Some excellent tips including a collection of API resources that provide open CORS headers (which means you will be able to call the API from your HTML file hosted on a different domain name to the API). ...

December 11, 2025

More on A.I. Water usage - Empire of A.I.

A few weeks ago I wrote about an issue in the book ‘Empire of A.I.’ by Karen Hao. There is now a much more in-depth look into this issue by Andy Masley. It includes a response from the author and Andy’s response to that response is well worth reading even if you don’t read the main (very detailed) post. I think both are writing in good faith here, it must be terrible to work on a book only to find you have published an error, which does seem to materially change a (fairly large) point you are making in your book. I do think Andy is correct though. ...

November 24, 2025

A.I. Water usage - Empire of A.I.

Update: 2025-11-24 Andy Masley has a much more in-depth look at this is issue, including a response from the author, and his response to that response is well worth reading. I’ve been following some of the debate on the water usage of LLMs. A lot of people seem concerned that this is a large issue. I’m not sure either way, but I’m coming round to the view that water usage is not a major concern, in comparison to, for example, the energy usage. ...

November 3, 2025

Link: Where's all the shovelware?

A couple of weeks back after the GPT-5 release, I wrote a skeptical post that the fact that the GPT-5 model picker release was botched was something of a bearish sign for llm-assisted programming: Okay, but if OpenAI cannot utilise their own models in coding/dev-ops to avoid a high-profile failure on a very high importance launch, what chance do other companies have? Why hasn’t the A.I. enabled OpenAI to improve their development/deployment strategies to avoid such techincal glitches? ...

September 4, 2025

AI agent programming and files as modules

For a long time I’ve been sceptical that using the file system to denote modules in a programming language is necessary. There are many good reasons to do this as things currently stand, but most of these reasons can, and arguably should, be solved with better tooling. For example from the post linked to above: why would we equate a file to a form of encapsulation? Why, would we wish to divide any application into a bunch of files in the first place. If you ask this question, you get a bunch of answers, but they mostly fall into two categories: 1. some vague notion about organisation and modularising your code and 2. it is easier to navigate whilst coding. I would argue that the first is nonsense, since no one is arguing against modularising code, only that the file system does not need to come into it. The second is potentially true, but rather speaks to a deficiency in your coding environment (text editor/IDE) rather than to the efficacy of using files to modularise a program’s source code. ...

July 3, 2025