aboutsummaryrefslogtreecommitdiff
path: root/docs/implementation
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-05-03 15:50:17 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-05-03 15:50:17 -0400
commit6fb49337bbb579c9247cf4788fef1bb56af066aa (patch)
tree2e6aa180964961e79e8b869cc42605ab891cf1ac /docs/implementation
parent3edb22d4a91a4246f9668c2c2fe75ec1b6b37aab (diff)
Clean up description of self-hosted BQN instances
Diffstat (limited to 'docs/implementation')
-rw-r--r--docs/implementation/vm.html3
1 files changed, 2 insertions, 1 deletions
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html
index 57f328e6..5a6e77c4 100644
--- a/docs/implementation/vm.html
+++ b/docs/implementation/vm.html
@@ -5,7 +5,8 @@
</head>
<div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a> / <a href="../index.html">main</a> / <a href="index.html">implementation</a></div>
<h1 id="the-bqn-virtual-machine-and-runtime">The BQN virtual machine and runtime</h1>
-<p>BQN's self-hosted compiler and runtime mean that only a small amount of native code is needed to run BQN on any given platform. For example, the <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../docs/bqn.js">Javascript environment</a> requires about 300 lines of Javascript code even though it compiles BQN bytecode to Javascript, a more complex strategy than interpreting it directly. This makes it fairly easy to port BQN to new platforms, allowing BQN to run &quot;natively&quot; within other programming languages and interact with arrays in those languages.</p>
+<p>BQN's self-hosted compiler and runtime mean that only a small amount of native code is needed to run BQN on any given platform. For example, the <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../docs/bqn.js">Javascript environment</a> requires about 300 lines of Javascript code even though it compiles BQN bytecode to Javascript, a more complex strategy than interpreting it directly. This makes it fairly easy to port BQN to new platforms, allowing BQN to be <a href="../doc/embed.html">embedded</a> within other programming languages and interact with arrays or functions in those languages.</p>
+<p>The way data is represented is part of the VM implementation: it can use native arrays or a custom data structure, depending on what the language supports. An initial implementation will be very slow, but can be improved by replacing functions from the BQN-based runtime with native code. As the VM system can be hard to work with if you're not familiar with it, I advise you to contact me to discuss implementing a VM if you are interested.</p>
<h2 id="bytecode">Bytecode</h2>
<p>The BQN implementation here and dzaima/BQN share a stack-based object code format used to represent compiled code. This format is a list of numbers of unspecified precision (small precision will limit the length of list literals and number of locals per block, blocks, and constants). Previously it was encoded as bytes with the <a href="https://en.wikipedia.org/wiki/LEB128">LEB128</a> format; while it no longer has anything to do with bytes it's called a &quot;bytecode&quot; because this is shorter than &quot;object code&quot;.</p>
<p>The self-hosted compiler uses a simpler, and less capable, format for block and variable data than dzaima/BQN. Only this format is described here; <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../dc.bqn">dc.bqn</a> adapts it to be compatible with dzaima/BQN.</p>