Side effect (computer science)
A part of a program with a side effect performs a noticeable action other than giving back a value. 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.
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. In Haskell, actions with side effects must be stated explicitly—this makes it easier to tell what code does or does not have them.
References[change | change source]
- "programming languages - What is a "side effect?"". Software Engineering Stack Exchange. Retrieved 2019-05-22.
- 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. http://dx.doi.org/10.1093/comjnl/32.2.98.
- Felleisen, Matthias VerfasserIn. How to design programs an introduction to programming and computing. ISBN 9780262534802. OCLC 989974617.
- Jones, Isaac (2006). "Haskell' status report". Proceedings of the 2006 ACM SIGPLAN workshop on Haskell - Haskell '06 (New York, New York, USA: ACM Press). doi:10.1145/1159842.1159860. ISBN 1595934898. http://dx.doi.org/10.1145/1159842.1159860.