Jump to content

User:WillWare/Functional programming

From Wikipedia, the free encyclopedia

I've spent most of my career doing what everybody else has been doing, using first Java and later Python for "web development" or whatever my employer called for. But lately I've become aware of a debate within the software engineering profession favoring "functional programming" over "object oriented programming". So let's look and see what's involved, and whether I should do anything different.

Several languages favor a functional approach: StandardML/OCaml, Haskell, F#, and to a lesser extent Rust and Lisp/Scheme. Haskell is probably the clearest exemplar of the whole thing.

The general principles involved appear to be:

  • Functions should do everything possible to avoid side effects (going in or going out).
  • Immutable data values are a very big deal.
  • Static typing is a big deal.
  • Prefer functions over classes and methods.
  • Prefer operators like map and filter over for-loops.
  • Tail recursion can be a good thing.

Among fans of FP ... more of this later, I'm stuck in a meeting for now.