Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To me, that's still unreadable. While the intention of the code may be documented, it's pretty hard to understand if that "+" is really correct, or if that "<" should actually be a ">". I can't even understand if a comment starts or terminates a particular piece of code.

BTW, how come there are dashes in the comment?





The initial long comment starts with the [ command and ends with the ] command so it forms a loop that is executed while the current cell is nonzero. But initially, all tape cells are zero, so the whole loop is in fact skipped.

Readability is a spectrum. The brainfuck code is still somewhat readable compared to for instance this Binary Lambda Calculus program:

00010001100110010100011010000000010110000010010001010111110111101001000110100001110011010000000000101101110011100111111101111000000001111100110111000000101100000110110

or even the lambda term λ(λ1(1((λ11)(λλλ1(λλ1)((λ441((λ11)(λ2(11))))(λλλλ13(2(64)))))(λλλ4(13)))))(λλ1(λλ2)2) it encodes.


First, the parent comment didn't say anything about a spectrum. It just posited "it's legible." But it isn't to me, nor to 99.999% of the people here, I assume. Even those who've dabbled once in BF will probably find it hard, as the comment admits to using tricks.

Second, while readability comes in various degrees (probably more of a high-dimensional value than a linear spectrum, but well), the only thing that's readable about brainfuck is the comment. The code itself is not understandable, unless you really start digging into it and manage to understand the state it is in at every step of the program. Even then I would argue it isn't readable: your vision provides very few clues to the meaning of each step.

The comment serves as a guidance where certain parts start (or end, I can't tell). It explains a few things about the code, but even from the comment I cannot understand what it does. Also, the comment might be entirely wrong. There's only a very hard way to tell.

Your binary lambda example is also unreadable, but at least it doesn't have as much state as the BF program (which, admittedly, is much larger). Breaking it down might require less effort.


> it doesn't have as much state as the BF program

Actually, it has much more, as it's an infinitely large prime number sieve, as shown on top of my webpage https://tromp.github.io/cl/cl.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: