Skip to main content

Posts

Premature Optimisation: We Knew Better 50 Years Ago

All good software engineers want to write good code. Unfortunately, many software engineers believe that good code must always be efficient, leading them to optimise unnecessarily or prematurely. Code is written primarily for people to read, so it should be as clear and simple as possible. One of the few constants in software engineering is change, and clear, simple code is easier to change without introducing bugs. However, what good software engineers really want to write is good software. This is even more important in the new world of AI, but this isn’t an article about AI. I am not suggesting that code never needs to be optimised, or that an engineer shouldn’t consider performance when writing it. For example, a value that is expensive to evaluate but remains constant should be initialised outside a loop rather than recalculated on every iteration. However, halving the execution time of a 2ms calculation in a request that also makes a 40ms database call makes very little differenc...
Recent posts

Essays, Papers, White Papers and Articles: What's the Difference?

I've been writing and blogging for as long as I can remember, and I've never really understood the difference between articles, essays, papers and white papers. I've certainly never known when I should use each term. So I asked ChatGPT to explain the differences and when I should use each one. This is what it told me. It turns out there's quite a bit of overlap, but the main differences come down to purpose, audience, evidence and formality. Essays An essay is about exploring an idea, developing an argument or expressing a point of view. It's often personal, reflective and doesn't necessarily require extensive research or a formal structure. For example, I've been reading a lot about software optimisation recently, particularly the views of Donald Knuth, Michael Jackson, Brian Kernighan and P. J. Plauger. If I were to bring their ideas together, compare them with my own experience and reach a conclusion about premature optimisation, that would make a good es...

Introducing Omnilog: Logs. Metrics. Traces.

    OmniLog brings your observability data together, so you can understand what your systems are doing without jumping between tools. Send telemetry with OpenTelemetry , search your logs, chart your metrics and follow requests through distributed traces - all in one place. Your data stays private, and the information you need stays close at hand. Want to try OmniLog? Email me from: https://paulgrenyer.com/omnilog

Comments in Code: AI and the Last Resort

As I continue working on projects of my own, as well as those in my day job, I am learning more about the best ways to use AI to create software. Mostly Claude and sometimes Codex. One thing I cannot help noticing is the sheer number of comments AI adds to the code. In January 2025, I wrote a blog post called Comments in Code: Just Don’t Do It , in which I quoted Uncle Bob: It is well known that I prefer code that has few comments. I code by the principle that good code does not require many comments. Indeed, I have often suggested that every comment represents a failure to make the code self explanatory. I have advised programmers to consider comments as a last resort. I went on to say: Comments should always be “why”, never “what”, and only when     absolutely necessary. If you feel the need to write a “what” comment, put the code in     a well-named, meaning descriptive, function instead. I stand by this view. Comments should be few and far between and,...

Good Programming Style Never Gets Old

In my previous post, The Elements of Programming Style: still worth reading , I argued that the book is still worth reading. Going back through the rules made me think about which ones I would give to a developer today. Most need no help. Clear names, small modules, testing boundary values and measuring before optimising are as useful now as they were when Brian Kernighan and P. J. Plauger wrote the book. A few rules, though, speak in the syntax of Fortran and PL/I. Fortran is still used in scientific and high-performance computing, but many developers won’t recognise an arithmetic IF or a DATA statement. In those cases, I’ve kept the original rule and written a version that carries its advice into other languages. These are the 72 rules I took from my reading notes, in order. Where I’ve changed one, I’ve included the original, the updated rule and my reason. 1. Write clearly - Don’t be too clever 2. Say what you mean, simply and directly. 3. Use library functions. 4. Use temporary var...

Principles of Program Design - Don't do it.

  This book is unlikely to be of interest, unless you’re interested in data processing programs written in COBOL. However, I was interested in optimisation and the origin of: 1. Don’t do it.  2. Don’t do it yet. So I was satisfied with that at least. There are ideas here which have survived rather better than the examples, such as keeping programs simple, avoiding GO TO where possible and making each component responsible for validating the data it passes on. But much of the book is firmly rooted in the sort of data processing systems it was written for, and I struggled to relate many of the design techniques, particularly program inversion, to the way I think about software today. I did enjoy the occasional bit of personality, especially “A Moral Tale” and warnings to “resist this satanic temptation”. The exception was the chapter on optimisation, which was by far the most interesting part of the book. Jackson’s two rules are wonderfully simple: “Don’t do it” and “Don’t do it...

I, Robot

The Foundation series has been my go to for a good, enjoyable read over the last two years, so naturally I moved on to Asimov’s Robot series afterwards. However, the short stories in I, Robot were mostly a disappointment. They feel self indulgent, with too much philosophy and science, Asimov showing off, and not enough story. The most enjoyable moments come from the stories featuring Gregory Powell and Mike Donovan. Their banter and the relationship between them provide some much needed amusement and were easily the highlight of the book for me. However, it did give me food for thought for the current potential issues with the rapid development of AI at the moment, and the many concerns around safety. I wonder if all we need is: An AI may not injure a human being or, through inaction, allow a human being to come to harm. An AI must obey the orders given it by human beings except where such orders would conflict with the First Law. An AI must protect its own existence as long as such p...