In defence of pseudocode

By Eirini Kolaiti. Posted

Eirini Kolaiti explores whether describing code in simple English can support the teaching and assessment of programming skills

When I used to teach programming it didn’t take me long to realise how easily my students could confuse or even forget basic structural elements of a programming language. They would be tripped up by misusing capitalisation, white space, or parentheses. Basic syntax errors like these would sidetrack students from focusing on developing a solution. Instead, they would resort to trying out every possible instruction they could find online in the hope that it would solve their errors. It turns out that my experiences weren’t unique, and are also supported by research in computing education.

The case for simple languages

In 2006, Linda Mannila and colleagues from the Turku Centre for Computer Science in Finland compared 60 programs written by students aged 16–19 after their first programming course, in either Python (a simple language, developed for its readability) or Java (a more advanced language). They analysed the assignments in terms of both syntax and logic errors, and overall functionality. 

The results were remarkable. Programming in Python not only helped students avoid making syntax errors, but it also allowed them to solve the given problem. The percentage of Python programs that ran correctly and fulfilled the intended purpose was more than double the Java programs. 

One potential drawback of teaching programming in Python rather than a more complex language, such as Java, is that it does the students a disservice – that they would need to relearn aspects of programming when moving to a less intuitive language, like Java. However, the team did not find this to be the case: students who had first learned with Python were at no disadvantage when switching to Java. 

So, if choosing a simple language can play such a positive role in student progression, why not opt for that option?

From simple to pseudocode

Allison Elliot Tew and Mark Guzdial took the matter of programming language choice even further. In 2011, they developed a way of comparing the knowledge of university students who took introductory programming courses in Java, Matlab, and Python. They wanted to make the assessment language-independent, so they used pseudocode instead of any of the taught programming languages. Pseudocode makes use of simple English to describe what a program does. It is laid out in a similar manner to a programming language, but removes some of the clutter that is needed for the machine to understand the code, which increases the complexity to a human reader. 

The results demonstrated that a pseudocode-based assessment can accurately determine the students’ competency regardless of their programming background. This means that students could transfer their comprehension of fundamental programming concepts to pseudocode notation. Reversing this logic, surely we can use pseudocode to scaffold the learning of programming concepts.

Walk before you run (a program)

In 2004, an international group of researchers, led by Raymond Lister at the University of Technology in Sydney, conducted a study regarding programming competency across seven countries. Instead of asking students to produce their own programs, the researchers examined whether students could understand existing code (written in Java or C++), for example, by predicting the output of a given program. The results suggest that what stops many students from performing well in programming tasks is not a lack of ability to problem-solve, but a fragile knowledge of fundamental concepts. Students were unable to hand-trace code (where the values of variables are calculated by hand) because of an inefficient command of basic programming tasks, such as iterating over an array or the use of recursion. These areas are mostly related to an ability to read, rather than write, code. 

I would therefore argue that as educators we should use programs in pseudocode to foster these preliminary skills, so that students benefit from a reduction in the cognitive load caused by language-specific syntax. After all, most programming languages are not designed with the aim of teaching programming in mind, whereas pseudocode can be adapted to meet the needs of the students. 

Pseudocode activities can be used in lessons in order to practise reading and tracing code, and as an opportunity to discuss basic programming concepts. Students could then convert the pseudocode programs (their own or each other’s) into compilable code. This gives them the opportunity to experiment with how to implement algorithmic constructs using the specific features of a programming language, and how to deal with syntax errors. Having the stepping stone of pseudocode therefore helps with the skills needed to test and debug algorithms, 

Pseudocode can also be used for formative assessment. Low-stakes tests and starter activities that use pseudocode snippets to test specific misconceptions can help unpack the underlying processes of program execution. I have found that challenging students with small, targeted pseudocode programs helps with engagement and information retention. In this way, pseudocode could pave the way towards gaining fundamental knowledge and skills through reading and tracing code before moving on to writing actual programs and dealing with the inevitable corollary of syntax errors.

Pseudocode activities

Here are some ideas for ways to incorporate pseudocode into your teaching:

  • Start activities with pseudocode to discuss concepts and then convert into code to deal with syntax errors, and to test/debug the algorithm and check the structure of the algorithm. It should be easier to write an algorithm after students have worked on a pseudocode version, rather starting with a programming language

  • Ask students to write a program using pseudocode and then swap with a partner for writing it in a programming language

  • Give snippets of pseudocode to test basic misconceptions, for example in the use of recursion

  • Give small programs that students can hand-trace, writing out the values of variables as the program progresses, to check their skills at understanding code

Further reading


Pseudocode at GCSE

I recently asked GCSE Computer Science teachers on Twitter which type of pseudocode they used for designing programs. 38% followed the exam board specific pseudocode and 53% did not specify a syntax. Several commented that it was much more important that learners could effectively design their own programs and the syntax used was less relevant.

GCSE Computer Science pseudocode survey.

There is currently no requirement for students to write using a specific pseudocode syntax. However, most exam boards have their own unique approach to pseudocode that they use for presenting questions. Students will need to be familiar with these to answer the questions successfully. Exam questions will indicate the form or response required, whether it’s a specific programming language, natural English, pseudocode, or flowchart. 

- Rebecca Franks, Learning Manager at the Raspberry Pi Foundation


https://www.twitter.com/eirinikolaiti

Educator

Free

If you’re a UK-based teacher, volunteer, librarian or something in between, we'll send each issue free to your door.

Digital

Free

Just want to read the free PDF? Get each new issue delivered straight to your inbox. No fuss and no spam.

Buy

From £6

If you are UK-based but not involved in education, you can get hard copies by buying back issues or subscribing via our partner service.