3223 Programming Languages and Translations

Functional Programming With Clojure

Functional Programming Principles

Basic form of decomposition is the function

Basic mechanism of composition is function call

Goal of func. prog. is to compose programs from software procedures that act like mathematical functions

  • takes arguments
  • returns a value

All useful programs have side effects

BUT function programming encourages writing side-effect free functions.

Easier to understand programs that avoid side effects.

Functional programming in OO Language

  • method receives all of the information it needs through arguments
  • method produces its only results by returning a value
  • (side effects should be avoided whenever possible)
  • in OO languages we can mimic some aspects of functional programming by avoiding mutation
  • functional languages make this more natural