DEV Community

Si for CodeTips

Posted on • Originally published at codetips.co.uk on

What is pseudocode?

Pseudocode is the representation of code.

What is pseudocode?

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.

Top comments (4)

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Pseudocode is the hottest new language you should learn in 2019 😁

Collapse
 
devdrake0 profile image
Si

The latest stackoverflow survey has the average salary for pseudocode at 500k. πŸ˜‚

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Wait.. as soon as a programmer writes invalid code, you might argue that this is now pseudocode, and so you should be paid 500k to transpile this code back to valid code πŸ˜‰.

Thread Thread
 
devdrake0 profile image
Si

Wait.... I have to fix bugs every day at work. Surely that means I'm actually translating the invalid (pseudocode) back to valid code?

So I'm effectively a pseudocode programmer and a pseudocode -> JavaScript/Go compiler?

I think I'm going to need to ask for a payrise on Monday.....