5
$\begingroup$

Before becoming a teacher, I believed that pseudo code was a relic from the past (see also my question on goto and flowcharts):

When all you have is assembler language, Fortran, and Cobol, and no one has invented a compiler for a structured languages, then you need to write pseudo code. That is write in a high-level language, and compile it by hand. Now we can write it in a high-level language and get the machine to compile it, so is there a need for pseudo code?


Note I have now changed my view, somewhat, on pseudo code, but not on flowcharts and goto see my answer below. Please add your own answer, if you have I different perspective.

$\endgroup$
2
  • $\begingroup$ I feel this question is lacking a clear definition... Is your Pseudo-Code just a weakly structured language with implicit gap filling? The Arm Architecture defines a formalised Pseudo-Code which is used to completely describe the architecture... $\endgroup$ Sep 28, 2017 at 14:50
  • $\begingroup$ sudo code: “The command you type to get the computer to do a task as admin?” — One pupil of mine. $\endgroup$ Oct 3, 2017 at 10:00

3 Answers 3

7
$\begingroup$

Yes, definitely. There is a need, while developing an algorithm, for a language (or diagramming technique) that is less precise and requires less detail than a formal programming language. This is to let the developer expand his/her thoughts from an overall view to one that is more and more refined. This is true even for high-level languages, though the language itself may be useful for that given a test-first design methodology and good tools.

A pseudo-code is also useful for presenting algorithms in a language neutral way so that implementers may build to suit a need in the language of their choice.

I note, especially, that The Science of Programming by David Gries uses such a pseudo code throughout. The code is defined in the book and fairly precise, though leaves out many details needed for implementation. It is the same language, in fact, that Edsger Dijkstra used in his papers. I used several variations on it as the basis of a compiler course for many years. The Gries book should be on the bookshelf (and in the mind) of every serious computer scientist, and most programmers.


Programming involves several tasks at different levels of abstraction. A good pseudocode lets a programmer focus first on the overall, high level, concepts, without having to change focus, or get distracted by, the lower level details needed for implementation. Even if you use "misspelled java" as your pseudocode you have gained this separation of concerns as long as your development environment doesn't complain too visibly or loudly as you go.

Teaching this separation of concerns to students, via some formal or informal pseudocode, is a way to get them to develop algorithms from the outside-in rather from the top-down (i.e. top of page to bottom of page). That is to say, from the general to the specific, rather from the first statement to the last. Some students seem to want to work in that way initially. The sooner they develop better habits, the sooner they can progress.

$\endgroup$
2
  • $\begingroup$ Yes, when reading this, is realised that as a professional developer I have sometimes invented a Domain Specific Language, and used that to help me design a program. Because I had not written a compiler for it, it was a pseudo-code. $\endgroup$ Sep 28, 2017 at 13:12
  • 1
    $\begingroup$ Sometimes, I have wondered if pseudocode is actually more useful to students who have learned basic programming rather than complete beginners. To be able to write good pseudocode, the programmer needs to be able to pinpoint the appropriate level of abstraction which is something beginners have a hard time doing. $\endgroup$
    – fnurl
    Oct 1, 2017 at 21:18
4
$\begingroup$

Pseudo-code allows expressing that an algorithm to solve some problem is not the same as the syntax (formatting, punctuation abuse, etc.) required to make any particular compiler or interpreter happy.

Pseudo-code is also suitable for algorithms using data types that are not directly expressible in a standard programming language, such as real physical objects with the kids in the room acting as the operators and sequencers, etc.

It also requires less writing (characters, punctuation) on a chalkboard/whiteboard.

$\endgroup$
1
$\begingroup$

While I think that it is correct that a professional programmer does not need pseudo code (as other high level languages are available), and that management should not encourage programmers to design in pseudo code. I do think that there is value in education.

Some exam bodies views

AQA

“Questions in the written examination that involve code will use this pseudo code for clarity and consistency. However, students may answer these questions in any valid format.” — http://filestore.aqa.org.uk/subjects/AQA-GCSE-COMPSCI-W-TRB-PSEU.PDF

AQA have also stated that they have tested there pseudo code, by building a compiler. And that they compile and test all code that is used in questions.

OCR

“The following guide shows the format pseudocode will appear in the examined components. It is provided to enable teachers to provide learners with familiarity before the exam. Learners are not expected to memorise the syntax of this pseudocode and when asked may provide answers in any style of pseudocode they choose providing its meaning could be reasonably inferred by a competent programmer.” — http://www.ocr.org.uk/Images/260952-pseudocode-guide-teacher-guide.pdf

WJEC

“Is there an agreed convention for writing pseudo code in this course? There is no agreed convention, and appropriate pseudocode is rewarded with marks.” — (Can't find link)

Summary

Therefore these exam boards do not insist that students write in pseudo code, an answer in python can receive the same marks. Pseudo code is just the exam boards way of having one language for all in questions, and of being lenient on syntax of answers. AQA's (and may be the others) pseudo code, as used in questions, is a real high level language, nothing pseudo about it.

A learning perspective.

Just as pseudo code was useful in the past, before compilable high-level languages existed. It is of equal value today when learning your first language. For a learner, they have no compilable high-level languages available, as this is what they are learning. Therefore it can be useful to be able to express themselves in pseudo code.

When I was learning to program, I would first write it in pseudo code, then convert it into comments, and then one line at a time translate it into the language that I was learning. This translation phase, involved a lot of looking stuff up in a book. I still sometimes, but infrequently, do this.

It is important though to note, there is no point in formally learning a pseudo code. This results in the boot-strap problem (we learn a to help us learn b, but first we have to learn a, but a is no easier to learn than b). The pseudo code that the student uses will evolve, to become more and more like the language that they are learning, and will become less and less used.

$\endgroup$
1
  • $\begingroup$ In the now OCR spec, they have changed most references to pseudo code to (some thing like) reference language. $\endgroup$ Dec 24, 2019 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.