Todd Sundsted

My post on using emoji in Crystal Language identifiers got some ๐ŸŽ‰ attention. The obvious question was, how much further could I take a Crystal based solution? I played around with macros for a while to see how much syntax I could replace, but that path didn't go very far. Too much of the language, like block delimiters, showed through.

It turns out there is at least one programming language designed almost entirely around emojiโ€”Emojicode. Emojicode is pretty cool and impressively complete, but because Emojicode is, at its core, a fairly traditional imperative language, it is difficult to keep the ASCII out. ๐Ÿค”

I thought I could do better by modeling an emoji-based programming language on a stack-based language like Forth. ๐Ÿ’ก Heavy use of recursion and the stack makes it easy to avoid naming things, which means โœจ less ASCII and more emoji โœจ.

This ugly duckling defines a word (a function) that computes a factorial. The factorial word is the character โ— (the syntax ๐Ÿ“–โ— ... ๐Ÿ“• defines it as a new word). You can see that โ— calls itself recursively, right?

๐Ÿ’ญ Factorial

๐Ÿ“–โ—๐Ÿ“š2๏ธโƒฃโฌ‡๏ธโ“๐Ÿ‘๐Ÿ—‘๏ธ1๏ธโƒฃ๐Ÿ‘Ž๐Ÿ“š1๏ธโƒฃโž–โ—โœ–๏ธ๐Ÿ”š๐Ÿ“•

๐Ÿ”ข5โ—๐Ÿ˜€   ๐Ÿ’ญ 120
๐Ÿ”ข10โ—๐Ÿ˜€  ๐Ÿ’ญ 3628800

You can use spaces and line breaks to make things more readable, but a lot of Forth code kind of looks like this to me so ๐Ÿคท.

There's already a small number of primitive words and a standard library of additional words. I'll probably play around with the core a bit more and then publish it.

Tower of Hanoi ๐Ÿฏ works, too!

#emoji #forth #esolang