Hacker News new | ask | show | jobs
by auggierose 4235 days ago
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.
1 comments

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.