Referential Transparency and State

A pair of terms characterizing two useful ways of looking at a computing system:

Referential Transparency
The view that all elements of a program are describable at some level of timelessness, or without reference to implicit context. Even more importantly, that the elements of a program can be exchanged and substituted reliably like terms in a set of mathematically-consistent equations. Such is the impetus behind functional programming: lazy evaluation and concurrency are possible because of referentially-transparent semantics offered. Without time-invariant substitutability, evaluation order cannot be freely adjusted separately from the programmer's specification.
State
The view that all programs move through time, and have meaning (as information content) that depends on actions which occur, altering the set of meaningful relationships between objects within some outer domain of all possible values.

There are many ways in which the adherents of each camp attempt to embrace the other: within functional programming, there are monads used and linear types. Stateful languages, while mostly categorized as imperative, can also be logical or equational in nature, where state is equivalent to the idea of reduction or evaluation. There is also the use of single static assignment forms of imperative languages, used in Sisal and many intermediate languages of compilers for the purpose of providing a portable yet provable encoding of programs.

This dichotomy of viewpoints is also expressed in the distinction between pure and impure, or side effecting, objects. In a properly unified system, the distinction is purely a matter of linguistic perspective: determining what effects an object has vs. what side-effects it has depends on the notion of context in general. Most languages avoid this issue by not providing rich-enough contexts or ways to modify them.


This page is linked from: Duality   Linear Logic Comments