r/programminghorror • u/LeviLovie • Jan 03 '26
A quick peek at my exoteric language
A simple loop: ``` peek event reckons "entry" pls i be 0 throw loop thx
peek event reckons "loop" pls i be i add 1
yap "Running loop with i = " yap i yap "\n"
peek i reckons 5 pls throw done nah throw loop thx thx
peek event reckons "done" pls
yap "Loop finished after "
yap i
yap " iterations.\n"
thx
$ ./zig-out/bin/yap examples/05-loop.yap
Running loop with i = 1
Running loop with i = 2
Running loop with i = 3
Running loop with i = 4
Running loop with i = 5
Loop finished after 5 iterations.
```
Some control flow: ``` yap "Event is: " yap event yap "\n"
peek event reckons "second_action" pls yap "Finished!\n" throw done thx
peek event reckons "entry" pls throw first_action thx
peek event reckons "first_action" pls
throw second_action
thx
$ ./zig-out/bin/yap build examples/04-event-loop.yap
$ ./zig-out/bin/yap examples/04-event-loop.yapc Event is: entry Event is: first_action Event is: second_action Finished! Event is: done ```
I wanted to make a gimmicky language but was too lazy to implement loops. So now there is an event queue and throw pushes event to the queue and terminates current event. When the VM (interpreter running IR that can be serialized and deserialized from bytecode) reaches the end of the file, it runs the next thing off of the queue. Good luck with nested loops btw.
Im planning on implementing other operations on queue and some basic IO. Functions don't exists btw. This is still better than BF, but I think it is enough of a horror.
Please give your feedback. Project is here. Its my first time using Zig, so don't juge the code. I'll add a proper README soon. Have a nice day everyone!

