Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: fb39ca4 on December 07, 2010, 08:07:25 pm

Title: Brainf*ck
Post by: fb39ca4 on December 07, 2010, 08:07:25 pm
I found a brainfuck compiler on ticalc.org. Not knowing what it was, I googled it. Apparently, it is a super-minimalist language with only 8 operators. Anyone tried it yet?
Title: Re: Brainf*ck
Post by: Deep Toaster on December 07, 2010, 08:10:21 pm
Yep: http://ourl.ca/6692/110036 ;D

As for the compiler, any chance it's made by thepenguin77/juju2143?

EDIT: Here: http://ourl.ca/6692/110343
Title: Re: Brainf*ck
Post by: Juju on December 07, 2010, 11:51:11 pm
I only made an über-slow interpreter.
Title: Re: Brainf*ck
Post by: Scipi on December 07, 2010, 11:52:57 pm
I downloaded the stuff to develop in it, but I haven't had the time to try it out yet. ;_; I also need to find a good tutorial. :P
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 08, 2010, 01:04:11 am
Oh wow I remember you posted that juju. I wonder what kind of game quality can be made in Brainfuck?
Title: Re: Brainf*ck
Post by: Builderboy on December 08, 2010, 01:14:29 am
Well its been proven Turring Complete, which means that you could make Portal if you were so inclined :P
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 08, 2010, 01:15:35 am
O.O ?

