Hacker News new | ask | show | jobs
by lkrubner 5398 days ago
I don't think this is a language people use in real life. It's more for testing. When I went for a job interview at Alexander Interactive http://www.alexanderinteractive.com/ one of the tests they gave me was to write a short bit of code in Brainfuck to reverse a string. The string they gave me was "Hello World". I was allowed to look at the Wikipedia page regarding Brainfuck. They had an interpreter running, into which I could type my code and see the results. I had 15 minutes to make it work.

I think that is where these kinds of languages are used. I think the idea is to test how fast a programmer can learn something new. (For the most part, I'm doubtful about these tests.)

3 comments

My friend, I believe you've missed the tongue-in-cheek nature of the parent comment (and, in fact, that of Brainfuck itself).
Sounds like either they were messing with you; you are messing with us; or Alexander Interactive doesn't respect their applicants
Impossible, or seemingly impossible, interview questions are actually quite useful. It can be quite informative to see how the applicant response to such a situation, and what their "Oh shit, wasn't expecting this" emergency problem solving techniques are.
Which is another way of saying, messing with people is a respectable interview tactic--see how they react to a little nudge.
> Which is another way of saying, messing with people is a respectable interview tactic

I don't think so. Rather it's that technology jobs (and others, surely) often confront frustrating, confounding, and even downright impossible tasks. The ability to identify a situation as impossible or otherwise -- to drill down to the point of conflict -- is prized, as well as the ability to keep it together mentally and keep plugging away.

beautiful! 12 minutes :

>,[[>,]]<[.<]

edit: of course it should be

>,[>,]<[.<]

">,[>,]<[.<]"

    pStr++;
    *pStr = getc(stdin); //or wherever
    while *pStr {
      pStr++;
      *pStr = getc(stdin);
    }
    pStr--;
    while *pStr {
      putc (*pStr, stdout)
      pStr--;
    }
It'll print the reverse of a string, but it will also print everything before it until it hits a null byte. I'd add

    <[-]
to the beginning to null out the preceding byte and hope it wasn't important.

As silly as brainfuck seems, I could see something like it being used in nanobots (should such a thing ever come to pass), where memory would be at a severe premium.

Brainfuck doesn't really save more memory than any other Turing machine language. However, it could save you silicon space in your hypothetical nanobot because everything is an increment -- incrementing can be done by a chain of half adders, which require fewer gates than full adders.
>It'll print the reverse of a string, but it will also print everything before it until it hits a null byte.

exactly! The brainfuck execution starts with the pointer at the first byte of zero-filled array:

http://www.muppetlabs.com/~breadbox/bf/

So the first ">" in my program moves the pointer to the next byte, and this skipped first byte would serve as a stopper when pointer moves back.

Ah. I wasn't aware of that part of the spec. In that case, then, the code would work.

It's an interesting language, and one that I'm not convinced is so entirely without practical application as is commonly stated.