
This style is more directly usable on multicore architectures (again, no shared state).A lot of Big Data processing is based on the MapReduce paradigm which is straight out of functional programming theory.Functions as values give programmers more opportunities for reuse.
Easier to prove correct, because the result of calling a specific function with a specific argument is always the same no matter how many times you make that call.Amenable to more compiler optimizations, especially in regard to core and thread allocation, and caching of previous results.
Functional programming languages code#
When you truly have no side effects, your code is automatically:
Information hiding is handled through lexical closures (because there are no shared stateful objects). Recursion, folding, and powerful collection operators are used in place of loops. Ubiquitous use of higher-order functions: functions that can (1) take functions as arguments and (2) return functions. Functions do not have side-effects (e.g., no mutable variables, no I/O, no databases). Functions are first-class values: they can be assigned to variables and used pretty much as freely as numbers, booleans, and strings. There are many other paradigms as well, but those are the main ones. Functional programming: programming by composing side-effect-free functions. Logic programming: given a collection of facts and inference rules, an engine answers your questions. Object oriented programming: programming around a society of objects, each with their own behaviors. Structured programming: programming with nicely nested, crisp, control structures (no "gotos"). Declarative programming: programming by saying what you want, not how it should be computed. Imperative programming: programming with commands (Do this, then do that, etc.). Roughly, the most common paradigms include: The Basics What is it?įunctional programming is one of many recognized ways of programming, called paradigms. This thing called “functional programming” is kind of all the rage these days, after being introduced over a half century ago.