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

> Brainf*ck is the antithesis of modern software engineering. There are no comments, no meaningful variable names, and no structure

That's not true. From the little time I've spent trying to read and write some simple programs in BF, I recall good examples being pretty legible.

In fact, because the language only relies on those few characters, anything else you type becomes a comment. Linebreaks, whitespace, alphanumeric characters and so on, they just get ignored by the interpreter.

Have a look at this, as an example: https://brainfuck.org/chessboard.b





I also wonder whether brainfuck (ie turing machine like) coding would be a more efficient interface to LLMs

For those who want to try it, there’s always the https://raku.org module…

  use Polyglot::Brainfuck;
    
    bf hi { 
        ++++++++[>++++[>++>+++>+++>+<<<<-]>
        +>+>->>+[<]<-]>>.>---.+++++++..+++.
        >>.<-.<.+++.------.--------.>>+.>++. 
    }
    
    say hi.decode; # Hello World!
    
    bf plus-two {
        ,++.
    }
    
    say plus-two(buf8.new: 40).head; # 42

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


> That's not true. From the little time I've spent trying to read and write some simple programs in BF, I recall good examples being pretty legible.

Anything in a reasonably familiar type face and size will continue to be legible, however brainfuck is not easily human parsable.

Greatly reducing its ability to be _read and mentally internalized._ With out that, are you really doing software engineering or are you actually a software maintenance person?

A janitor doesn't need to understand how energy generation works if he has to change the light bulb.




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

Search: