This commit is contained in:
Miloslav Ciz 2025-03-17 16:42:36 +01:00
parent 6f0a813940
commit f69e3a3e4b
16 changed files with 2006 additions and 1999 deletions

View file

@ -1,10 +1,10 @@
# Paradigm
By [programming language](programming_language.md)'s paradigm (from Greek *paradeigma*, "pattern", "example") we mean the very basic concepts used as a basis for performing computation in that language. Among the most popular paradigms we'll find for example the [imperative](imperative.md), [object oriented](oop.md) and [functional](functional.md), but there exist many others; we may view every paradigm as a set of basic ideas, principles and [mathematical](math.md) models (e.g. [models of computation](model_of_computation.md), [data types](data_type.md), forms of [expressions](expression.md) etc.) that form the foundation of how the whole language works; these foundations are subsequently also accompanied by a kind of "programming philosophy" (we'll oftentimes hear sentences such as "[everything is](everything_is.md) X" where *X* may be *number*, *object*, *array*, *list* etc.), a naturally emerging "mindset", a set of recommendations the programmer should follow when using the language. But let it be set straight that paradigm will NOT include other than purely technical, engineering aspects of computation, i.e. artistic or political ideas (such as "eco-friendlieness", "anti-fascism", ...) are indeed not part of programming paradigm. Nevertheless, although of technical nature, aspects of paradigms are subjective, for example the question of drawing borders between them -- just like [music](music.md) genres or human [races](race.md), paradigms are [fuzzy](fuzzy.md) concepts, they have different definitions in different books, come in different flavors and are often combined; sometimes it's unclear how to classify paradigms (if one strictly falls under another etc.) or even if something is or isn't a paradigm at all. In a wider sense the term *paradigm* may also be used outside of programming languages, for example a paradigm of a [physics engine](physics_engine.md) might be "everything's a sphere" etc.
By [programming language](programming_language.md)'s paradigm (from Greek *paradeigma*, "pattern", "example") we mean the very essential concepts used as a basis for performing computation in that language. Among the most popular ones we'll find for example the [imperative](imperative.md), [object oriented](oop.md) and [functional](functional.md), but there's a sizable set of other paradigms in the world; a paradigm can be understood as a set of fundamental ideas, principles and [mathematical](math.md) models (e.g. [models of computation](model_of_computation.md), [data types](data_type.md), forms of [expressions](expression.md) etc.) upon which are built more complex constructs of the language -- paradigm forms foundations which are subsequently accompanied by a kind of "programming philosophy" (expressed for examples as "[everything is](everything_is.md) X" where *X* may be *[number](number.md)*, *[object](oop.md)*, *[array](array.md)*, *[list](list.md)* etc.), a naturally emerging "mindset", a set of recommendations the programmer should follow when using the language. But let it be set straight that paradigm will NOT include other than purely technical, engineering aspects of computation, i.e. artistic or political ideas (such as "eco-friendlieness", "anti-fascism", ...) are indeed not part of programming paradigm. Nevertheless, although of technical nature, aspects of paradigms are subjective, for example the question of drawing borders between them -- just like [music](music.md) genres or human [races](race.md), paradigms are [fuzzy](fuzzy.md) concepts, they have different definitions in different books, come in different flavors and are often combined; sometimes it's unclear how to classify paradigms (if one strictly falls under another etc.) or even if something is or isn't a paradigm at all. In a wider sense the term *paradigm* may also be used outside of programming languages, for example a paradigm of a [physics engine](physics_engine.md) might be "everything's a sphere" etc.
For example the [functional](functional.md) paradigm is built on top of [lambda calculus](lambda_calculus.md) (one of many possible mathematical systems that can be used to perform general calculations) which performs calculations by combining pure mathematical [functions](function.md) -- this then shapes the language so that a programmer will mostly be writing mathematical functions in it, AND this also usually comes with the natural "philosophy" of subsequently viewing everything as a function, even such things as loops or [numbers](number.md) themselves. In contrast [object oriented](oop.md) (OOP) paradigm tries to solve problems by constructing a network of intercommunicating "objects" and so in OOP we tend to see most things as objects.
For example the [functional](functional.md) paradigm is built on top of [lambda calculus](lambda_calculus.md) (one of many possible mathematical systems that can be used to perform general calculations) which performs calculations by combining pure mathematical [functions](function.md) -- this then shapes the language so that a programmer will mostly be writing mathematical functions in it, AND this also usually comes with the natural "philosophy" of consequently viewing everything as a function, even such things as loops or [numbers](number.md) themselves. In contrast [object oriented](oop.md) (OOP) paradigm aims to solve problems by constructing a network of intercommunicating "objects" and so in OOP we tend to perceive everything as objects.
**Most common** practically used paradigm is the **[imperative](imperative.md)**, one based on the plain and simple concept of issuing "commands" to the [computer](computer.md) -- even though nowadays it almost always gets combined with some other [bullshit](bullshit.md) paradigm, most infamously [object orientation](oop.md). Prevalence of imperative paradigm is probably due to more than one factor, most important of which is most likely its simplicity (it's possibly the closest to human thinking, easiest to learn, predict etc.), efficiency thanks to being closest to how computers actually work (compilers have very small overhead in translation, they perform less "[magic](magic.md)"), [historically](history.md) established status (which is related to simplicity; imperative was the first natural approach to programming) etc. Even more abstract paradigms are ultimately built on top of imperative system, so imperative is just present everywhere.
**Most common** practically used paradigm is the **[imperative](imperative.md)**, one based on the plain and simple concept of issuing "commands" to the [computer](computer.md) -- even though nowadays it almost always gets combined with some other [bullshit](bullshit.md) paradigm, most infamously [object orientation](oop.md). Prevalence of imperative paradigm is probably due to more than one factor, most important of which is most likely its [simplicity](kiss.md) (it's possibly the closest to human thinking, easiest to learn, predict etc.), efficiency thanks to being closest to how computers actually work (compilers have very small [overhead](overhead.md) in translation, less "[magic](magic.md)" is required), [historically](history.md) established status (which is related to simplicity; imperative was the first natural approach to programming), compatibility with [minimalism](minimalism.md) (AKA good design) etc. Even the more abstract paradigms are ultimately erected on top of an imperative system, so imperative computation is present in one way or another.
**List of notable paradigms** follows (keep in mind the subjectivity and fuzziness that affect classification):