What is a Pseudocode?
Pseudocode is a method of writing out an algorithm or code concept in a way that makes it easy for people to read and understand. While it may structurally resemble a programming language, pseudocode isn't actually meant for a machine to read or process. Within the general structural conventions of a programming language, it may include explanations using natural language, mathematical formulas, and other notations. It is often used in various publications to illustrate the function of an algorithm, or in the planning stages for a computer program before any actual code is written.
One common use of pseudocode is in textbooks and scientific publications. By omitting many of the things that differentiate one programming language from another, it may allow a high level understanding of an algorithm by many different people, regardless of the programming languages they know. An algorithm is a set of steps or instructions designed to give a particular result, and one commonly makes up the backbone of computer programming. This may make the ability to understand algorithms, across different programming languages, very useful.
The other main use of pseudocode is to get down the general functions of a new program before writing any real code. This may allow a programmer to view things in a top-down manner, conceptualizing the entire system before getting bogged down in the actual coding. Another form that this process may take is the use of a graphical structure, such as a flow chart.
Skeleton programming is similar to pseudocode, though it differs in that it can actually be compiled without errors. Pseudocode follows the structural conventions of programming languages, while omitting many of the things code requires to be successfully parsed. The purpose of skeleton programming is merely to get a high level program up and running quickly, while utilizing dummy code for many functions that will be filled in later. This makes it similar in function to planning tools, with one resulting in an actual, working program and the other being more like a non-working mock-up.
Another use of pseudocode is in the explanation of certain mathematical algorithms. By combining mathematical notations from set and matrix theory with a generic programming structure and natural language, it may become possible to easily explain a variety of mathematical algorithms. Though it may require mathematical training for this to work, people with such training will generally be able to understand such algorithms regardless of their other backgrounds.
@NathanG - I am truly grateful for examples of pseudocode that are available online and in textbooks.
I am not ashamed to admit that most of my initial programming work is done in some variant of BASIC, so I appreciate it when a much needed algorithm is demonstrated in pseudocode rather than in C++ or some other really technical language.
With pseudocode I now have access to everything from a simple bubble sort algorithm to a simulation of a neural network. Believe it or not, I can duplicate these algorithms in BASIC just as easily as another programmer can write it in C++. The program logic is what counts, not the underlying language.
@m3g4n - While I agree that pseudo code itself is not a programming language, it can be syntactically similar to languages meant to provide basic scripting for an application.
For example, years ago I bought Macromedia Director. Director has its own programming language called Lingo. However, when I looked at the examples of the code, it was almost as if I was writing pseudocode to get the application to do what I wanted.
They had abstracted the concepts to such a high level that the programming constructs were almost in complete sentences; it looked less like a language and more like an explanation of what the compiler was supposed to do.
This was in the early days of the product, and I think this was meant to make it accessible to people who didn’t have a programming background; most early users were in fact graphic designers so I understood this approach.
@Animalz – I’d be glad to post a pseudocode example! This might not make sense to people who don’t know much about programming, but here it is:
if red button is pressed
(then add in a tab here) stop the car animation
(add in another tab) print “It’s still going!”
As you can see, when you use pseudocode, you leave out the curly brackets, semicolons, and other symbols that your chosen programming language uses in its finished code.
By the way, “print” here means “show this text on the screen”, not “print this text onto some paper”.
What does a pseudocode look like? I only use flow charts when I plan my coding, so I’m having a hard time visualizing a pseudocode. Could someone post an example?
So, there’s actually a name for the gibberish I write when I’m working out how to program something? I’d never even heard the word “pseudocode”, but I’ve been using it for years!
Pseudocode really helps me develop algorithms before I start the actual coding. It gives me a chance to get my ideas down on paper and make sure everything will work together to achieve the outcome I want.
I don’t have all of the commands memorized for the programming language I work with. But I don’t have to worry about that when I plan programs in pseudocode. I can just write down what I want the coding to achieve, then later I can look up the exact commands I need. It’s much easier that way.
Post your comments