What is psuedocode?

Featured image

Pseudocode is the representation of code.

Pseudocode is used when you are trying to explain a programming concept, or to describe how you plan on implementing some functionality in your program, without the constraints of making it syntactically correct.

Take almost any previous article on this site and you will find pseudocode. In What are loops we introduced the concept of a list and a loop:

-- list --

recipients = James, John, Jimmy, Jane, Jake, Jemma, Joanne, Juliet, Jessica, Josh

-- Loop --

for $name in recipients {
    Dear $name

    .... body of letter ....
}

As far as I know, neither of these are valid in any programming language, by which I mean if you tried to use them, as they are written above, you’d get errors and the program wouldn’t run.

They were added to the articles because it makes the process of explaining much easier. They say a picture says a thousand words, I think the same is true for code examples. Imagine reading all of the previous examples without the pseudocode examples, would you have understood them?

You may now be wondering why use pseudocode at all. If code examples make the process so much easier, why not just write syntactically correct code that can be executed? There are a lot of programming languages out there. We could explain these concepts in one programming language, but then it would only work for that one language. We could explain these concepts in all of the programming languages, but then these articles would become very long and very repetitive.

So we show you the concepts using pseudocode so you can focus on the concepts, not one specific programming language implementation.

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.