When I was reviewing a book, I saw that there's a sentence claiming "side effect is a term coming from the domain of functional programming". I would think that the concept existed before the invention of the functional programming paradigm, but the author is asking for a citation that I was not able to find. Does the concept of "side-effect" actually predate functional programming, or is the author right?
2 Answers
The earliest usages of the term that I'm aware of are in regard to Algol 60, one of the first languages to be (or attempted to be) defined by a specification. When people started implementing it, they found that desirable optimizations (such as reordering expressions) could not be performed if the order of evaluation matters, which is possible only if side-effects are permitted. Also, side-effects may be considered mathematically inelegant, and one goal of the Algol effort was to produce a formal notation for algorithms.
Now, for some actual citations:
- In “ALGOL 60 maintenance” (ALGOL bulletin 10, 1960), M. Woodger comments on the current draft of the specification, stating “It is quite unreasonable to allow the evaluation of expressions to induce side-effects”.
- Samelson and Bauer (ALGOL bulletin 12, 1961) concur strongly, calling side-effects “preposterous”.
- Dijkstra, on the other hand, in a letter to the editor, asserts that side-effects can be useful, e.g., in writing a random number generator.
- Knuth, in “ALGOL 60 confidential” [Communications of the ACM 4(6), 1961], discusses the problem of side effects being poorly defined by the specification (it was unclear whether they were allowed or forbidden, and whether the order of evaluation was prescribed at all), although he does not use the term “side-effect”.
- Knuth again, in “The remaining trouble spots in ALGOL 60” [Communications of the ACM 10(10), 1967] contains extensive commentary on side-effects and how they affect Algol 60 programmers and implementors.
Unrelated to Algol:
- Leavenworth's “FORTRAN IV as a syntax language” [Communications of the ACM 7(2), 1964] considers how side-effects may be convenient alongside short-circuiting boolean expressions.
- Abrahams et al., in “The LISP 2 programming language” [Proceedings of AFIPS '66], use the term in noting that their compiler always treats the order of evaluation as undefined, unless the code uses a special operator
ORDER
to force left-to-right.
The term and intuitive notion of a side effect of course predates functional programming. So your question is really, does the meaning of side effect in programming languages (i.e., a function which has effects beyond its input-output behavior) date back to functional programming? To this I think the answer is yes for trivial reasons, if "functional programming" is interpreted broadly: the definition of a side effect is in terms of a function's input-output behavior, which is exactly the meaning of a functional program. So as long as people were studying side effects, they were doing so in contrast to pure functional programs.
It is also not easy to put a start date on the study of functional programming, which is why I adopt this broad view. Functional programming traces its roots back to Alonzo Church and the lambda calculus. At that time, people were already aware of the meaning of programs and the equivalence between different models of computation. The usage of the term side effect for programs entails an understanding of program input-output behavior which implies an understanding of what a purely functional program is.
For what it's worth, the earliest instance of "side effect" I could find in this usage, in papers indexed by Google Scholar, was in the study of LISP in the 1970s. Though I would not be surprised if there are earlier instances.
- Output driven interpretation of recursive programs, or writing creates and destroys data structures, Friedman, Daniel P., and David S. Wise. Information Processing Letters, 1976. Paywalled link.
Does the concept of "side-effect" predate functional programming?
- final question:is the author right?
:) If you really want just an answer to a simple question then just ask the simple question without side effects. Pun intended. $\endgroup$