Karl's Programming Lessons

Rules? What rules? There arn't any rules!

But there are lessons. Rules are to be followed, but lessions are to be applied using judgement.

Lessons that teach what, exactly?

Get it done fast, get it done right, get it done cheaply. Pick two.

These lessons are about the right way to write programs, for some value of "right". The particular value of right is expressed by the following:

Programs are written for people to read, and only incidentally for machines to execute.

The reasoning behind this is that unless someone knows what a program does, the program is useless.

There are some assumptions underlying these lessons. If you're going to run a program once, and then throw it away, none of this matters.

Or, you may be counting on AI telling you what the program does and never having a human read the code. As I write this, depending entirely on AI in this way, in the long term, is an untested approach. If you want to bet on keeping your programs running long-term, only with AI, go for it and good luck. This page is not for you.

I particularly question whether AI will be able to tell you why your programs are written the way they are written, which is part of what's involved in writing code for humans to read. If you don't know what problem your code is trying to solve, the "why" of your code, you don't really know what the code is doing.

Why bother to write this?

The short answer is that I feel like it.

The longer answer is that the AI written code I've seen is written like it was done by a programming novice. Albiet a novice with an infallable memory that has ingested a huge amount of the world-wide code-base.

Given Sturgeon's law, this means the AI has seen a huge amount of crap. As they say: Garbage in. Garbage out.

If you're writing code with AI assistance, read the code. Then, use your judgement. Should the code be changed in light of the lessons below?

The Lessons