summaryrefslogtreecommitdiff
path: root/docs/runtime/u3.md
blob: 5f1457f9f957f63ae378b0ac6c1c66bc9469c7e3 (plain)
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
---
description: "Introduction to u3, the Nock runtime system. C library for making and storing nouns. Solid-state interpreter."
layout:
  title:
    visible: true
  description:
    visible: false
  tableOfContents:
    visible: true
  outline:
    visible: true
  pagination:
    visible: true
---

# U3

The Urbit interpreter is built on a Nock runtime system written in C, `u3`.  This section is a relatively complete description.

You should keep reading if (a) you're planning to work on the Urbit interpreter; (b) you're a language implementation geek; or (c) you don't really understand anything until you've seen the actual structs.

## u3: Noun processing in C {#u3-noun-processing-in-c}

`u3` is the C library that makes Urbit work.  If it wasn't called `u3`, it might be called `libnoun` - it's a library for making and storing nouns.

What's a noun?  A noun is either a cell or an atom.  A cell is an ordered pair of any two nouns.  An atom is an unsigned integer of any size.

To the C programmer, this is not a terribly complicated data structure, so why do you need a library for it?

One: nouns have a well-defined computation kernel, Nock, whose spec fits on a page and gzips to 340 bytes.  But the only arithmetic operation in Nock is increment.  So it's nontrivial to compute both efficiently and correctly.

Two: `u3` is designed to be a "solid-state interpreter," ie, a single-level store which is transparently snapshotted.  This implies a specialized memory-management model, etc, etc.

(Does `u3` depend on the higher levels of Urbit, Arvo and Hoon? Yes and no.  `u3` expects you to load something shaped like an Arvo kernel, and use it as an event-processing function.  But you don't need to use this feature if you don't want, and your kernel doesn't have to be Arvo proper - just Arvo-compatible.  Think of `u3` as the BIOS and Arvo as the boot kernel.  And there are no dependencies at all between Hoon the language and `u3`.)