Side effect (computer science)

A part of a program with a side effect performs a noticeable action other than giving back a value.[1] Examples include showing a picture on a computer screen, or checking what year it is. Code with side effects can be harder to understand without any context, and the order of instructions more important for code with side effects.[2]

In functional programming, programmers try to avoid side effects when they can, so it is easier to prove that a program will always do what it is supposed to. In some functional languages, like Standard ML, Scheme, or Scala, side effects are not restricted, but programmers still try to use them less.[3] In Haskell, actions with side effects must be stated explicitly—this makes it easier to tell what code does or does not have them.[4]

  1. "programming languages - What is a "side effect?"". Software Engineering Stack Exchange. Retrieved 2019-05-22.
  2. Hughes, J. (1989-02-01). "Why Functional Programming Matters". The Computer Journal. 32 (2): 98–107. doi:10.1093/comjnl/32.2.98. ISSN 0010-4620.
  3. Felleisen, Matthias (2018). How to design programs : an introduction to programming and computing (Second ed.). Cambridge, Massachusetts. ISBN 978-0-262-53480-2. OCLC 1033570710.{{cite book}}: CS1 maint: location missing publisher (link)
  4. Jones, Isaac (2006). "Haskell' status report". Proceedings of the 2006 ACM SIGPLAN Workshop on Haskell - Haskell '06. New York, New York, USA: ACM Press: 122. doi:10.1145/1159842.1159860. ISBN 1595934898. S2CID 30893956.

From Wikipedia, the free encyclopedia · View on Wikipedia

Developed by razib.in