TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Anyone ever use brainf*k ?

2 pointsby Allocator2008almost 17 years ago
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"?

4 comments

bkrauszalmost 17 years ago
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.<p>In short: no.
newt0311almost 17 years ago
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 <i>absolutely</i> necessary). BF is primarily a joke as well as an interesting exercise in what is needed for completeness.
评论 #253799 未加载
alnayyiralmost 17 years ago
You realize the language is a programmer circle-jerk inside joke right?<p>Disclaimer: asm coder.<p>Also, if you want speed, write in C. Asm is for demi-gods and the masochistic alone.
Allocator2008almost 17 years ago
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&#38;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. :-)