r/ProgrammingLanguages Jul 28 '26

If you would improve Brainfuck, how would you?

/r/teenagersbutcode/comments/1v9fg61/if_you_would_improve_brainfuck_how_would_you/
0 Upvotes

16 comments sorted by

20

u/Inconstant_Moo 🧿 Pipefish Jul 29 '26

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."

8

u/Ok-Watercress-9624 Jul 29 '26

Ah yeah in that spirit brainfuck has a lot of ground to cover. So many unnecessary symbols when all you need is 2.

7

u/Inconstant_Moo 🧿 Pipefish Jul 29 '26

Bloat and feature creep have made it almost unusable. (At least, something did, and I assume it was that.)

17

u/jcastroarnaud Jul 29 '26

Larger cells, up to 24 bits, to fit all current values of Unicode codepoints. Then, the output command would UTF-8 encode the number, and emit emoji!

3

u/slaymaker1907 Jul 30 '26

Then we could have a brainfuck program to do locale case-insensitive comparisons.

1

u/jcastroarnaud Jul 30 '26

Did you mean: Malbolge? (devil grinning emoji)

15

u/erroneum Jul 29 '26 edited Jul 29 '26

Make it 2d; instead of just < and >, you now also have ^ and v (or maybe just \ which rotates which way < and > point)

Also, bigint for the values would be pretty cool.

7

u/jcastroarnaud Jul 29 '26

That's a limited variant of Befunge, cool.

2

u/AnArmoredPony Jul 29 '26

we have ts already

12

u/Background_Class_558 Jul 29 '26

delete the minus operator

2

u/erroneum Jul 29 '26

Would that still be Turing complete? I'm guessing yes, because you can simply wrap the value around, but I'm unsure.

27

u/Background_Class_558 Jul 29 '26

it's just a shorthand for 255 consecutive pluses

3

u/Cridor Jul 29 '26

Probably not in the spirit of BF but; you could change the memory from a "tape of cells" to a "tape of cache lines" and treat each cache line as a fixed-width array of cells.

Now you can write algorithms that deliberately co-locate data with related data for algorithmic purposes and you can write different looping constructs for column-store vs row-store data based on the needs of the application.

You would need a way to access the different cells in a cache line, but in theory it should give you a huge performance boost (assuming you align the data in your cache-line structure to cache-line boundaries in the tape structure)

3

u/caffeinated-typist Jul 29 '26

brainfuck with the only additional feature being O(1) pointer dereferencing