1. 34
  1.  

  2. 17

    This is Chuck Moore’s best piece of advice, imo:

    • Do Not Speculate!

    Do not put code in your program that might be used. Do not leave hooks on which you can hang extensions. The things you might want to do are infinite; that means that each one has 0 probability of realization. If you need an extension later, you can code it later - and probably do a better job than if you did it now. And if someone else adds the extension, will they notice the hooks you left? Will you document that aspect of your program?

    1. 20

      It’s equally important to know what not to code and how to not code it. In a misguided attempt to keep a program lean and simple, it’s easy to code yourself into a corner where that extension cannot be added. Sometimes it’s just because the code changes you’d need to make are big, but it’s even worse when you can’t change your design because other programs and people rely on the assumption that it’s not there.

      Single-threaded vs multit-hredead is a common example. If you are using shared mutable memory, you cannot just add it if your code is full of non-reentrant functions.

      Dr. Wirth has all my respect as a language designer and programmer, but the point about an 8k editor is a strawman. You still can make one, and it will be like editors from the 60’s—without all the features people might not be yearning for at that time because they were impossible, like syntax highlighting and autocompletion. Same goes for compilers. In my OCaml + vim + merlin setup, I can see the inferred type of any expression. A 32kbyte compiler would not be able to handle a type system that allows that, to begin with.

      1. 5

        I’m not going to argue against this advice as it is generally sensible, but saying that infinite possibilities mean each one has 0 probability is just distractingly bad math. There can easily be infinite number of possibilities with one of them being almost certain which is why this advice is only generally sensible.

        1. 1

          An average of 0 probability for any given extension at least

        2. 3

          Oof, I needed that.

          1. 1

            Very true! Sometimes not speculating is really hard.

          2. 7

            You’d probably like Wirth’s essay A Plea for Lean Software (pdf).

            1. 6

              Let me give you an example. Let’s say you have software that has only one purpose …

              Hah, if only life were that simple. I’m happy if I encounter a function with a single, clear purpose.

              1. 5

                I didn’t read all of it because it’s not very novel. I do want to say that I agree, but only as far as code quality. And having said that, I’ve come to think that there is either no or a negative relationship between code quality and long term career success in technology companies.

                1. 2

                  I once made a badly-drawn cartoon with a similar point: http://nathanmlong.com/2017/09/developer-experience-levels/

                    1. 2

                      “This is why I haven’t written a line of code in 3 years, and have taken up being a gardener during the day.”