on master help sign in
Merge pull request #1223 from tinnus-napbus/environment-setup

change hoon school setup to introduction

commit80bd5623f31ba41861bf951841e42bd39c9d02fe authortinnus-napbus <77721746+tinnus-napbus@users.noreply.github.com> dateFri 22 Oct 2021, 12:54 (5 years ago) parent0b895979ce96e3
5 files changed+152−145
content/docs/development/environment.md+1−1 content/docs/glossary/dojo.md+2−1 content/docs/hoon/hoon-school/_index.md+28−33 content/docs/hoon/hoon-school/intro.md+121 content/docs/hoon/hoon-school/setup.md−110
content/docs/development/environment.md+1−1
@@ -10,7 +10,7 @@ within the Urbit ecosystem.
1010
1111## Creating a development ship
1212
13−To do work with Hoon, we recommended using a "fake" ship -- one that's not
13+To do work with Hoon, we recommended using a "fake" ship — one that's not
1414connected to the network.
1515
1616Because such a ship has no presence on the network, you don't need an Azimuth
content/docs/glossary/dojo.md+2−1
@@ -11,4 +11,5 @@ The other default command-line app is [Chat](/docs/glossary/chat). To switch bet
1111and [Chat](/docs/glossary/chat) press Ctrl-X. The Dojo is the first thing you encounter after successfully booting your [ship](/docs/glossary/ship).
1212
1313### Further Reading
14−- [Hoon Tutorial Lesson 1.1: Setup](/docs/hoon/hoon-school/setup): A great way to get started with using Hoon in the Dojo.
14+
15+- [Hoon Tutorial Lesson 1.1: Introduction](/docs/hoon/hoon-school/intro): A great way to get started with using Hoon in the Dojo.
content/docs/hoon/hoon-school/_index.md+28−33
@@ -7,36 +7,31 @@ aliases = ["/docs/byte/0/", "/docs/byte", "/docs/learn/hoon/hoon-tutorial/"]
77insert_anchor_links = "right"
88+++
99
10−This series is designed to teach you Hoon without assuming you have an extensive
11−programming background. In fact, you should be able to follow much of it even if
12−you have no programming experience at all, though of course experience helps. We
13−strongly encourage you to try out all the examples of each lesson. These lessons
14−are meant for the beginner, but they aren't meant to be skimmed. Each lesson
15−falls into one of two categories: **readings**, which are prose-heavy
16−explanations of Hoon fundamentals, and **walkthroughs**, which are line-by-line
17−explanations of example programs. Walkthroughs are found between readings,
18−offering a practical implementation of the concepts taught in the reading
19−before.
20−
21−If you're curious about why Urbit is written in this new language, we recommend
22−reading the [Hoon overview](/docs/hoon/overview) that covers the high-level
23−design decisions behind the language.
24−
25−Chapter 1 introduces and explains the fundamental concepts you need in order to
26−understand Hoon's semantics.
27−
28−Hoon is a "subject-oriented" programming language &mdash; every expression of
29−Hoon is evaluated relative to a **subject**. The subject is a piece of data that
30−represents the environment, or the context, of an expression. After reading
31−Chapter 1 you should understand what the subject is and how to refer to its
32−various parts. In this chapter you'll also learn about
33−**[cores](/docs/glossary/core/)**, which are an important data structure in
34−Hoon. Once you get the hang of [cores](/docs/glossary/core/) you'll be able to
35−write your own functions in Hoon.
36−
37−Chapter 2 covers the type system, writing basic apps, and the workings of the
38−Arvo kernel.
39−
40−You should also consider enrolling in Hooniversity, a regularly held
41−community-run course which follows along the Hoon School curriculum and may be
42−found at [Hooniversity](https://hooniversity.org/).
10+- [1.1 Introduction](https://urbit.org/docs/hoon/hoon-school/intro)
11+- [1.1.1 Walkthrough: List of Numbers](https://urbit.org/docs/hoon/hoon-school/list-of-numbers)
12+- [1.2 Nouns](https://urbit.org/docs/hoon/hoon-school/nouns)
13+- [1.3 Hoon Syntax](https://urbit.org/docs/hoon/hoon-school/hoon-syntax)
14+- [1.3.1 Walkthrough: Conditionals](https://urbit.org/docs/hoon/hoon-school/conditionals)
15+- [1.4 Gates (Hoon Functions)](https://urbit.org/docs/hoon/hoon-school/gates)
16+- [1.4.1 Walkthrough: Recursion](https://urbit.org/docs/hoon/hoon-school/recursion)
17+- [1.5 Lists](https://urbit.org/docs/hoon/hoon-school/lists)
18+- [1.5.1 Walkthrough: Fibonacci Sequence](https://urbit.org/docs/hoon/hoon-school/fibonacci)
19+- [1.6 The Subject and Its Legs](https://urbit.org/docs/hoon/hoon-school/the-subject-and-its-legs)
20+- [1.6.1 Walkthrough: Ackermann Function](https://urbit.org/docs/hoon/hoon-school/ackermann)
21+- [1.7 Arms and Cores](https://urbit.org/docs/hoon/hoon-school/arms-and-cores)
22+- [1.7.1 Walkthrough: Caesar Cipher](https://urbit.org/docs/hoon/hoon-school/caesar)
23+- [1.8 Doors](https://urbit.org/docs/hoon/hoon-school/doors)
24+- [1.8.1 Bank Account](https://urbit.org/docs/hoon/hoon-school/bank-account)
25+- [1.9 Generators](https://urbit.org/docs/hoon/hoon-school/generators)
26+- [2.1 Atoms, Auras, and Simple Cell Types](https://urbit.org/docs/hoon/hoon-school/atoms-auras-and-simple-cell-types)
27+- [2.2 Type Checking and Type Inference](https://urbit.org/docs/hoon/hoon-school/type-checking-and-type-inference)
28+- [2.3 Structures and Complex Types](https://urbit.org/docs/hoon/hoon-school/structures-and-complex-types)
29+- [2.3.1 Walkthrough: Libraries](https://urbit.org/docs/hoon/hoon-school/libraries)
30+- [2.3.2 Molds](https://urbit.org/docs/hoon/hoon-school/molds)
31+- [2.4 Standard Library: Trees, Sets, and Maps](https://urbit.org/docs/hoon/hoon-school/trees-sets-and-maps)
32+- [2.5 Type Polymorphism](https://urbit.org/docs/hoon/hoon-school/type-polymorphism)
33+- [2.5.1 Walkthrough: Iron Polymorphism and Wet Polymorphism](https://urbit.org/docs/hoon/hoon-school/iron-polymorphism)
34+- [2.5.2 Walkthrough: Lead Polymorphism](https://urbit.org/docs/hoon/hoon-school/lead-polymorphism)
35+- [2.6 Behn](https://urbit.org/docs/hoon/hoon-school/behn)
36+- [2.7 Gall](https://urbit.org/docs/hoon/hoon-school/gall)
37+- [2.7.1 Gall Walkthrough: Egg Timer](https://urbit.org/docs/hoon/hoon-school/egg-timer)
content/docs/hoon/hoon-school/intro.mdnew file+121
@@ -0,0 +1,121 @@
1++++
2+title = "1.1 Introduction"
3+weight = 1
4+template = "doc.html"
5+aliases = ["/docs/learn/hoon/hoon-tutorial/setup/"]
6++++
7+
8+This series is designed to teach you Hoon without assuming you have an extensive
9+programming background. In fact, you should be able to follow much of it even if
10+you have no programming experience at all, though of course experience helps. We
11+strongly encourage you to try out all the examples of each lesson. These lessons
12+are meant for the beginner, but they aren't meant to be skimmed. Each lesson
13+falls into one of two categories: **readings**, which are prose-heavy
14+explanations of Hoon fundamentals, and **walkthroughs**, which are line-by-line
15+explanations of example programs. Walkthroughs are found between readings,
16+offering a practical implementation of the concepts taught in the reading
17+before.
18+
19+If you're curious about why Urbit is written in this new language, we recommend
20+reading the [Hoon overview](/docs/hoon/overview) that covers the high-level
21+design decisions behind the language.
22+
23+Chapter 1 introduces and explains the fundamental concepts you need in order to
24+understand Hoon's semantics.
25+
26+Hoon is a "subject-oriented" programming language — every expression of
27+Hoon is evaluated relative to a **subject**. The subject is a piece of data that
28+represents the environment, or the context, of an expression. After reading
29+Chapter 1 you should understand what the subject is and how to refer to its
30+various parts. In this chapter you'll also learn about
31+**[cores](/docs/glossary/core/)**, which are an important data structure in
32+Hoon. Once you get the hang of [cores](/docs/glossary/core/) you'll be able to
33+write your own functions in Hoon.
34+
35+Chapter 2 covers the type system, writing basic apps, and the workings of the
36+Arvo kernel.
37+
38+## Environment Setup
39+
40+Before beginning, you'll need to get a development ship running and configure an
41+appropriate editor. See the [Environment Setup](/docs/development/environment)
42+guide for details.
43+
44+## Getting started
45+
46+Once you've created your development ship, let's try a basic command. Type `(add 2 2)` at the prompt and hit return. Your screen now shows:
47+
48+```
49+fake: ~zod
50+ames: czar: ~zod on 31337 (localhost only)
51+http: live (insecure, public) on 80
52+http: live (insecure, loopback) on 12321
53+> (add 2 2)
54+4
55+~zod:dojo>
56+```
57+
58+You just used a function from the Hoon standard library, `add`. Next, quit Urbit
59+with `ctrl-d`:
60+
61+```
62+> (add 2 2)
63+4
64+~zod:dojo>
65+$
66+```
67+
68+Your ship isn't running anymore and you're back at your computer's normal
69+terminal prompt. If your ship is `~zod`, then you can restart the ship by
70+typing:
71+
72+```sh
73+urbit zod
74+```
75+
76+## Another Noun
77+
78+You've already used a standard library function to produce one value, in the
79+Dojo. Now that your ship is running again, let's try another. Enter the number
80+`17`.
81+
82+We won't show the `~zod:dojo> ` prompt from here on out. We'll just show the
83+echoed command along with its result.
84+
85+You'll see:
86+
87+```
88+> 17
89+17
90+```
91+
92+You asked Dojo to evaluate `17` and it echoed the number back at you. This value
93+is a "noun". We'll talk more about [nouns](/docs/glossary/noun/) in [Lesson
94+1.2](/docs/hoon/hoon-school/nouns), but first let's write a very basic program.
95+
96+## Generators
97+
98+Generators are the most straightforward way to write Hoon programs. They are a
99+concept in Arvo, and involve saving Hoon code in a `.hoon` text file. While they
100+aren't strictly part of the Hoon language, we'll be dealing with generators
101+throughout this tutorial.
102+
103+The simplest type of generator is the **naked generator**. All naked generators
104+are `gates`: functions that take an argument and produce an output. To create a
105+generator, all you need to do is write a `gate`, save it in a `.hoon` file, and
106+add it to the `/gen` directory of a desk on your ship.
107+
108+To be able to add files easily, you'll need to mount a desk to the Unix
109+filesystem. We'll use the `%base` desk throughout Hoon School since we're using
110+a fake ship, but note a different one would be more suitable on a live ship. To
111+mount `%base`, just run `|mount %base` in the dojo. If you look in your
112+[pier](/glossary/pier), you should now see a `base` folder. Once you've added
113+the `.hoon` file in `base/gen`, you'll need to run `|commit %base` in the dojo
114+so the new file is recognised by your ship. To run a generator named
115+`mygen.hoon`, you would type `+mygen <argument>` in your ship's dojo. If you
116+added it to a desk other than `%base`, you can run `+desk!mygen <argument>`
117+where `desk` is the desk you put it in.
118+
119+If this doesn't make sense yet, that's okay. In the [next
120+lesson](/docs/hoon/hoon-school/list-of-numbers), we will walk you through an
121+example `gate` that is run as a generator.
content/docs/hoon/hoon-school/setup.mddeleted−110
@@ -1,110 +0,0 @@
1−+++
2−title = "1.1 Setup"
3−weight = 1
4−template = "doc.html"
5−aliases = ["/docs/learn/hoon/hoon-tutorial/setup/"]
6−+++
7−
8−Before we begin working on Hoon, you should first (1) have Urbit installed and (2) boot a ship that you can use for trying out Hoon examples. Interactive learning is far superior to passive reading.
9−
10−## What is an urbit?
11−
12−An **urbit** is an Urbit virtual computer with persistent state that can connect to the Urbit network. (Note the lowercase `u` here. "Urbit" is the entire software stack, whereas "an urbit" is a local instance.) Each urbit is associated with a unique number that plays three distinct roles: (1) it's an address on the Urbit network, (2) it's a cryptographic identity, and (3) it's (in principle) a human memorable name. Normally an urbit's name is represented as a string starting with `~`, as in `~zod` or `~taglux-nidsep`.
13−
14−These may not look like numbers, but they are. Each urbit name is written in a base-256 format, where each "digit" is a syllable. Imagine your phone number as a pronounceable string which sounds like a name in a foreign language. An ordinary user-level urbit is a "planet", and it's named by a 32-bit number. The latter is represented as a four-syllable string; e.g., the planet name `~taglux-nidsep` is the number 6,095,360.
15−
16−## Installing Urbit
17−
18−You can install Urbit on any Mac or Unix machine; if you're just trying out Urbit or creating a development ship, you can follow the steps for creating a development ship [here](/docs/development/environment). On Windows, make a virtual Linux machine using VirtualBox or a similar tool.
19−
20−Once you're finished, you can [boot your very own ship](/getting-started/). While you can develop in Hoon on your own ship on the live network, we strongly suggest developing on a development ship first.
21−
22−## Getting started
23−
24−Once you've created your development ship, let's try a basic command. Type `(add 2 2)` at the prompt and hit return. Your screen now shows:
25−
26−```
27−fake: ~zod
28−ames: czar: ~zod on 31337 (localhost only)
29−http: live (insecure, public) on 80
30−http: live (insecure, loopback) on 12321
31−> (add 2 2)
32−4
33−~zod:dojo>
34−```
35−
36−You just used a function from the Hoon standard library, `add`. Next, quit Urbit with `ctrl-d`:
37−
38−```
39−> (add 2 2)
40−4
41−~zod:dojo>
42−$
43−```
44−
45−Your ship isn't running anymore and you're back at your computer's normal terminal prompt. If your ship is `~zod`, then you can restart the ship by typing:
46−
47−```sh
48−urbit zod
49−```
50−
51−## Another Noun
52−
53−You've already used a standard library function to produce one value, in the Dojo. Now that your ship is running again, let's try another. Enter the number `17`.
54−
55−> We won't show the `~zod:dojo> ` prompt from here on out. We'll just show the echoed command along with its result.
56−
57−You'll see:
58−
59−```
60−> 17
61−17
62−```
63−
64−You asked Dojo to evaluate `17` and it echoed the number back at you. This value is a "noun". We'll talk more about [nouns](/docs/glossary/noun/) in [Lesson 1.2](/docs/hoon/hoon-school/nouns), but first let's write a very basic program.
65−
66−## Generators
67−
68−Generators are the most straightforward way to write Hoon programs. They are a concept in Arvo, and involve saving Hoon code in a `.hoon` text file. While they aren't strictly part of the Hoon language, we'll be dealing with generators throughout this tutorial.
69−
70−The simplest type of generator is the **naked generator**. All naked generators are `gates`: functions that take an argument and produce an output. To create a generator, all you need to do is write a `gate`, save it in a `.hoon` file, and add it to the `/gen` directory of a desk on your ship.
71−
72−To be able to add files easily, you'll need to mount a desk to the Unix filesystem. We'll use the `%base` desk in this case, but you might like to use a different one if you're not on a fake ship. To mount `%base`, just run `|mount %base` in the dojo. If you look in your [pier](/glossary/pier), you should now see a `base` folder. Once you've added the `.hoon` file in `base/gen/`, you'll need to run `|commit %base` in the dojo so the new file is recognised by your ship. To run a generator named `mygen.hoon`, you would type `+mygen <argument>` in your ship's dojo. If you added it to a desk other than `%base`, you can run `+desk!mygen <argument>` where `desk` is the desk you put it in.
73−
74−If this doesn't make sense yet, that's okay. In the [next lesson](/docs/hoon/hoon-school/list-of-numbers), we will walk you through an example `gate` that is run as a generator.
75−
76−## Text editors
77−
78−Writing code in any language is typically done using a text editor, but common programs like Notepad, Microsoft Word, or OpenOffice Writer are not suitable for programming. You'll want instead a text editor that is specifically designed for writing code. This will assist with things such as colorizing keywords, finding patterns, matching parentheses and brackets, etc.
79−
80−Below is a complete list of text editors that have support for Hoon [syntax highlighting](https://en.wikipedia.org/wiki/Syntax_highlighting) -- an important tool for any programming language. For each of these editors, you'll need to download the editor and then you'll need to install some additional syntax-highlighter package. The process for adding Hoon support differs for every editor. For most newbie-friendly text editors, this is easily accomplished from within the editor itself, and you'll learn how to do so following a newbie tutorial for that editor.
81−
82−If you are brand new to programming, don't think too much about which editor to use; any of the newbie-friendly options will suit you.
83−
84−### Newbie-friendly text editors
85−
86−These editors are easy to use for first-time coders.
87−
88−#### Atom
89−
90−Atom is free and open-source and runs on all major operating systems. It is available [here](https://atom.io/). A package for Hoon support is maintained by Tlon and may be obtained using the package manager within the editor by searching for `Hoon`.
91−
92−#### Sublime
93−
94−Sublime is closed-source, but may be downloaded for free and there is no enforced time limit for evaluation. It runs on all major operating systems. It is available [here](https://www.sublimetext.com/).
95−
96−#### Visual Studio Code
97−
98−Visual Studio Code is free and open-source and runs on all major operating systems. It is available [here](https://code.visualstudio.com/). Hoon support may be acquired in the Extensions menu within the editor by searching for `Hoon`.
99−
100−### Advanced text editors
101−
102−These text editors have a high learning curve and are only recommended for experienced programmers.
103−
104−#### Emacs
105−
106−Emacs is free and open-source and runs on all major operating systems. It is available [here](https://www.gnu.org/software/emacs/). Hoon support is available with [hoon-mode.el](https://github.com/urbit/hoon-mode.el).
107−
108−#### Vim
109−
110−Vim is free and open-source and runs on all major operating systems. It is available [here](https://www.vim.org/). Hoon support is available with [hoon.vim](https://github.com/urbit/hoon.vim) and is maintained by Tlon.