1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<head>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link href="style.css" rel="stylesheet"/>
<title>BQN: finally, an APL for your flying saucer</title>
</head>
<div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a></div>
<h1 id="bqn-finally-an-apl-for-your-flying-saucer">BQN: finally, an APL for your flying saucer</h1>
<p><em>Try it online below or <a href="https://mlochbaum.github.io/BQN/try.html">here</a>, and see <a href="running.html">running.md</a> for more options.</em></p>
<div class='cont'>
<div class='kb'></div>
<div class='rel'>
<textarea class='code' rows='1' autofocus><⟜'a'⊸/ "Big Questions Notation"</textarea>
<svg class='demo' viewBox='0 -6 4 12'><path d='M1 -6H0L1 0L0 6H1L4 0z'/></svg>
</div>
<pre class='rslt'>"B Q N"</pre>
</div>
<p><strong>BQN</strong> is a new programming language in the APL lineage, which aims to remove inconsistent and burdensome aspects of the APL tradition and put the great ideas on a firmer footing. BQN is aimed at existing and aspiring APL-family programmers, and using it requires a solid understanding of functions and multidimensional arrays. However, because of its focus on providing simple, consistent, and powerful array operations, BQN should also be a good language for learning array programming and building stronger array intuition.</p>
<p>BQN maintains many of the ideas that made APL\360 revolutionary in 1966:</p>
<ul>
<li>Human-friendly <strong>infix notation</strong> with no precedence rules to remember.</li>
<li><strong>Built-in array operations</strong> handle any number of dimensions easily.</li>
<li><strong>Higher-order functions</strong> allow basic functions to be applied in more powerful ways.</li>
</ul>
<p>It incorporates concepts developed over years of APL practice:</p>
<ul>
<li>The <a href="doc/leading.html"><strong>leading axis model</strong></a>, which allows for simpler built-in functions.</li>
<li>Trains and combinators for <strong>tacit programming</strong>.</li>
<li>Lightweight <strong>anonymous functions</strong> (like <a href="https://aplwiki.com/wiki/Dfn">dfns</a>).</li>
</ul>
<p>But BQN is redesigned from the ground up, with brand new ideas to make these paradigms easier to use and less likely to fail.</p>
<ul>
<li>The <strong>based array model</strong> makes non-arrays a fundamental part of the language, and removes the surprise of floating arrays and the hassle of explicit boxes. New <strong>array notation</strong> eliminates the gotchas of <a href="https://aplwiki.com/wiki/Strand_notation">stranding</a>.</li>
<li>A <a href="doc/context.html"><strong>context-free grammar</strong></a> where a value's syntactic role is determined by its spelling makes it easier for machines and humans to understand code.</li>
<li>Oh, and it naturally leads to <a href="doc/functional.html"><strong>first-class functions</strong></a>, a feature often missed in APL.</li>
<li>The <strong>new symbols</strong> for built-in functionality allow the syntactic role of a primitive to be distinguished at a glance, and aim to be more consistent and intuitive.</li>
</ul>
<h2 id="what-kind-of-name-is-bqn">What kind of name is "BQN"?</h2>
<p>It's three letters, that happen to match the capitals in "Big Questions Notation". You can pronounce it "bacon", but are advised to avoid this unless there's puns.</p>
<h2 id="what-does-bqn-look-like">What does BQN look like?</h2>
<p>Rather strange, most likely:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRK2DiiJjijL3ijZ8xMuKGlTIgICMgVGhlIDEydGggRmlib25hY2NpIG51bWJlcg==&run">↗️</a><pre> <span class='Function'>⊑+</span><span class='Modifier'>`</span><span class='Modifier2'>∘</span><span class='Function'>⌽</span><span class='Modifier2'>⍟</span><span class='Number'>12</span><span class='Function'>↕</span><span class='Number'>2</span> <span class='Comment'># The 12th Fibonacci number
</span>144
</pre>
<p>For longer samples, you can <a href="https://github.com/mlochbaum/BQN/blob/master/src/c.bqn">gaze into the abyss</a> that is the self-hosted compiler, or the <a href="https://github.com/mlochbaum/BQN/blob/master/src/r.bqn">shallower but wider abyss</a> of the runtime, or take a look at the friendlier <a href="https://github.com/mlochbaum/BQN/blob/master/md.bqn">markdown processor</a> used to format and highlight documentation files. There are also <a href="https://github.com/mlochbaum/BQN/blob/master/examples/fifty.bqn">some translations</a> from <a href="https://www.jsoftware.com/papers/50/">"A History of APL in 50 Functions"</a> here.</p>
<h2 id="how-do-i-get-started">How do I get started?</h2>
<p>Read the <a href="doc/index.html">documentation</a>!</p>
<p>BQN documentation is currently written primarily for array programmers and is not comprehensive, with aspects of the language that are shared with APL poorly documented. If you're not an array programmer, it would probably be better to start with another language, or wait a few weeks. But if you're a serious language enthusiast, the <a href="spec/index.html">specification</a> is fairly complete and might be enough to fill the gaps in the documentation.</p>
<p>If you're an array programmer, then you're in much better shape. However, you should be aware of two key differences between BQN and existing array languages beyond just the changes of <a href="doc/primitive.html">primitives</a>—if these differences don't seem important to you then you don't understand them! BQN's based array model is different from both a flat array model like J and a nested one like APL2, Dyalog, or GNU APL in that it has true non-array values (plain numbers and characters) that are different from depth-0 scalars. BQN also uses <a href="doc/context.html">syntactic roles</a> rather than dynamic type to determine how values interact, that is, what's an argument or operand and so on. This system, along with lexical closures, means BQN fully supports Lisp-style <a href="doc/functional.html">functional programming</a>.</p>
<script src='bqn.js'></script><script src='repl.js'></script>
|