100 Languages Speedrun: Episode 02: Emojicode

Most programming languages are created to address some genuine need, but some are just an art statement. One such art statement is the Emojicode language - self-described as a "full-blown programming language consisting of emojis."

Hello World

Let's start by writing hello.🍇:

💭𝔀𝓸𝔀
🏁 🍇
  😀 🔤🄷🄴🄻🄻🄾, 🅆🄾🅁🄻🄳🔤❗️
🍉

As you can see, usual keywords have been replaced by emoji:

  • 💭 are comment lines
  • 🏁 🍇 ... 🍉 is the main function
  • 🔤 is like quotes
  • 😀...❗️ is like print
  • in general, ❗️ ends argument list

The contents of the strings and comments don't have to be emoji, but I used my app for fancy text to spice them up as well.

Variables

We can put thing in variables by using ➡️. Variables go on the right, which is fairly unconventional choice, but not completely unheard of. 🧲 does string interpolation:

🏁 🍇
  🔤ⓔⓥⓔⓡⓨⓞⓝⓔ🔤➡️who
  😀 🔤🄷🄴🄻🄻🄾, 🧲who🧲🔤❗️
🍉

Lists and for loops

Lists are created by 🍿...🍆. I get the first emoji, not so sure about the second one.

You can loop with 🔂 iterator list 🍇 body 🍉, which is a decent loop emoji:

🏁 🍇
  🍿
    🔤Python🔤
    🔤JavaScript🔤
    🔤Ruby🔤
    🔤Emojicode🔤
    🔤PHP🔤
  🍆➡️languages
  😀 🔤Most important languages to learn🔤❗️
  🔂 language languages 🍇
    😀 language❗️
  🍉
🍉

FizzBuzz

We need a few more things here.

  • 🔂 variable 🆕⏩ start afterend step is a for i in range(start, afterend, step) loop.
  • i 🚮 15 🙌 0 is i % 15 == 0
  • ↪️, 🙅‍↪️, and 🙅 are if, else if, and else

And with that we can write a FizzBuzz, using fancy fonts for output as well:

🏁 🍇
  🔂 i 🆕⏩ 1 101 1 ❗ 🍇
    ↪️ i 🚮 15 🙌 0 🍇
      😀 🔤𝔽𝕚𝕫𝕫𝔹𝕦𝕫𝕫🔤 ❗
    🍉
    🙅↪️ i 🚮 3 🙌 0 🍇
      😀 🔤𝔽𝕚𝕫𝕫🔤 ❗
    🍉
    🙅↪️ i 🚮 5 🙌 0 🍇
      😀 🔤𝔹𝕦𝕫𝕫🔤 ❗
    🍉🙅🍇
      😀 🔤🧲i🧲🔤 ❗
    🍉
  🍉
🍉

Doubling things

We need one more thing - functions.

Well, we're a bit lost. Documentation doesn't say anything about functions. It has closures so we'd think that this might work:

🏁 🍇
  🍇 i 🔢➡️🔢
    ↩️ i➕i
  🍉 ➡️ double

  😀 🔤🧲⁉️ double 21❗🧲🔤❗
🍉

We need to declare types. 🔢➡️🔢 means takes an integer, and returns an integer. ↩️ is return. ⁉️...❗ is function call. Not too bad.

Y Combinator fail

Unfortunately these cannot be recursive, so this doesn't work at all!

🏁 🍇
  🍇 n 🔢➡️🔢
    ↪️ n ◀️ 3 🍇
      ↩️ 1
    🍉🙅🍇
      💭 Does not work
      ↩️ ⁉️ fib n➖1❗➕⁉️ fib n➖2❗
    🍉
  🍉 ➡️ fib

  😀 🔤🧲⁉️ fib 5❗🧲🔤❗
🍉

Well, I thought about doing the old Lisp trick, and pass fib closure as argument to fib, so it can call itself, but that only works if there are no stupid types getting in the way. It's possible for type system to support Y combinator if it supports recursive types, but I don't think Emojicode does.

Classes

The documentation doesn't say anything about functions, but it has classes. So let's define class 🤖 with method 🚀 that does fib:

🐇 🤖 🍇
  🆕🍇
  🍉

  ❗️ 🚀 n 🔢➡️🔢 🍇
    ↪️ n ◀️ 3 🍇
      ↩️ 1
    🍉🙅🍇
      ↩️ 🚀👇 n➖1❗➕🚀👇 n➖2❗
    🍉
  🍉
🍉

🏁 🍇
  🆕🤖❗️ ➡️ fib

  🔂 i 🆕⏩ 1 31 1 ❗ 🍇
    🚀fib i❗️ ➡️ x
    😀 🔤🧲x🧲🔤❗
  🍉
🍉

If you've been following along, this code shouldn't be too difficult to understand.

  • 🆕🤖❗️ ➡️ fib - creates a new 🤖 and assigns it to fib variable
  • 🚀fib i❗️ ➡️ x - calls 🚀 on fib instance, calling our only method with argument i
  • 🐇 🤖 🍇 ... 🍉 - definition of a class with name 🤖 (class names must be emoji)
  • 🆕🍇🍉 - empty constructor, we need some constructor for every class, even if it doesn't do anything
  • ❗️ 🚀 n 🔢➡️🔢 🍇...🍉 - defining method 🚀...❗️ that taken one integer argument n and returns an integer
  • ↩️ 🚀👇 n➖1❗➕🚀👇 n➖2❗ - recursive call, 🚀👇 n➖1❗ is this.🚀(n-1) in more usual language

Unicode

This language was of course created as an art statement (or as a joke if you prefer to put it that way), but it asks an important question. Throughout the history of programming, nearly every language (APL and Raku being the most notable exception, and don't worry - we'll surely cover both in this series) limited itself to just plain text with ASCII characters.

Even though ASCII symbols were clearly not enough, so symbols get reused to mean ten different things (try to list all syntactic meanings of {} characters in JavaScript or actually in just about any language), and long strings of characters like !==, **= and such get used as fake extra characters.

So the question is - should programming languages keep limiting themselves to just ASCII, or is it finally time to embrace the whole Unicode? An interesting middle ground are ligature fonts like Fira Code - the source code would still say !==, but in the editor you'd see .

Code

All code examples for the series will be in this repository.

Code for the Emojicode episode is available here.