2.4 Important Basic Concepts for Hoon: Atoms, Auras, Cells, Nouns, Lists, Runes

We’ve covered a lot of the basics. You understand how to get your ship up and running, and how to boot a fake ship so that you can do some coding on it without endangering your regular Urbit identity. We’ve talked about Hoon’s naivety in broad terms, created and committed a simple generator and made our way around the dojo. We’ve spoken about atoms (natural numbers that everything boils down to) and auras in general terms and now it’s time to dig into the core building blocks of the hoon language.

One of the most interesting and controversial things about Urbit is the very significant amount of terms and in many cases new concepts that are specific to Urbit. Whether these novel terms are part of an honest commitment to the vast thought-exercise of creating a computing system from scratch, or whether they represent a commitment to call things by new names because they do not perfectly match to similar items in the world of computer science and therefore should not share the same label, the terms are an important part of Urbit which can be disorienting at first.

After a few words about Nock, we will do a quick review & brief expansion upon Atoms & Auras which we covered above. We will then describe Nouns, Cells, Lists and Runes. Once all of that is complete then..then! it will finally be time to get into the first basic lesson and march forward into learning the Hoon language.

2.4 Nock

Nock is the base “language” upon which Hoon is built. The word language is in quotes because though Nock is indeed a computing language, it is very simple, and might be better described as a short list of logic rules. It is famously short; short enough that the entire language specification fits on one side of a T-shirt.

Nock “thinks” in regular whole numbers: zero, plus integers. They are called “unsigned integers” and it’s easiest to think of them as positive whole numbers. In the world of Urbit, these whole numbers are called Atoms (remember this definition of Atom – you will use this term over and over again forever in Hoon), and they, plus the rules of logic that Nock describes, make all computation possible within your Urbit. The Hoon language compiler converts all of your code to these whole numbers in a particular structure that Nock requires.

For the most part, we will not go into the logic rules of Nock here. Some would say that eventually to truly understand Hoon you will need to dive into Nock and understand it, but that would be best relegated to the “maybe someday” category for the beginning coder. For now, know that there are rules, atoms and structure within which the atoms reside, that make up all of Nock. We will dig into the “structure” side of things shortly when we talk about cells.

Having said that, we know that there people who are adventurous, curious or perhaps purists who want to learn Nock before learning Hoon.  This is entirely do-able and ~timluc-miptev has created a very approachable Nock learning lesson set which can be found here: https://blog.timlucmiptev.space/

Back in the world of Hoon, we revisit now the fact that atoms can be represented as a variety of things, and that we use Auras (briefly covered above) to represent – or “cast” – an atom as one thing or another.

Each time you do this you will then see a list of the new or changed files that have been ported into your urbit ship with this command. So, even though it seems like a lot of work, every single time you make a change to a program and want to test it, you need to |commit %home before you do so. Fortunately in the dojo, if you hit the up arrow it will recall your prior commands in sequence, so if you enter |commit %home once then you can easily find it with the up arrow thereafter.

2.5 What are: Atoms, Auras, Cells and Nouns?

We are going to expound greatly on these basic principles from the official Urbit documentation, but these concise descriptions are true, excellent, and a great starting point:

A noun is an atom or a cell. An atom is any natural number.
A cell is any ordered pair of nouns.

We’ll briefly introduce these concepts and then refer you (along with some learning goals) to the urbit docs to complete the package.

2.5.1 Why do we need cells?

