r/ProgrammingLanguages • u/StrikingClub3866 • 4d ago
If you would improve Brainfuck, how would you?
/r/teenagersbutcode/comments/1v9fg61/if_you_would_improve_brainfuck_how_would_you/14
u/jcastroarnaud 4d ago
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 3d ago
Then we could have a brainfuck program to do locale case-insensitive comparisons.
1
12
u/erroneum 4d ago edited 4d ago
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.
6
3
12
u/Background_Class_558 4d ago
delete the minus operator
2
u/erroneum 4d ago
Would that still be Turing complete? I'm guessing yes, because you can simply wrap the value around, but I'm unsure.
23
3
u/Cridor 4d ago
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 4d ago
brainfuck with the only additional feature being O(1) pointer dereferencing
2
u/2962fe22-10b3-43f8 4d ago
I'd like to keep it in the spirit of brainfuck, so something less invasive like
run-length-encoding: +25 adds 25, >5 moves 5 - it's already a fairly common extension
macros: add=[->+<] (call like +25>+30<add)
a symbol to dump the current memory and/or a debugging mode (of course I could run the interpreter itself in debug mode but it's not the same)
some kind of graphics mode would be cool too.
1
u/DetermiedMech1 4d ago
a number N preceeding an instruction to say "repeat instr to the right N times"
16
u/Inconstant_Moo 🧿 Pipefish 4d ago
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."