wiki:FirstPrinciples/Functions

Functions

Functions are "mappings" (in mathematical sense - x -> 2x + b) or transformations (transitions from one state to another) in real (biological) world. Enzymes could be viewed as machines, which has parts that could be viewed as functions (ok, procedures!) made out of matter. This is clumsy but still better than highly abstract bullshit of category theorists.

What is more important - the Mother Nature (at least at the molecular level) is stateless and pure-functional, in a sense that each enzyme, or rather any part of an it, is a pure-function so to speak.

If we realize this, we immediately understand, that, lets say Microservices shall be done in a pure-functional paradigm (share-nothing, pure message-passing) only, and trying otherwise will inevitably result in a messy failure. The Mother Nature tried it and rejected as unreliable.

Same input -> same output. Always.

The main principle which defines (distinguish) a function is that it is, so to speak, "pure" (an abstract notion of bad philosophers), which means it is completely isolated and self-contained - not affected by anything outside of it, which, in turn, implies that it produces the same value for the same input. Always.

A function is an abstract notion of concrete implications of the laws of physics. Fundamental chemical reactions at molecular level are functions - they produce the same output in the same initial conditions. Always. Life itself is possible only because this is so.

Functional programming as a discipline should (in my opinion) learn more from biology and less from highly abstract, sectarian branches of mathematics. (Good math is the science of patterns, of what is, not of what possible). MIT of old times tried exactly that - to augment the notions of programming by notions from molecular biology. Very bright guys, like young Alan Kay (who got a degree in molecular biology) did it too.

Last modified 5 months ago Last modified on Sep 23, 2019, 2:23:04 AM
Note: See TracWiki for help on using the wiki.