aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/doc/index.html1
-rw-r--r--docs/doc/paradigms.html24
2 files changed, 25 insertions, 0 deletions
diff --git a/docs/doc/index.html b/docs/doc/index.html
index 351f6f9e..04630845 100644
--- a/docs/doc/index.html
+++ b/docs/doc/index.html
@@ -11,6 +11,7 @@
<li><a href="syntax.html">Syntax</a></li>
<li><a href="types.html">Types</a></li>
<li><a href="primitive.html">Primitives</a></li>
+<li><a href="paradigms.html">Paradigms</a></li>
</ul>
<p>Concepts:</p>
<ul>
diff --git a/docs/doc/paradigms.html b/docs/doc/paradigms.html
new file mode 100644
index 00000000..27df4657
--- /dev/null
+++ b/docs/doc/paradigms.html
@@ -0,0 +1,24 @@
+<head>
+ <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
+ <link href="../style.css" rel="stylesheet"/>
+ <title>BQN in programming paradigms</title>
+</head>
+<div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a> / <a href="../index.html">main</a> / <a href="index.html">doc</a></div>
+<h1 id="bqn-in-programming-paradigms">BQN in programming paradigms</h1>
+<p>It hangs onto weakly positive connotations somehow, but the term &quot;multi-paradigm&quot; should not really impress you. Let's dig into exactly which paradigms BQN supports and how.</p>
+<p>This information won't really tell you what tasks BQN is good for: after all, it turns out you can write an efficient compiler entirely using array programming, something many people assumed was impossible. Instead, it tells you what approaches you can take to writing programs, and how comfortable you'll find it to work with BQN—or how much you can use it to stretch your brain in new directions.</p>
+<p>When programming in BQN, I almost always use array, tacit, and (slightly impure) functional styles, and encapsulate code in medium or large projects using namespaces. I sometimes use object-oriented or imperative programming in addition to these.</p>
+<h2 id="typing">Typing</h2>
+<p>BQN is a <strong>dynamically typed</strong> language with a coarse <a href="types.html">type system</a> that only distinguishes types when the difference is blindingly obvious. There is a single numeric type and a single unicode character type. A fast implementation such as dzaima/BQN will check to see when it can represent the data with a smaller type than the one offered by the language. BQN usually avoids implicit type conversion, with the exception that many primitives automatically convert atoms to unit arrays. The fact that a data value can be applied as a function to return itself could also be considered an implicit conversion.</p>
+<p>BQN has no &quot;pointer&quot; or &quot;reference&quot; type, and uses <strong>automatic memory management</strong>. Its data types are <strong>immutable</strong> while operations and namespaces are mutable; mutable data can create reference loops, which the implementation must account for in garbage collection but the programmer doesn't have to worry about.</p>
+<p>Dynamic types and garbage collection introduce overhead relative to a statically-typed or manually managed language. The impact of this overhead can be greatly reduced with array programming, because an array of numbers or characters can be stored as a single unit of memory and processed with functions specialized to its element type.</p>
+<h2 id="styles">Styles</h2>
+<p>BQN is designed for <strong>array</strong> programming. The array is its only built-in collection type and is has many primitives designed to work with arrays.</p>
+<p>BQN is okay for <strong>imperative</strong> programming. Blocks are lists of statements. Variables can be modified with <code><span class='Gets'>↩</span></code>, and while there are no truly global variables, lexical scoping allows variables at the top level of a file, which are similar (<code><span class='Function'>•Import</span></code> with no left argument saves and reuses results, so that data can be shared between files by loading the same namespace-defining file in each). BQN doesn't directly support <strong>structured</strong> programming (which refers to a particular way to structure programs; it also doesn't have a Goto statement, the &quot;unstructured&quot; alternative when the term was coined). However, its first-class functions allow a reasonably similar <a href="control.html">imitation</a> of control structures.</p>
+<p><strong>Functional</strong> programming is a term with many meanings. Using the terms defined in the <a href="functional.html">functional programming document</a>, BQN supports first-class functions and function-level programming, allows but doesn't encourage pure functional programming, and does not support typed functional programming. BQN uses <strong>lexical scope</strong> and has full support for <strong>closures</strong>. In this way BQN is very similar to Lisp, although it lacks Lisp's macro system.</p>
+<p>BQN has excellent <a href="tacit.html">support</a> for <strong>tacit</strong> or <strong>point-free</strong> programming, with <a href="train.html">trains</a> and intuitive symbols for combinators making it much easier to work with (in my opinion) than other languages that support this style. It's near-universally considered a poor choice to implement entire programs in a tacit style, so this paradigm is best used as a small-scale tool within a style like functional or object-oriented programming.</p>
+<p>BQN uses <a href="namespace.html">namespaces</a> as <strong>modules</strong> to organize code; the only possible interaction with a module is by its exported variables. There doesn't seem to be a name for this paradigm, but there should be.</p>
+<p>BQN supports <strong>object-oriented</strong> programming <a href="oop.html">only incidentally</a>. This is not as bad as it sounds, and programming with objects in BQN can often feel pretty similar to other object-based languages. The main differences are that objects don't have a <code><span class='Value'>this</span></code> property to pass themselves into functions, and there's no built-in way to find the class of an object. There is also no support for inheritance, which is not unheard of in the object-oriented world.</p>
+<p>BQN does not support <strong>metaprogramming</strong> such as macros or reflection, except with very crude techniques like <code><span class='Function'>•Eval</span></code>. Functions describe computations and can easily be written, passed around, and applied: they can fill in for any use of macros or generics in a C-like language. If desired, it's easy to use lists as S-expressions to form structures that can be easily manipulated and also evaluated—roughly, embedding Lisp in BQN.</p>
+<p>BQN does not yet have support for <strong>concurrent</strong> programming. It's likely that its strict approach to lexical scoping and encapsulation make it a good fit for concurrent execution, but designing such a system is not a priority. In contrast, array operations are ideal for <strong>parallel</strong> computing, including SIMD or GPU computation. To enable highly-parallel algorithms, the implementation must evaluate primitives (or combinations) using these algorithms, and the programmer must use primitives that have been implemented in this way. It would be possible to define a subset of BQN that restricts the programmer to code with an efficient parallel implementation, but BQN itself does not have any such restrictions.</p>
+<p>BQN doesn't support <strong>logic</strong> programming or <strong>computer algebra</strong>, although its <a href="../spec/inferred.html">inferred properties</a> might be considered a very rudimentary form of either of these. It doesn't support <strong>dataflow</strong> programming.</p>