Hacker News new | ask | show | jobs
by jacquesm 4238 days ago
This is fun stuff. Reading around a bit I found this:

"While nowhere near the simplest such automaton known, and certainly not of any theoretical interest, Nock is so stupid that if you gzip the spec, it's only 374 bytes. Nock's only arithmetic operation is increment. So decrement is an O(n), operation; add is O(m * n)... "

Don't they mean 'subtraction' rather than 'add'?

edit: This is so fascinating, it has me totally enthralled. Think smalltalk meets lisp meets some wild eyed programmer who knows just how to appeal to the general frustration most programmers should have (do they?) about the state of our art.

Best post on HN in a long time, very curious how this one will turn out in the long term. May all your ships come in ;)

edit2:

Digging around a bit more: Peter Thiel and a bunch of others have apparently invested in this through a vehicle called 'Tion', https://angel.co/tlon (the Thiel reference is that Thiel backed John Burnham, who is co-founder in Tion).

2 comments

I'm not sure on the specifics here, but I'd have thought that subtraction would be O(n). To perform n - m on a simple register machine with only increment, you just count from m up to n (and count from 0 up to n, outputting 0 if you reach n, since subtraction is partial).

EDIT: It seems they are going for a naive implementation where subtract just repeatedly calls decrement, so yes, that's going to be O(m*n).

It depends on what the n means in O(n). If n means anything other than "the number of digits of x" (i.e., n = log(x)), then this is absurdly slow.
The n is just n: it's the number you are subtracting from. Of course, it's impractically slow, but I believe it's just example code in a opening tutorial for the Nock language.
You are both right. Nock is not meant to be fast.

There are only 10 operators in Nock, and when you get to the last one, you see there's a space for a "hint" to the compiler. This is how Nock becomes fast in Hoon. You start with an extremely slow, naive implementation, and then you write something called a "jet" which is proven (I think usually a weak proof is considered sufficient, like by fuzzing) to be semantically equivalent to the nock that it replaces. Then you do your best to make sure you use that exact expression anywhere you mean that, and don't reinvent it again later.

Jets are currently written in C, since the vere platform is written in C. Learning how they work and how to write them is on my bucket list.

The "corporate tentacle" as they call it is actually called Tlön, not Tion, though you got the link right...

It is a reference to something out of Jorge Luis Borges