Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but typically omits details that are not essential for the understanding of the algorithm, such as subroutines, variable declarations and system-specific code. In Communications a code is a rule for converting a piece of Information (for example a letter, Word, Phrase, or In Mathematics, Computing, Linguistics and related subjects an algorithm is a sequence of finite instructions often used for Calculation A programming language is an Artificial language that can be used to write programs which control the behavior of a machine particularly a Computer. In Computer science, a subroutine ( function, method, procedure, or subprogram) is a portion of code within a larger In Programming languages, a declaration specifies the Identifier, type, and other aspects of language elements such as variables and functions The programming language is augmented with natural language descriptions of the details, where convenient, or with compact mathematical notation. In the Philosophy of language, a natural language (or ordinary language) is a Language that is spoken or written in phonemic-alphabetic or phonemically-related The purpose of using pseudocode is that it may be easier for humans to read than conventional programming languages, and that it may be a compact and environment-independent description of the key principles of an algorithm. No standard for pseudocode syntax exists, as a program in pseudocode is not an executable program.
Flowcharts can be thought of as a graphical alternative to pseudocode. A flowchart is a Schematic representation of an Algorithm or a stepwise process, showing the steps as boxes of various kinds and their order by connecting Pseudocode resembles, but should not be confused with, skeleton programs including dummy code, which can be compiled without errors. Skeleton programming is a style of Computer programming based on simple high-level program structures and Dummy code. In Computer programming, dummy code is inserted in a program skeleton to simulate processing and avoid compilation error messages A compiler is a Computer program (or set of programs that translates text written in a computer language (the source language) into another
Contents |
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. Scientific literature comprises scientific Publications that report original empirical and theoretical work in the natural and Social sciences Computer science (or computing science) is the study and the Science of the theoretical foundations of Information and Computation and their Numerical analysis is the study of Algorithms for the problems of continuous mathematics (as distinguished from Discrete mathematics) 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. Donald Ervin Knuth (kəˈnuːθ (born 10 January 1938) is a renowned computer scientist and Professor Emeritus of the Art of Computer The Art of Computer Programming is a comprehensive Monograph written by Donald Knuth that covers many kinds of Programming Algorithms See the terminology section below for information regarding inconsistent use of the terms assembly and assembler A microprocessor incorporates most or all of the functions of a Central processing unit (CPU on a single Integrated
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. A programmer is someone who writes Computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist 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.
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. In Linguistics, syntax (from Ancient Greek grc συν- syn-, "together" and grc τάξις táxis, "arrangement" is the Popular syntax sources include Pascal, BASIC, C, Java, Lisp, and ALGOL. Pascal is an influential imperative and procedural Programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small In Computer programming, BASIC (an Acronym for Beginner's All-purpose Symbolic Instruction Code) is a family of High-level programming languages tags please moot on the talk page first! --> In Computing, C is a general-purpose cross-platform block structured Lisp (or LISP) is a family of Computer Programming languages with a long history and a distinctive fully parenthesized syntax Algol (β Per / Beta Persei known colloquially as the Demon Star, is a bright Star in the Constellation Perseus. 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.
An example of how pseudocode differs from regular code is below.
Regular code (written in PHP):
<?php if (is_valid($cc_number)) { execute_transaction($cc_number, $order); } else { show_failure(); } ?> |
Pseudocode:
if credit card number is valid then execute transaction based on number and order else show a generic failure message end if |
The pseudocode of the Hello world program is particularly simple:
output: Hello World
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. PHP is a computer Scripting language. Originally designed for producing Dynamic web pages it has evolved to include a Command line interface capability A "Hello World" program is a Computer program that prints out "Hello world!" on a Display device. Numerical analysis is the study of Algorithms for the problems of continuous mathematics (as distinguished from Discrete mathematics) In Mathematics, a matrix (plural matrices) is a rectangular table of elements (or entries) which may be Numbers or more generally In the Philosophy of language, a natural language (or ordinary language) is a Language that is spoken or written in phonemic-alphabetic or phonemically-related 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. In Mathematics, Computing, Linguistics and related subjects an algorithm is a sequence of finite instructions often used for Calculation
Normally non-ASCII typesetting is used for the mathematical equations, for example by means of TeX or MathML markup, or proprietary formula editors. American Standard Code for Information Interchange ( ASCII) Typesetting involves the presentation of textual material in graphic form on Paper or some other medium. TeX (ˈtɛx as in Greek, often /ˈtɛk/ in English; written with a lowercase 'e' in imitation of the logo is a Typesetting system designed and mostly Mathematical Markup Language ( MathML) is an application of XML for describing mathematical notations and capturing both its structure and content A formula editor is a name for a computer program that is used to typeset mathematical works or formulae
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, and pidgin C. In Computer programming, pidgin code is a mixture of several Programming languages in the same program or Pseudocode that is a mixture of a programming Algol (β Per / Beta Persei known colloquially as the Demon Star, is a bright Star in the Constellation Perseus. Fortran (previously FORTRAN) is a general-purpose, procedural, imperative Programming language that is especially suited to In Computer programming, BASIC (an Acronym for Beginner's All-purpose Symbolic Instruction Code) is a family of High-level programming languages Pascal is an influential imperative and procedural Programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small tags please moot on the talk page first! --> In Computing, C is a general-purpose cross-platform block structured
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. In the Philosophy of language, a natural language (or ordinary language) is a Language that is spoken or written in phonemic-alphabetic or phonemically-related
Various attempts to bring elements of natural language grammar into computer programming have produced programming languages such as HyperTalk, Lingo, AppleScript, SQL and Inform. HyperTalk is a high-level Programming language created in 1987 by Dan Winkler and used in conjunction with Apple Computer 's HyperCard hypermedia The name Lingo has been used by several unrelated programming languages AppleScript is a Scripting language devised by Apple Inc, and built into Mac OS. Inform is a Programming language and design system for Interactive fiction originally created in 1993 by Graham Nelson. 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.
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. A specification language is a Formal language used in Computer science. Examples are:
Some array programming languages include vectorized expressions and matrix operations as non-ASCII formulas, mixed with conventional control structures. In Computer science, array programming languages (also known as vector or multidimensional languages generalize operations on scalars to apply Examples are: