Search code examples
language-agnosticstateimperative-programming

Statements and state


Is there any deeper meaning in the fact that the word "statement" starts with the word "state", or is that just a curious coincidence? Note that english is not my native language, so the answer might be obvious to you, but not me ;)


Solution

  • Etymologically, the answer is yes, as Christopher pointed out.

    However, I would argue that in programming, too, there is a connection. Statements (as opposed to expressions, which are syntactic elements which may be evaluated for their value) are syntactic elements representing imperative commands. (You may hear that in C, many statements (ex. assignment) are also expressions.)

    As such, statements necessarily involve some change in the state of the program (ex x := 5), or the imposition of some control flow (ex GOTO 10). You will note that a purely functional language (say, Haskell), contains no statements, but only expressions.