5Concepts
Five Concepts Programming Languages Share
Programming languages are the means by which humans can express ideas in ways they understand to communicate them to computers in ways they understand. Programming languages must be translated from a human-intelligible form to a computer-intelligible form — usually by means of a compiler or interpreter.
Concepts
To understand how to communicate with a computer through programming, neophytes and beginning students must master (at least) five programming-language concepts that (mostly) all programming languages (mostly) share.
Sequence
- The concept that serial computers — those that understand imperative programming — execute instructions in a sequence that change a program’s state.
- A sequence is one of the structured programming control structures.
- A recipe is an analog of a sequence.
Selection
- The concept that computers can execute one of a number of statements depending on a program’s state.
- A selection is one of the structured programming control structures.
- A selection can be referred to as a conditional (statement) and is often represented by two mutually-exclusive sequence paths chosen based on a Boolean (
true
orfalse
) value. - A common selection is an
if
statement.
Selection is typified by program branches forward in the program sequence, because typically instructions may be skipped depending on the program’s state.
Iteration
- The concept that computers can repeatedly execute instructions based on programmatic criteria (until operations have been applied to every element of a collection or the program reaches a certain state).
- Iteration is one of the structured programming control structures.
- An iteration can be referred to as a loop.
- Common iterations are
for
(count-controlled loop) andwhile
(condition-controlled loop) statements.
Iteration is typified by program branches backward in the program sequence, because typically instructions may be repeated depending on the program’s state.
Function
- The concept that many instructions can be abstracted into a single statement that can be invoked multiple times.
- The flow of control in a computer program is transferred to non-local instructions when a function is invoked (after which the flow of control usually returns to the sequence in the program just after the function was invoked) — as opposed to the flow of control being transferred only to local instructions in sequence, selection, and iteration.
- Mathematical functions are analogs of programming functions.
Variables
- The concept that named locations within a computer can be given values representing the state of a program that can be: remembered from instruction to instruction, be retrieved, and be modified.
- A variable varies, in that its value can change.
- Variables in programming superficially resemble, but may not directly correspond to the concept of variable in mathematics.
Note: in declarative programming programs do not typically have side effects (mutable system state stored in variables). Functional programming, for example, aims to minimize or eliminate side effects. The five programming-language concepts described here are for typical imperative programming languages.
#programming