IT Pro is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more
In-depth

What is pseudocode?

We take a closer look at the descriptive take on programming languages

Pseudocode spelt out in wooden blocks in front of code text

Whether you’re a professional developer, hobbyist, total novice, or just someone who has hit F12 in a web browser, we’ve all seen pages full of code. For the uninitiated, however, high-level languages complete with unique types, keywords, syntaxes and more, can be difficult to decipher.

Pseudocode aims to bridge the gap between code and plain English, allowing developers to explain more clearly to non-developers what a specific feature or algorithm achieves in an application.

The code written by developers is meant to be readable by machines, not humans. Machines are far better equipped to read endless parentheses, curly brackets, and pipes than we are; we're simply too used to the comparatively inefficient letters, words, and symbols. Pseudocode strikes a balance between the two, explaining complex computer science concepts to those who don’t have a deep understanding of programming.

Why is pseudocode code used?

Two people looking at code on a computer monitor

Pseudocode keeps some aspects of the language intact in its representation; if you were explaining how to create a loop in pseudocode, you may still use the ‘for’ keyword but you may choose to omit ‘var’ and ‘let’ keywords to describe variables and constants. Common syntax seen in popular programming languages can also go out the window; instead of assigning values to properties with ‘=’, you may simply use an arrow to show which value belongs to which property in code.

Just in the same way we humans use our native languages differently to accommodate different audiences and purposes, writers of pseudocode can get creative with how they represent complex structures in a way that’s more familiar to other people. There is no strict style or syntax for pseudocode, it’s all about translating machine code for humans in the clearest way possible.

Related Resource

The data-driven enterprise

How organisations can truly make the most of their data

Whitepaper cover with aerial view of a city and river with digital linesFree Download

This form of coding is often used to map out or pre-plan how a programme will work before then translating it into a real language. It's another way of planning, in that it could replace a series of flowcharts and unified modelling language charts that show how an algorithm or system works, as well as its key aims. This is especially useful for people who'd ideally want to ensure the core code is foolproof, and that whatever it is eventually translated into has a fixed point of reference in relatively plain English.

Pseudocode can also help to spot any potential flaws in the code before an app or algorithm is written out in full, which lends itself to a far more efficient process in the longer-term. When it comes to patching any errors in future, for example, the process could be much smoother.

Beyond the practical benefits of pseudocode, programmers often use pseudocode as a point of reference to translate a piece of code from one language to another, as it documents the underlying functions and aims of a programme; almost like a translatory aid. But it can also be helpful to add any additional functions, in terms of visualising where these may fit into the overall programme.

So where are you likely to see it? Pseudocode is often found in scientific publications or textbooks where it can be used to help outline specifically how certain algorithms can be deployed in certain tasks and use cases. Overall it's useful for straightening out how a function would work for any users who aren't necessarily versed in a particular language they're working with at any given time.

Examples of pseudocode

As we've already mentioned, it's important to remember that pseudocode can't be fed into a computer, and is therefore only designed for other people to read. Below we've included an example of how we can potentially use pseudocode to write the 'FizzBuzz Algorithm' alongside how it's written in Python.

Pseudocode Python 

num : 1
FOR num -> 1 to 20
   IF num MOD 15 ===0
      PRINT “FizzBuzz”
   ELSE IF num MOD 3 ===0
      PRINT “Fizz”
   ELSE IF num MOD 5===0
      PRINT “Buzz”
   ELSE
      PRINT num
   ENDIF
ENDFOR

for num in range(1, 21):
   if num % 15 ==0:   
      print("FizzBuzz")   
   elif num %3 ==0:        
      print("Fizz")   
   elif num %5==0:       
      print("Buzz")   
   else:       
      print(num) 

Pseudocode can, however, be even more stripped back than the above example. Here's another example of pseudocode in action, again, versus its equivalent in Python.

Pseudocode Python 

Num : INTEGER

Num

Num = int(input("Please enter a number: ))

for Number in range (1,11):     

   print(Num*Number

In all cases, however, programmers advise that you use proper naming conventions, that you use indentation and white spaces, and that you keep it simple and concise. You shouldn't, on the flip side, make it too abstract or too generalised.

Featured Resources

Join the 90% of enterprises accelerating to the cloud

Business transformation through digital modernisation

Free Download

Delivering on demand: Momentum builds toward flexible IT

A modern digital workplace strategy

Free download

Modernise the workforce experience

Actionable insights and an optimised experience for both IT and end users

Free Download

The digital workplace roadmap

A leader's guide to strategy and success

Free Download

Most Popular

Raspberry Pi launches next-gen Pico W microcontroller with networking support
Hardware

Raspberry Pi launches next-gen Pico W microcontroller with networking support

1 Jul 2022
Xerox CEO John Visentin dies unexpectedly aged 59
Careers & training

Xerox CEO John Visentin dies unexpectedly aged 59

30 Jun 2022
Former Uber security chief to face fraud charges over hack coverup
data breaches

Former Uber security chief to face fraud charges over hack coverup

29 Jun 2022