top | item 10508935

Urbit language tutorial, chapter 0

128 points| urbit | 10 years ago |urbit.org | reply

97 comments

order
[+] MichaelGG|10 years ago|reply
Really should lead with an end example then deconstruct how it works. But I get the feeling they are trying to be intentionally obtuse, either to show off cleverness or as performance art. Perhaps that's a bit cynical.
[+] gclaramunt|10 years ago|reply
>But I get the feeling they are trying to be intentionally obtuse, either to show off cleverness or as performance art

Same here. I really don't see the point of renaming well known and defined concepts

[+] nikolay|10 years ago|reply
Yes, to me this is some kind of logorrhoea (or "diarrhea of the mouth"). I think even TempleOS sounds more clearly than Urbit...
[+] ajkjk|10 years ago|reply
I'm finding this tutorial really hard to follow. It doesn't track my mental state very well; each successive sentence that qualifies an idea doesn't follow from the last one to me.

I'm struggling to describe this phenomenon exactly, but I want to try because I'm interested in quantifying it. So here's an attempt:

When I'm reading a tutorial to a new idea, a qualification needs to follow naturally. If you tell me "this is an A", and then follow it with "note: it's not a B", that qualification only works if I would have thought, in my head "oh, is it also a B?" after the first sentence. Otherwise, I'm left in a tough spot: I believe you that it's an A, but I don't trust that I know what an A is, because I'm apparently supposed to have realized that that suggested it could have been a B as well - because you just jumped in and pointed out that it wasn't!

So such a qualification is not just a clarification; it's also narrowing down the possible meanings of A. But I didn't know about all those meanings, because all I have is the word 'A' right now, and I don't understand the complexity of that yet.

Here's a specific example:

"A noun is an atom or a cell. An atom is any unsigned integer. A cell is an ordered pair of nouns.

The noun is an intentionally boring data model. Nouns don't have cycles (although a noun implementation should take advantage of acyclic graph structure)."

As of sentence #3, it looks like a noun can contain cycles. I mean, it can be a cell, and a cell can contain nouns, so that seems like a cycle. Then, in sentence #5, I'm told they don't have cycles. What? Now I don't know what to believe. I thought I understood nouns, but I don't anymore. Then, in the parens, even more concepts are thrown in. Now we're talking implementations - but I don't know what we're implementing. And we're taking advantage of acylic graph structures. Taking advantage? To do what? And the word 'although' shows up. They 'don't' have cycles, 'although' we should take advantage of their not having cycles? Either this is mis-worded or there's even more context I'm missing.

.. anyway, that got wordy. Point is, almost every sentence in this article confuses me further, instead of confusing me less. There are no 'ah-ha' moments. It's just "huh?" after "huh?".

[+] urbit|10 years ago|reply
Thanks for the detailed feedback!

As of sentence #3, it looks like a noun can contain cycles. I mean, it can be a cell, and a cell can contain nouns, so that seems like a cycle. Then, in sentence #5, I'm told they don't have cycles. What?

If we used the word "tree" and "leaf" here instead of "noun," would that help? "A tree is a leaf or a cell. A leaf is any unsigned integer. A cell is an ordered pair of trees."

It doesn't strike me that anyone reading this definition, even not knowing what a "tree" and a "leaf" are, would assume that a tree can have cycles. And then, two sentences later, if we say that a tree doesn't have cycles, I'd hope that that would settle the matter.

It's probably a mistake to bring implementation issues (like the fact that you can share a pointer rather than copying a subtree, thus creating a DAG [1]) into a discussion of this level, though. All kinds of people have different kinds of CS backgrounds...

[1] https://en.wikipedia.org/wiki/Directed_acyclic_graph

[+] openasocket|10 years ago|reply
Two pieces of feedback:

First, at the end of this I'm still rather confused about what molds are for, and it's implied that all will be explained in the next chapter. This is a tutorial, not the next great American novel: do not end chapters on cliffhangers! After finishing a chapter, the reader should be able to go back and fully understand every concept introduced in the text. Either expand this chapter to include a complete explanation of molds, or move molds into a separate chapter.

Two, you include this example of a mold:

++ span

  $%  [%atom p=@tas]

      [%cell p=span q=span]

      [%cube p=* q=span]

  ==
This is chapter 0 of a tutorial on Hoon: do not just include Hoon syntax with no explanation! I have some idea of what this function does from context clues, but I have no way of knowing if my intuition is correct. This is why pseudocode was created: use it! Here's my best guess of what that function does:

  function span_mold(noun n)

    if n is of the form (p,q)

        return [%cell span_mold(p) span_mold(q)]

    else if n is of the form @a

        return [%atom %a]

    else if n is of the form %b

        return [%cube b span(b)]
Is that right? I have no clue!
[+] urbit|10 years ago|reply
It is right! You do have clue!

This is excellent feedback. Normally I'd agree with it. Ideally, this will be the last cliffhanger in the tutorial...

[+] SolarNet|10 years ago|reply
Long story short, this quote:

> Lisp masters beware: Hoon [a b] is Lisp (a . b), Lisp (a b) is Hoon [a b ~]. ~ means nil, with value zero. Lisp and Hoon are both pair-oriented languages down below, but Lisp has a layer of sugar that makes it look list-oriented. Hoon loves its "improper lists," ie, tuples.

