View Full Version : Brainfuck programming language
blight
January 10th, 2004, 02:55
Hi!
Checkout this programming language which consists only of 8 operators, the compiler is 171 bytes (runs on linux, dunno about windows) and my first hello-world program is 967 bytes ;P
http://www.muppetlabs.com/~breadbox/bf/
Here's the hello-world which I just wrote:
>+++++++
[<++++++++++>-]
<++>
>++++++++++
[<++++++++++>-]
<+>
>+++++++++++
[<++++++++++>-]
<-->
>+++++++++++
[<++++++++++>-]
<-->
>+++++++++++
[<++++++++++>-]
<+>
>+++
[<++++++++++>-]
<++>
>+++++++++
[<++++++++++>-]
<--->
>+++++++++++
[<++++++++++>-]
<+>
>+++++++++++
[<++++++++++>-]
<++++>
>+++++++++++
[<++++++++++>-]
<-->
>++++++++++
[<++++++++++>-]
++++++++++
< < < < < < < < < < <
.>.>.>.>.>.>.>.>.>.>.>.
:w00t: :blink: :teehee: :crazy: :)
blight
January 10th, 2004, 03:04
matching C code for the program above:
#include <stdio.h> // putchar()
#include <string.h> // memset()
char data[30000];
int main(void) {
char *p = data;
memset( data, 0, 30000 );
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;*p++;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p--;*p--;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p--;*p--;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;p++;
p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;*p++;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p--;*p--;*p--;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p++;*p++;*p++;*p++;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
p--;*p--;*p--;p++;
p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++;* p++;*p++;*p++;
while (*p) {p--;*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++ ;*p++;*p++;p++;*p--;}
*p++;*p++;*p++;*p++;*p++;*p++;*p++;*p++; *p++;*p++;
p--; p--; p--; p--; p--; p--; p--; p--; p--; p--; p--;
putchar(*p);p++;putchar(*p);p++;putchar( *p);p++;putchar(*p);p++;putchar(*p);p++; putchar(*p);p++;putchar(*p);p++;putchar( *p);p++;putchar(*p);p++;putchar(*p);p++; putchar(*p);p++;putchar(*p);
}
Remote
January 10th, 2004, 03:32
I don't get it:P ?? What's it good for except size?
blight
January 10th, 2004, 04:52
it's not very readable and i think there is no way of creating/using functions so i'd say it's uselsee :P
BlueYoshi
January 12th, 2004, 16:18
Hi
I have made BrainFuck intepreter for windows. It can run the code right from the editor and allows using also numeric I/O (no need to convert values into ASCII) for making easily calculation programs... though I'm not sure whether BF is best language for lenghty mathematical operatings ;)
It's available here (http://koti.mbnet.fi/smiika/downloads/BrainFuck0.4.zip) (Delphi sources included).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.