Programming Language and Effects

Topics: Programming language, Functional programming, Imperative programming Pages: 1 (351 words) Published: February 20, 2013
In computer science , a function or expression is said to have a side effect if, in addition to returning a value, it also modifies some state or has an observable interaction withcalling functions or the outside world. For example, a function might modify a global or static variable , modify one of its arguments, raise an exception, write data to a display or file, read data, orcall other side-effecting functions. In the presence of side effects, a program's behavior depends on history; that is, the order ofevaluation matters. Understanding and debugging a function with side effects requires knowledge about the context and its possible histories. [1] [2] Side effects are the most common way that a program interacts with the outside world (people, filesystems, other computers on networks). But the degree to which side effects are used depends on the programming paradigm. Imperative programming isknown for its frequent utilization of side effects. In functional programming , side effects are rarely used. Functional languages such as Standard ML , Scheme and Scala do not restrict side effects, but it is customary for programmers to avoid them. [3] The functional language Haskell restricts side effects with a static type system ; it uses the concept of monads to do stateful and IO computations. [4] [5] Assembly language programmers must be aware of hidden side effects — instructions that modify parts of the processor state which are not mentioned in the instruction's mnemonic. A classic example of a hiddenside effect is an arithmetic instruction which explicitly modifies a register (an overt effect) and implicitly modifies condition codes (ahidden side effect). One defect of an instruction set with many hidden side effects is that, if many instructions have side effects on a single piece of state, like condition codes, then the logic required to update that state sequentially may become aperformance bottleneck. The problem is particularly acute on processors...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Programming Language Essay
  • Programming Languages Essay
  • Programming Language Essay
  • Programming Languages Essay
  • Essay about Programming Language
  • Evolution of Programming Languages Essay
  • Programming Language (Pl1) Essay
  • It Programming Essay

Become a StudyMode Member

Sign Up - It's Free