Brainfuck, ABAP F***, WTF?
User Exits, extensions and additional developments – all necessary in the SAP world. But sometimes (as we know from the butcher) it can be a bit more – in this case, a Brainfuck interpreter in ABAP.
During my studies, I had already engaged with the esoteric programming language. More specifically, I wanted to develop a processor design that executes Brainfuck code directly. Regular café visits were a fixed part of my life back then and a reason why the design never went beyond sketches and block diagrams. Therefore, there were never any real tests of suitability using an FPGA or similar.
Brainfuck: Esoteric, yet no hocus pocus
Brainfuck is an esoteric programming language. It should be noted that the term 'esoteric' in this case does not refer to pseudoscientific hocus pocus, but rather emphasises that the programming language is unsuitable for practical application development.
Since Brainfuck is Turing-complete, it is still possible to perform the same calculations that can be implemented in other programming languages like C or ABAP. However, it is generally much more difficult to implement algorithms in Brainfuck than in other languages, as the instruction set is absolutely minimalistic. It consists of exactly eight commands, each represented by a symbol (for details on the instruction set, see Wikipedia).
Furthermore, there are no floating-point types, subroutines, or commands for multiplication, division, or logical XOR operations. Also, branching using 'if' cannot be easily used. These would have to be implemented using loops, whose running condition only allows a check for equality to zero.
And because I am always looking for new challenges outside of developments with business utility, I implemented a Brainfuck interpreter in ABAP at the beginning of the year.
The implementation is available in our ABAP F*** repository on GitHub. Below is a small program in Brainfuck that can be used to test the ABAP implementation.
-[--->+<]>--.[--->+<]>+++.+[->+++<]>++.+[--->+<]>+++.-[---->+<]>++.+++++[->+++<]>.-.--.---.+++++.---------.--[--->+<]>-.++[->+++<]>.+++++++++.+++.[-->+++++<]>+++.---[->++++<]>.------------.---.--[--->+<]>-.+[----->+<]>+.---------.[--->+<]>+.----.[---->+<]>+++.[->+++<]>+.--[--->+<]>---.++.-----------.------.+++++++++.-------.[->+++<]>-.
A bit of fun must be had.



