Compiler C to Brainfuck (for harassing a professor)?

14.7k views Asked by At

A professor of mine has said he'll accept homework assignments in any language we'd care to use. I'm on good enough terms that I'd like to mess with him a bit and submit a valid homework assignment using brainfuck, whitespace, or some equally "useful" language.

I have the C-sources for a few simple numerical analysis routines as well as the compiled output and the assembly files they generate.

Does anyone know of a decompiler (or a C->brainfuck translator) that could give me something akin to the "brainfuck source code"?

3

There are 3 answers

3
AudioBubble On BEST ANSWER

Just use APL or J.

Unlike BF, they were actually designed to serve a "useful" (and not a "useful as in BF" sense) purpose - and yet can easily make Perl code-golf entries look like novels. (The dedication and mental training to enjoy these languages is currently more than my skill/effort levels.)

If the goal is using a purely esoteric language, I have always enjoyed the look of Piet programs. It looks prettier and is actually able to solve common CS homework problems. Following the links will reveal "Piet assemblers" and other tools. Win.

Happy coding.

0
EboMike On

A quick Google search brings up the (a?) Brainfuck site, which links to an archive with "all things Brainfuck". I doubt there's a C->brainfuck translator anywhere, I wouldn't think anyone would invest that much time.

2
JorenHeit On

For what it's worth, I just wrote a very simple Brainfuck Assembler (inspired by this SO post actually), which assembles readable source code (not C, just something simple and nameless) to BrainFuck. The source-code and compilation/usage instructions can be found here: BrainFuck Assembler.

Edit: The project has recently been updated under a new name: BrainFix.

Edit 2: I redid the entire project. The new and improved version has quite a lot of features and is available on Github.