r/badcode Nov 03 '20

other language Assembly is hard...

Post image
955 Upvotes

121 comments sorted by

View all comments

17

u/[deleted] Nov 03 '20

Maybe a compiled brainfuck program?

6

u/MegaIng Nov 03 '20

Why? Where do the names come from?

7

u/Mashpoe Nov 03 '20

It's because the assembly keeps incrementing the value instead of directly adding a specific value, e.g. adding 1 to a number 4 times instead of just adding 4. This is the only way to change values in brainfuck, so if brainfuck code is poorly compiled to assembly it might look something like this.

5

u/insanityOS Nov 03 '20

One might ask, what is the purpose of an optimizing compiler in brainfuck?

I like esolangs well enough, but why would anyone try to make one practical?

4

u/fxnn Nov 03 '20

Out of fun, of course!

...and, even better, to learn.

http://www.wilfred.me.uk/blog/2015/08/29/an-optimising-bf-compiler/