

Anyone ever use brainf*k ? - Allocator2008

http://en.wikipedia.org/wiki/Brainfuck#Language_design<p>I was googling something at work today and stumbled across brainf*k, a "minimalist", but still Turing complete language with only 8 instructions, including the io. "&#60;" means decrement the pointer location, "&#62;" means iterate the pointer location, "+" means iterate the pointer byte value, "-" means decrement the pointer byte value, "[" means enter a while type loop until pointer byte value is 0, "]" ends that while loop, "." means put a char to standard out, and "," means read a char from standard out.<p>Anything "real world" one can use this for? Like it is small, so I should imagine it is fast? So like maybe for large problems involving lots of "number crunching"?
======
bkrausz
At this point you may as well be writing in assembly, but compilers are
advanced enough that it's usually more efficient to write in C and let the
compiler convert to assembly.

In short: no.

------
newt0311
So... The compiler itself is insanely efficient (I have heard that it is on
the order of ~200 bytes). However, the compiled code is probably nowhere near
as efficient simply because the high level constructs are hidden from the
compiler. Furthermore, the time that you will save in execution, you will lose
many times over in writing the program (this by the way is why no one should
ever develop in C/C++ unless it is _absolutely_ necessary). BF is primarily a
joke as well as an interesting exercise in what is needed for completeness.

~~~
silentbicycle
It's not "insanely efficient", it's just really _small_. Like Forth, but
without the expressive power, conceptual elegance, efficiency, or speed of
development. :)

I wrote a bf interpreter a few weeks ago. (It's one of those things which is
just tricky enough to be good for trying out languages, btw.) You can't call
anything that makes you deal with strings by repeatedly incrementing cells to
set ASCII codes _efficient_ , seriously. One of my test programs was a rot-13
program, and it was slo-o-o-o-o-ow.

Also (wear a helmet before you read this ;) ), there's an i386 native code
brainfuck compiler, written _in brainfuck_ :
<http://www.nada.kth.se/~matslina/awib/>

------
alnayyir
You realize the language is a programmer circle-jerk inside joke right?

Disclaimer: asm coder.

Also, if you want speed, write in C. Asm is for demi-gods and the masochistic
alone.

------
Allocator2008
Thanks for the tips! My day job is that I write in SilkTest for test
automation, but occasionally have to do some c for stuff silk cannot handle.
So I recently bought the K&R book on C programming, and have been enjoying
that. If nothing else I suppose bf gives one a good "excuse" to learn c in
some more depth by "translating" bf to c or vice-versa. :-)