I wonder how the code would look like...
Title: Re: Brainf*ck
Post by: fb39ca4 on December 08, 2010, 01:32:47 pm
It's set up so you have 30kb of memory all set to zero, and a pointer at the zeroth byte.
There's only 8 commands:
< > increment or decrement the pointer by 1
+ - increment or decrement the value of the byte the pointer points to
. , print or store a character in the current cell
[ if the value of the current byte is zero, then go past the corresponding ]
] go back to the matching [
What I found really ... odd ... is someone wrote a brainf*ck ... in brainf*ck.
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 01:35:25 pm
/me is amazed at how hard this programming language is

Oooh, I love BrainFuck :D  Try this one on for size (routine sucks probably >.>)
Code: [Select]
->[->+>+>+<<<]>>>
[-<<<+>>>]<<<<
[->>[-<+>]>[->+<<+>]>[-<+>]<<<<]>,
Multiplies the first number by the second number, and leaves the result in the... 2nd slot I think... Line breaks were added for readability :D

This is wow...
Title: Re: Brainf*ck
Post by: Ashbad on December 08, 2010, 01:37:07 pm
+++++ +++++                  initialize counter (cell #0) to 10
[                               use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2
    > +++                   add  3 to cell #3
    > +                        add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                    print 'H'
> + .                      print 'e'
+++++ ++ .              print 'l'
.                          print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'


This prints hello world
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 01:38:35 pm
+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2
    > +++                   add  3 to cell #3
    > +                     add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                  print 'H'
> + .                   print 'e'
+++++ ++ .              print 'l'
.                       print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'


Code: [Select]
+++++ +++++           
[                       
    > +++++ ++             
    > +++++ +++++           
    > +++                   
    > +                   
    <<<< -                 
]                   
> ++ .                 
> + .                   
+++++ ++ .           
.                       
+++ .                   
> ++ .                 
<< +++++ +++++ +++++ . 
> .                 
+++ .                 
----- - .           
----- --- .             
> + .                   
> .

Can this be done without entering lines?
Title: Re: Brainf*ck
Post by: Ashbad on December 08, 2010, 01:39:27 pm
yeah
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 01:43:18 pm
Code: [Select]
+++++ +++++ [ > +++++ ++ > +++++ +++++ > +++ > + <<<< - ] > ++ .> + . +++++ ++ . . +++ .  > ++ . << +++++ +++++ +++++ . > . +++ . ----- - . ----- --- . > + . >
If I ever told a programming teacher at a University this was a Hello World program he would not believe it.
Title: Re: Brainf*ck
Post by: JosJuice on December 08, 2010, 01:55:17 pm
Code: [Select]
+++++ +++++ [ > +++++ ++ > +++++ +++++ > +++ > + <<<< - ] > ++ .> + . +++++ ++ . . +++ .  > ++ . << +++++ +++++ +++++ . > . +++ . ----- - . ----- --- . > + . >
If I ever told a programming teacher at a University this was a Hello World program he would not believe it.
No, you're doing it wrong. Remove the spaces :P
Code: [Select]
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>
Title: Re: Brainf*ck
Post by: Ashbad on December 08, 2010, 02:01:12 pm
This actually wouldn't be hard to make a compiler in axe :)
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 02:10:52 pm
This actually wouldn't be hard to make a compiler in axe :)

A ON-CALC Compiler... Hum! That would be cool.
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 08, 2010, 02:44:22 pm
+++++ +++++                  initialize counter (cell #0) to 10
[                               use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2
    > +++                   add  3 to cell #3
    > +                        add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                    print 'H'
> + .                      print 'e'
+++++ ++ .              print 'l'
.                          print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
----- - .               print 'l'
----- --- .             print 'd'
> + .                   print '!'
> .                     print '\n'


This prints hello world
ASM looks easier to read than this. O.O

This actually wouldn't be hard to make a compiler in axe :)

A ON-CALC Compiler... Hum! That would be cool.
Also I thought BrainFuck was interpreted, not compiled? ???
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 02:46:05 pm
Even HEX looks simpler than that to me :)
Title: Re: Brainf*ck
Post by: merthsoft on December 08, 2010, 02:52:15 pm
It is interpreted, though that doesn't mean that it couldn't be compiled. I made a .NET interpreter recently: http://myserverathome.com/BFI.exe (http://myserverathome.com/BFI.exe).
Title: Re: Brainf*ck
Post by: TravisE on December 08, 2010, 02:54:16 pm
In case you don't find that challenging enough, there's always this programming language (http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29)... :devil:
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 02:58:40 pm
In case you don't find that challenging enough, there's always this programming language (http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29)... :devil:

No... I just saw Wiki Page, omG that's impossible!
Title: Re: Brainf*ck
Post by: Scipi on December 08, 2010, 03:18:41 pm
I went to the languages linked. OMG LOLCODE!!!!
Title: Re: Brainf*ck
Post by: thepenguin77 on December 08, 2010, 03:20:31 pm
Actually it is very easy to compile. My compiler mentioned in the second post does just that. It almost directly translates to assembly in fact. > is inc hl, < is dec hl, + is inc (hl), and - is dec (hl). The other four commands are a little more complex, but not much bigger than 10 bytes a piece.
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 03:21:15 pm
Actually it is very easy to compile. My compiler mentioned in the second post does just that. It almost directly translates to assembly in fact. > is inc hl, < is dec hl, + is inc (hl), and - is dec (hl). The other four commands are a little more complex, but not much bigger than 10 bytes a piece.
A compiler with 8 commands xD There are only8 commands so making a compiler must be easy.
Title: Re: Brainf*ck
Post by: TravisE on December 08, 2010, 03:21:55 pm
I went to the languages linked. OMG LOLCODE!!!!

Yeah, I found LOLCODE hilarious.  ;D
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 03:22:43 pm
http://en.wikipedia.org/wiki/LOLCODE (http://en.wikipedia.org/wiki/LOLCODE)

Hahahahaahah
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 08, 2010, 03:26:51 pm
It is interpreted, though that doesn't mean that it couldn't be compiled. I made a .NET interpreter recently: http://myserverathome.com/BFI.exe (http://myserverathome.com/BFI.exe).
lol nice. Now I wish I knew that language X.x

And yeah I remember about Whitespace and Lolcode. About the latter, Miotatsu wrote a tutorial for it a while ago: http://ourl.ca/4689
Title: Re: Brainf*ck
Post by: merthsoft on December 08, 2010, 05:56:42 pm
If you're a fan of esoteric programming languages, you should check out the esolang wiki!:
http://esoteric.voxelperfect.net/wiki/Main_Page (http://esoteric.voxelperfect.net/wiki/Main_Page)
Title: Re: Brainf*ck
Post by: Munchor on December 08, 2010, 06:15:10 pm
http://esoteric.voxelperfect.net/wiki/Joke_language_list (http://esoteric.voxelperfect.net/wiki/Joke_language_list)

Best link ever. Epic.
Title: Re: Brainf*ck
Post by: fb39ca4 on December 08, 2010, 07:56:50 pm
Loooooooooooooooooooool!
I especially liked the Text language.
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 08, 2010, 10:43:27 pm
Lol nice XD

<semi-troll>They should add TI-Nspire BASIC to the joke language list.</semi-troll>
Title: Re: Brainf*ck
Post by: Deep Toaster on December 09, 2010, 12:11:41 am
<semi-troll>They should add TI-Nspire BASIC to the joke language list.</semi-troll>

XD YES That would totally beat half the languages on the list in uselessness!
Title: Re: Brainf*ck
Post by: AngelFish on December 09, 2010, 12:12:52 am
Not even jokingly, either. There's no user input during runtime  :P
Title: Re: Brainf*ck
Post by: Deep Toaster on December 09, 2010, 12:17:49 am
Except 2.0 and above, which have Request, but it gets annoying (like a dialog box that appears out of nowhere. Horrible for games).
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 09, 2010, 01:01:24 am
Yeah true, but what Deep Thought said. Same thing occurs on the TI-89 and 92+, but at least the 68K models got a Getkey function.
Title: Re: Brainf*ck
Post by: TIfanx1999 on December 11, 2010, 10:17:00 am
Lolcode actually looks pretty freaking awesome. You'd think it was developed by the people on that site that must not be named...  O.O

Lol nice XD

<semi-troll>They should add TI-Nspire BASIC to the joke language list.</semi-troll>
:evillaugh:
Quoted For Truth
The sad part is that Nspire BASIC IS likely less funtional than most of the languages on that list.  :'(
Title: Re: Brainf*ck
Post by: fb39ca4 on December 11, 2010, 10:22:22 am
That is very true...
Title: Re: Brainf*ck
Post by: Ashbad on December 11, 2010, 10:38:11 am
at least with brainf*ck you can do whatever you want with those 30K of bytes you have to use...

EDIT: 1111th post :P
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 12, 2010, 05:04:22 am
Does it also let you mess with memory stuff like assembly languages or is it more high level?
Title: Re: Brainf*ck
Post by: Deep Toaster on December 12, 2010, 11:47:18 am
It depends on the interpreter/compiler. There's are commands to modify a single byte at a time, which can technically be any byte in RAM, but some interpreters/compilers (like thepenguin77's) make sure you can only modify bytes in a safeRAM location.
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 13, 2010, 02:12:04 pm
Ah, right, thanks for the info. :)
Title: Re: Brainf*ck
Post by: calcforth on December 27, 2010, 03:24:53 pm
Does it also let you mess with memory stuff like assembly languages or is it more high level?
If you want to mess with memory then Malbolge (http://en.wikipedia.org/wiki/Malbolge) should be your thing. It took two years to write "Hello, World" in Malbolge:
Code: [Select]
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#"
`CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>
The standard Malbolge is not Turing-complete because there are memory limitation, but there are some extended versions which (http://esolangs.org/wiki/Malbolge_Unshackled) are Turing-complete. Lou Scheffer posted a cryptanalysis (sic!) of Malbolge and wrote BrainFuck to Malbolge compiler (http://www.lscheffer.com/bf2malbolge.html).
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 27, 2010, 06:42:08 pm
O.O

I don't think I'll ever touch that language...
Title: Re: Brainf*ck
Post by: c.sprinkle on December 27, 2010, 09:03:19 pm
It looks evil.
Title: Re: Brainf*ck
Post by: calcforth on December 28, 2010, 03:02:49 am
It looks evil.
What do you expect from language named after eight circle of hell?

O.O

I don't think I'll ever touch that language...
I think you are missing the point. Nobody uses Malbolge (or Brainfuck, for that matter) for "real" programming. They exist to show that questions like "what can pointers do that variables can't?" are just incorrect. The answer is always the same: "nothing". You can rewrite any program in Brainfuck and/or Malbolge - and it'll do the same thing still. All constructs which exist in many languages are always about convenience and [sometimes] efficiency, not about pure implementability.

As Joel wrote in this article (http://www.joelonsoftware.com/articles/fog0000000073.html) "understanding pointers in C is not a skill, it's an aptitude", but it does not mean you can avoid them if you are not using C. There are tasks which are easy to implement with pointers and hard without them - and you can write them in any sane or insane language - including TI-Basic or Malbolge.
Title: Re: Brainf*ck
Post by: DJ Omnimaga on December 28, 2010, 06:54:36 pm
Ah I see, then. I wasn't too sure. X.x