Pseudocode

Pseudocode

Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading. Pseudo-code typically omits details that are not essential for human understanding of the algorithm, such as variable declarations, system-specific code and subroutines. The programming language is augmented with natural language descriptions of the details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it may be easier for humans to understand than conventional programming language code, and that it may be a compact and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications that are documenting various algorithms, and also in planning of computer program development, for sketching out the structure of the program before the actual coding takes place.

No standard for pseudocode syntax exists, as a program in pseudocode is not an executable program. Pseudocode resembles, but should not be confused with, skeleton programs including dummy code, which can be compiled without errors. Flowcharts can be thought of as a graphical alternative to pseudocode.

Application

Textbooks and scientific publications related to computer science and numerical computation often use pseudocode in description of algorithms, so that all programmers can understand them, even if they do not all know the same programming languages. In textbooks, there is usually an accompanying introduction explaining the particular conventions in use. The level of detail of such languages may in some cases approach that of formalized general-purpose languages — for example, Knuth's seminal textbook "The Art of Computer Programming" describes algorithms in a fully-specified assembly language for a non-existent microprocessor.

A programmer who needs to implement a specific algorithm, especially an unfamiliar one, will often start with a pseudocode description, and then simply "translate" that description into the target programming language and modify it to interact correctly with the rest of the program. Programmers may also start a project by sketching out the code in pseudocode on paper before writing it in its actual language, as a top-down structuring approach.

yntax

As the name suggests, pseudocode generally does not actually obey the syntax rules of any particular language; there is no systematic standard form, although any particular writer will generally borrow style and syntax for example control structures from some conventional programming language. Popular syntax sources include Pascal, BASIC, C, Java, Lisp, and ALGOL. Variable declarations are typically omitted. Function calls and blocks of code, for example code contained within a loop, is often replaced by a one-line natural language sentence.

Depending on the writer, pseudocode may therefore vary widely in style, from a near-exact imitation of a real programming language at one extreme, to a description approaching formatted prose at the other.

Examples of pseudocode

An example of how pseudocode differs from regular code is below.

The pseudocode of the Hello world program is particularly simple:

output: Hello World

Mathematical style pseudocode

In numerical computation, pseudocode often consists of mathematical notation, typically from set and matrix theory, mixed with the control structures of a conventional programming language, and perhaps also natural language descriptions. This is a compact and often informal notation that can be understood by a wide range of mathematically trained people, and is frequently used as a way to describe mathematical algorithms.

Normally non-ASCII typesetting is used for the mathematical equations, for example by means of TeX or MathML markup, or proprietary formula editors.

Mathematical style pseudocode is sometimes referred to as pidgin code, for example "pidgin ALGOL" (the origin of the concept), "pidgin Fortran", "pidgin BASIC", "pidgin Pascal", "pidgin C", and "pidgin Ada".

Machine compilation or interpretation

It is often suggested that future programming languages will be more similar to pseudocode or natural language than to present-day languages; the idea is that increasing computer speeds and advances in compiler technology will permit computers to create programs from descriptions of algorithms, instead of requiring the details to be implemented by a human.

Natural language grammar in programming languages

Various attempts to bring elements of natural language grammar into computer programming have produced programming languages such as HyperTalk, Lingo, AppleScript, SQL and Inform. In these languages, parentheses and other special characters are replaced by prepositions, resulting in quite talkative code. This may make it easier for a person without knowledge about the language to understand the code and perhaps also to learn the language. However, the similarity to natural language is usually more cosmetic than genuine. The syntax rules are just as strict and formal as in conventional programming, and do not necessarily make development of the programs easier.

Mathematical programming languages

An alternative to using mathematical pseudocode (involving set theory notation or matrix operations) for documentation of algorithms is to use a formal mathematical programming language that is a mix of non-ASCII mathematical notation and program control structures. Then the code can be parsed and interpreted by a machine.

Several formal specification languages include set theory notation using special characters. Examples are:
* Z notation
* Vienna Development Method Specification Language (VDM-SL).

Some array programming languages include vectorized expressions and matrix operations as non-ASCII formulas, mixed with conventional control structures. Examples are:
* A programming language (APL), and its dialects APLX and A+.
* MathCAD.

ee also

* Short Code
* Dummy code
* Pidgin code
* Skeleton program
* Structured English
* Concept programming

External links

* [http://www.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html A pseudocode standard]
* [http://calgo.acm.org/ Collected Algorithms of the ACM]
* [http://www.cs.cornell.edu/Courses/cs482/2003su/handouts/pseudocode.pdf Pseudocode Guidelines] , PDF file.
* [http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/ Pseudocode Programming Process] base on data from Code Complete book


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Pseudocode — ist Programmcode, der nicht zur maschinellen Interpretation, sondern lediglich zur Veranschaulichung eines Paradigmas oder Algorithmus dient. Meistens ähnelt er natürlicher Sprache und höheren Programmiersprachen. Mit Pseudocode kann ein… …   Deutsch Wikipedia

  • Pseudocode — Pseudocode,   P Code …   Universal-Lexikon

  • Pseudocode — pseudokodas statusas T sritis automatika atitikmenys: angl. pseudocode; quasi code vok. Pseudocode, m rus. квазикод, m; псевдокод, m pranc. pseudocode …   Automatikos terminų žodynas

  • pseudocode — pseudokodas statusas T sritis automatika atitikmenys: angl. pseudocode; quasi code vok. Pseudocode, m rus. квазикод, m; псевдокод, m pranc. pseudocode …   Automatikos terminų žodynas

  • pseudocode — pseudokodas statusas T sritis informatika apibrėžtis Neformalus, žmogui skirtas algoritmo užrašymo būdas, kuriame vartojami žymenys artimi natūraliai kalbai. Plačiau žr. priede. priedas( ai) MS Word formatas atitikmenys: angl. pseudocode …   Enciklopedinis kompiuterijos žodynas

  • Pseudocode — Pseudo code En programmation, le pseudo code est une façon de décrire un algorithme sans référence à un langage de programmation en particulier. L écriture en pseudo code permet souvent de bien prendre toute la mesure de la difficulté de la mise… …   Wikipédia en Français

  • pseudocode — noun A description of a computer programming algorithm that uses the structural conventions of programming languages but omits detailed subroutines or language specific syntax …   Wiktionary

  • Pseudocode — Hilfsmittel bei der ⇡ Programmentwicklung zur verbalen Formulierung eines ⇡ Algorithmus oder der Rohform eines ⇡ Programms. Die Darstellungsform orientiert sich an der Schreibweise einer ⇡ Programmiersprache. V.a. die ⇡ Steuerkonstrukte werden… …   Lexikon der Economics

  • pseudocode — pseuˈdocode noun (computing) Instructions written in symbolic language which must be translated into an acceptable program language before they can be executed • • • Main Entry: ↑pseud …   Useful english dictionary

  • Pseudo-Code — Pseudocode ist eine sprachliche Mischung aus natürlicher Sprache, mathematischer Notation und einer höheren Programmiersprache. Wie Flussdiagramme und Nassi Shneidermann Diagramme ist auch Pseudocode eine Möglichkeit um Algorithmen darzustellen.… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”