It’s important to learn a bit about reason for a cell’s existence as a means of organizing information written linearly into a format that is both addressable linearly (i.e. you can easily pluck out a given value in order) and hierarchically (you can easily tell what is contained within what when there are multiple levels of nesting (cells/containers within one another).

You will soon learn that cells are a cool way of writing something in one line, and with the data having a predictable nested structure that makes any item within the cell addressable. You will learn to call this structure a “binary tree” and it can be a very big and complex binary tree if the cell structure is big and complex.

Let’s take a step back and look at another system for organizing numbers in a computational format: Microsoft Excel. You already know that Excel takes numbers, has structure and uses this structure to make calculations. Hopefully the basic rules of this are second nature for you. In Excel, it’s super easy to call attention to a piece of data

In A1 you can see the number 432, in cell A2 it’s 900 and so on. Formulas in excel refer to these locations in order to compute. In Hoon, theoretically all data can be expressed as one very long cell with many, many subsections (a binary tree).e. The cell addressing syntax provides a structure for referencing data within this gigantic binary tree.

Cells are important in Hoon because of the unique “binary tree” addressing system they provide us, and because all data in Hoon that is not a single value (atom) is stored as a cell – we will therefore need to become extremely comfortable with them. And you might pass through a bit of a sea of confusion before arriving at the glorious island of understanding. Hang in there as you go through Urbit tutorials section 1.2 where indicated, a bit further down.

2.6 So then what are Nouns?

Nouns are a category of item that includes both cells and atoms. And since everything in Hoon is either a cell (or a complex cell of cells) or an atom, then everything in hoon is a noun.

But much of the time you don’t need nested data in a complex structure. You just need a series of things in a particular linear order and it doesn’t need to be much more complex than that. Enter lists. Lists are a type of cell and therefore also a type of noun. And even though as cells they theoretically subscribe to those rules of complex structure, they are most easily thought of as just a collection of things in order. And there are lots of circumstances in computation when you need to have a group of things in order, or manipulate the order of a group of things.

Let’s get into the urbit tutorials a bit and learn about auras, cells and the beginning of nouns. And then we will go into a special type of noun (the list) further. Section 1.2 (Nouns) is a great overview of these first themes. We highly recommend reading that section and making sure you come away with these learnings or skills:

  • Define an atom
  • Define a cell in basic terms
  • Be able to convert any cell to a visual drawn-out binary tree
  • Define an aura
  • Using the dojo, cast any aura back to its base atom (number)
  • Using the dojo, cast any atom to an aura and try a few
  • Define a cord and its close cousin the term, and state the proper format for each appearing in code
  • Be able to convert a full cell format with all brackets to a “pretty printed” format with nonessential brackets removed (as the dojo automatically does) and back again.
  • Understand “noun addresses” or individual addresses within the binary trees and how to arrive at them
  • Do all of the exercises and either understand them or reach out to us in our group chat room for help

Now, with regards to lists, that resides in section 1.5 of the urbit docs. We should point out here that the nitty gritty of addressing data within lists is not something you will do much in the initial lessons of this beginner course. So if you are going for brain and time efficiency, you can skim section 1.5 and come back to it later as part of going through the lessons when we dig into lists further. These sections assume that you understand cells and binary trees, quite well, as well as the basic system of addressing the items within the binary tree of a cell, so make sure you have a good grasp on that before proceeding.

If you go through section 1.5 to better understand how to address data elements within lists and how to work with lists, the items below should be the areas of understanding that you take away from that section:

  • Definition of a list, what null-termination means and the different ways that null-termination can look
  • Definition of lest
  • Appearance of a simple list (for example, containing 1 2 3 4 5 ~) as pretty-printed by the dojo, and the same list with all cell-delineating brackets in place
  • Using types and casting to tell Hoon what type of data a list will contain
  • Finding & defining the head (also called i) and the tail (also called t) of any list
  • Tapes as a special type of list, which look like cords but are definitely not atoms, they are lists
  • Exposure to, but not memorization of any of the standard functions here. The takeaway at this stage is “there are a lot of things you can do with lists!” – pluck out specific values, insert values, reverse the order, and so on..

2.7 Hoon Syntax: Commands, Runes, Tall and Flat Forms

Hoon syntax can be mighty disorienting at first. Part of the reason is that many of the commands occur as simple two character symbols, called runes, which look like |- or =+. Runes are the basic building blocks of Hoon, and there are a few high level concepts to know that will help orient you to what runes are all about: 1) There is a way to phonetically pronounce each rune so that you can easily speak Hoon code if you like, 2) the runes for the most part have families (the first rune) 3) individual two-symbol runes within each family that do different things. Each two-character (sometimes referred to as diglyph) rune has a specific operation it performs and a syntax for building a proper statement with it.  4) Each rune has a specific number of “children” or something of a follow-on element or code expression that supports the rune. Rather than get into children here, we are going to include them as a core concept in the first lesson.

As you get into learning runes, here are some Anki flashcard decks that can help you get through this material and get it into your brain:

Anki Flash Card Deck: Hoon Rune Phonetics

In the Urbit documents, learning the phonetic pronunciations of the Hoon runes are called optional, but know that in conversation about Hoon and runes, these ways of speaking Hoon are widely used. We will use them frequently and ultimately you should learn them. Also, it’s just a bit of repetition learning and will serve you for a great while thereafter.

https://ankiweb.net/shared/info/2004875530

2.8 Anki Flash Card Deck: Hoon Rune Families

Learning the 12 rune families (the first symbol of the two-symbol rune tells you the family) will help you make sense of and remember the individual runes as you learn them later. This learning is very highly recommended.

https://ankiweb.net/shared/info/227862017

2.8.2 Anki Flash Card Deck: Hoon runes in plain English

It might be a bit early to learn these basic runes with zero context, but once you get a touch of enthusiasm about learning hoon then you should spend some of that energy on this deck. At first this might be rote memorization, but these are very important building blocks that will help you dispel many of the learning challenges to come.

https://ankiweb.net/shared/info/2122965757

2.8.3 Anki Flash Card Deck: Hoon runes in plain English

It might be a bit early to learn these basic runes with zero context, but once you get a touch of enthusiasm about learning hoon then you should spend some of that energy on this deck. At first this might be rote memorization, but these are very important building blocks that will help you dispel many of the learning challenges to come.

https://ankiweb.net/shared/info/2122965757