I wrote this as the first and as a test post for my website.
This is what I've learnt by working with one of the most popular esoteric programming language: Brainfuck. Brainfuck is an extreme minimalistic programming language. It only has 8 simple commands.
I wrote the Brainfuck interpreter in C. It has a few modifications and hacks that will makes it a bit more useful and faster. First of all, in Brainfuck there's usually a common sequence of instructions that you can just optimize out e.g. [-]. This operations basically loop until the data in current cell to be 0. We can optimize this by just immediately set the current cell to 0 rather than looping until it become 0. Another modification is to add FFI (Foreign Function Interface). FFI is a common practice in an interpreted programming language to provide a way to use a native or host system's functionality into the interpreted programming language. My Brainfuck interpreter basically reuse the . syntax rather than printing the current cell's data as a character it basically act like a syscall in Linux where you provide the data as a stack in the tape then it will call the according function.
My initial goal with Brainfuck was to implement a Game of Life. But I quickly understand that working with brainfuck purely is a huge pain. With that insight in my mind, I decided to write a programming language that will compile to Brainfuck. Both Brainfuck and Game Of Life is a Turing complete system Any system of data-manipulation rules can be said turing complete if it can be used to simulate any turing machine (including itself). Thus my language (that's compiled into Brainfuck) also need to be turing complete. On top of that, the language also need to be more expressive than Brainfuck since if it's not then there's no benefit on writing such language in the first place.
So the language is a small stack-based and concatenative programming language inspired by Forth and Porth. The development of the language initially goes pretty well until I need to implement array. It took me a few weeks to understand that with my current approach (which will become clear later) won't be successful. Thus in the end I dropped the project.
;; This is an example program that calculate fibonacci number in bfcat the high-level
;; Programming language that compiles on top of Brainfuck
;; N is a preprocessor definitions like #define N 10 in C
def N 100 end
;; a b
0 1
while dup N lt do
;; print a
over print
;; b a
swap
;; b a b
over
;; b (a+b)
add
end
;; as you can see there's no variable in this language
;; we operate by manipulating the stack.
The problem of implementing array comes because Brainfuck as the underlying system doesn't have the capability of random access. Random access is basically the ability of computer to read or write data instantly from any location. Brainfuck doesn't have this capability since it only can move the data pointers and modify data pointed by the data pointer.
There might be a solution to solve this random access problem. For example, I found out that to layout the data into a structure of data and metadata repeated in the tape may fix this problem since we have additional data (the metadata) about the data to work on while reading the data in the current cell. But this requires a huge refactor of the whole code even including the interpreter since FFI expect the data to be layouted immediately without in-between of metadata. But it's just an opinion and I think it's not worth my time to work further.
In the future, I might want to works with something like this again. There's another promising esoteric programming language that I think would be easier to use but also still unique and cool to work on. But it will have to wait LOL.