Compiler C to Brainfuck (for harassing a professor)? [closed]
Asked Answered
I

3

34

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"?

Impetrate answered 26/2, 2011 at 4:26 Comment(6)
I agree fully with belisarius, and I don't think turning in machine-generated code counts as doing the homework assignment in any language you care to use. I would give you a bad grade if I were your instructor. :-)Fibril
@Impetrate Is the same. Just include a zipped version of the source file in the compiled version and you have a language de-compilable on the fly.Stint
Just learn APL or J :-) After all, those are "useful" languages.Thoer
You should write an answer in Postscript - the professor can run it on his laser printer.Azure
Postscript is one of my favourite languages.Nordstrom
I just wanted to appropriately reply to someone who sent a birthday clock written in assembly ;). Anyway, this (esolangs.org/wiki/C2BF) might be helpful...Prisage
T
21

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.

Thoer answered 26/2, 2011 at 5:16 Comment(3)
Look at this one matthias-ernst.eu/piet ... a BF interpreter in Piet!Stint
@belisarius Beautiful art -- I am not able to fathom the minds of other people :)Thoer
J is unbelievable. beust.com/weblog/2008/08/28/coding-challenge-wrap-upPegg
S
12

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.

Speakeasy answered 19/2, 2013 at 9:50 Comment(2)
i wanted to take a look, but ... given the current availability of sourceforge i would suggest to duplicate you work somewhere else too.Machute
@philippelhardy It took me a few years but I took your advice, started from scratch and hosted it on github now ;-)Speakeasy
N
3

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.

Nondescript answered 26/2, 2011 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.