along with the knowledge that the people writing this like really strange names (tile, gate, vase, fish) and 2 part symbols (++ += =^) is all you need to know.

[+] kazinator|10 years ago|reply
> 42 and 0x2a are actually the same noun, because they're the same number. [...] But semantically, 42 has a decimal span and 0x2a hexadecimal, so they print differently.

A babbling load of twaddle which in and of itself wouldn't be a crime were the word "semantically" not involved as an abuse victim.

[+] sdegutis|10 years ago|reply
> Lisp and Hoon are both pair-oriented languages down below, but Lisp has a layer of sugar that makes it look list-oriented.

You know, I always wondered about where we should draw the line when describing Lisp as a language family vs. Lisp the original reference implementation, vs. Lisp the originally popular implementation (either CL or Scheme, take your pick). Because I think most people agree that Clojure is a valid Lisp, yet it's not based on pairs like Lisp traditionally is.

[+] theseoafs|10 years ago|reply
All of this can be neatly summarized as "a noun is either an unsigned integer or a pair of two nouns". The authors apparently love to give things funny names and weird syntax, but there's nothing here that Lisp didn't do 50 years ago. Let's see what happens in chapter 1, though.
[+] urbit|10 years ago|reply
Yes! Although there are some things Lisp did 50 years ago, that aren't here. But this is less an improvement on Lisp, than a tribute to Lisp.

Chapter 1 should remind you less of Lisp. Although I do expect to hear "that's just caddadr"...

[+] ThrustVectoring|10 years ago|reply
The "navigate to top" links in the upper left kept appearing and disappearing as I moved my mouse and scrolled around, and it's extraordinarily distracting to me.
[+] state|10 years ago|reply
Yeah, you're right. Was something that sounded good, but is actually just distracting. I'll take it out.
[+] incepted|10 years ago|reply
Ditto. I even moved my mouse cursor on the right side of the window, hoping it would stop.

It didn't.

[+] xixixao|10 years ago|reply
Tududum, anyone's got it cached (Google has some JS only)?

%exit

/~zod/home/~2015.10.17..20.34.57..3a55/arvo/eyre/:<[1.104 9].[1.106 38]>

[%bad-beam %home]

/~zod/home/~2015.10.17..20.34.57..3a55/arvo/eyre/:<[1.103 9].[1.106 38]>

/~zod/home/~2015.10.17..20.34.57..3a55/arvo/eyre/:<[1.102 9].[1.106 38]>

/~zod/home/~2015.10.17..20.34.57..3a55/arvo/eyre/:<[1.101 9].[1.106 38]>

/~zod/home/~2015.10.17..20.34.57..3a55/arvo/eyre/:<[1.100 9].[1.106 38]>

[+] state|10 years ago|reply
Sorry for the interruption. Everything is being served from an Urbit. We have done okay under HN load in the past but may have just screwed up a hotfix.

For the time being, here's a paste of the markdown: http://pastebin.com/G3zMqZN8

[+] mcnamaratw|10 years ago|reply
"FP for street programmers" sounds like a win.

Unfortunately I couldn't really understand anything else. My Lisp is rusty, but dotted pairs aren't something I usually have so much trouble following.

Is there a tutorial that's mostly code examples and not so much text?

[+] urbit|10 years ago|reply
The next tutorial is a lot less wordy, and should hopefully shed a good amount of light backward on this one.
[+] powera|10 years ago|reply
So basically this is a lot of syntax to add something resembling a type-system on top of a fundamentally un-typed language?
[+] urbit|10 years ago|reply
Yeah, that's pretty accurate.
[+] kzrdude|10 years ago|reply
It looks like urbit isn't really “public” yet; they claim to be in “semi-closed alpha” still.
[+] state|10 years ago|reply
It's actually more open than it looks. The code (https://github.com/urbit/urbit) is available to anyone interested. Anyone can build and run a comet.
[+] dragonbonheur|10 years ago|reply
Some languages are so disconnected from programmer needs and real life usefulness that they make me say "I'd rather learn assembler".
[+] tel|10 years ago|reply
How in the world do typeclasses work in Hoon?
[+] loqi|10 years ago|reply
I don't think Hoon's type system actually has a typeclass analogue. As far as I could tell, what it has is something like generics, but in a world where everything is ultimately a noun. IIRC, a previous iteration of the docs explained that "wet gates" (generic functions) are actually required to compile down to the same Nock when "instantiated" at a particular argument, modulo dead code elimination. Didn't look much like ad-hoc polymorphism to me.

A good example is Hoon's maps[1]. They're parameterized on type, but I'm pretty sure those types can't affect the runtime behavior by, say, specifying their own hash or comparison function. Instead, the map implementation[2] hardwires a couple of specific comparison functions[3] that effectively toss the type information and work in terms of the raw underlying nouns.

It is kind of weird that every type carves out a subset of nouns, even function types (or function "molds" or "spans" or whatever... I'll stop calling them types when the Urbit people stop calling it a type system). Hoon's C-flavor really shows when it makes the likes of strlen((char*)strlen) expressible in a purely functional way.

[1]: https://github.com/urbit/urbit/blob/7186219/urb/zod/arvo/hoo...

[2]: https://github.com/urbit/urbit/blob/7186219/urb/zod/arvo/hoo...

[3]: https://github.com/urbit/urbit/blob/7186219/urb/zod/arvo/hoo...

[+] ptc|10 years ago|reply

[deleted]