Program state
Encyclopedia
One of the key concepts in computer programming
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...

 is the idea of state, essentially a snapshot of the measure of various conditions in the system. Most programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

s require a considerable amount of state information in order to operate properly - information which is generally hidden from the programmer. For a real-world example, consider a three-way light switch. An ordinary switch turns on a light when it's in the "up" position, but in a three-way switch the "up" position could be on or off, depending on the state or "configuration" of the other switch, which is likely out of view.

In fact, the state is often hidden from the computer's hardware as well, which normally has no idea that this piece of information determines program state, while that piece is a temporary variable and will soon be discarded. This is a serious problem, as the state information needs to be shared across multiple processors in parallel processing machines. Without knowing which state information is important and which isn't, most languages force the programmer to add a considerable amount of extra code to indicate which data and parts of the code are important in this respect.

In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, imperative programming
Imperative programming
In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state...

 is opposed to declarative programming
Declarative programming
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than...

. Imperative programming is a programming paradigm
Programming paradigm
A programming paradigm is a fundamental style of computer programming. Paradigms differ in the concepts and abstractions used to represent the elements of a program and the steps that compose a computation A programming paradigm is a fundamental style of computer programming. (Compare with a...

 that describes computation in terms of a program state
State (computer science)
In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as lexers and parsers....

 and statements that change the program state.

See also

  • Dataflow programming
  • Imperative programming
    Imperative programming
    In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state...

  • State (computer science)
    State (computer science)
    In computer science and automata theory, a state is a unique configuration of information in a program or machine. It is a concept that occasionally extends into some forms of systems programming such as lexers and parsers....

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK