r/code • • Jul 29 '16

Help Please Please help! Need code to announce our pregnancy to my programmer boyfriend... <3

Hi all, my boyfriend is a Senior Software Engineer... I just found out that we are expecting, and I'd love to break the news to him with a block of code! Trouble is, I don't code... Would you all help me write a small block of code to let him know he's going to be a daddy? TIA!

1.3k Upvotes

209 comments sorted by

View all comments

Show parent comment

1

u/GreyVersusBlue Sep 04 '16

So.... You're writing on two sides of a point, simultaneously, and each time you jump from side to side you're writing a new character? And the character is based on a value determined by the +s and -s?

1

u/bcgoss Sep 04 '16

A pointer is a reference to a memory address. It "points" to that byte and says 'this one'. In brainfuck when you use + or - you change the value of the memory you're pointing to. The period symbol is used to read the memory at the current pointer and interpret it as an ascii character to be printed on the screen.

The < and > symbols are used to switch the pointer you're working with. Your program starts off with pointer 0, and you can use > to switch to pointer 1, then do some stuff and use < to switch back to pointer 0. This is useful because you can make changes to Pointer 0 without affecting pointer 1. You can set one pointer to the ascii value of a symbol and the other to point to the letter m. That way you don't have to step the value of the pointer all the way down to 32 just to use a space.

1

u/GreyVersusBlue Sep 04 '16

Alright. I think I understand it.

So what would be a practical reason to use this, rather than more traditional code?

5

u/bcgoss Sep 04 '16

lol

4

u/bcgoss Sep 04 '16

But realistically, there is no use for brainfuck. It exists to demonstrate what is possible when you have very very simple commands. And to fuck with people.

1

u/werewolf_nr Sep 07 '16

The only real advantage I can think of is that the interpreters can be absurdly small. Less than 1kb for some implementations.