Emojicode: The programming language you should have dreamed of

Theo Weidmann

Emojicode is a static, strongly typed programming language with a focus on integrating systems well, being Unicode compatible, and providing a stable and consistent interface. But what you don’t know is how it came into being.

Some time ago, I had the idea to create a programming language entirely consisting of Emojis. You might now ask: Whatever gave you that idea? And to be honest, I’m not sure anymore myself, but I do remember that somebody sent me a message with a lot of Emojis and I suppose my brain ultimately started parsing that as code.

While at the beginning it wasn’t anything serious, I soon perceived that I was building a programming language. A language in which I could avoid all the wrong decisions that somebody else made when he designed his language. Of course I had built in classes from the very beginning but I soon realised that I needed protocols (interfaces). And after that I realised I hated languages in which somewhere suddenly a NULL value pops up, because you didn’t study the documentation carefully enough (shame on you!). So I built in optionals. And who doesn’t like closures?

Let’s make short tour and see how these features empower Emojicode!

A quick class

Who would use a non-object-oriented programming nowadays? I guess nobody. So it’s just naturally that Emojicode has got first-class class support. Let us declare a class representing a person “👤”:



Not very interesting, is it? Let’s add a few instance variables (name, age) and an initializer:

🐇 👤 🍇
   🍰 name 🔡
   🍰 age 🚂
  🐈 👶 @name 🔡 🍇
     🍮 name @name
     🍮 age 0

I guess it’s not too hard to guess what means what here. What might not be so obviously is, that “🚂” is the integer type. 🍮 is used to set variables to a value.

SEE ALSO: Emojicode – A merrier kind of programming language

There are some other noteworthy things in this example. First of all initializers have names. This way you can always be sure to use the one you intended to use. A very convenient feature. The initializer in this example is named “👶”. Emojicode allows you to use any characters in variables (except emojis), that’s why I could name the initializer’s argument “@name”. But the most important thing about initializers in Emojicode is, that they enforce initialization of all instance variables. If you tried compiling the above example with an initializer like this one:

🐈 👶 @name 🔡 🍇
   🍮 name @name

You would get a message saying: “🚨 line 5 column 6 person.emojic: Instance variable “age” must be initialized.”.
Say good bye to NullPointerExceptions!

Furthermore instance variables are private to the class’s methods. And that is a great way of enforcing encapsulation, as shown by languages like Ruby. If we wanted to make the name of a person accessible we would need to write a better method.
🐖 🙋 ➡ 🔡 🍇
   🍎 name
That’s a whole bunch of code, but basically this declares a method (🐖 ) named “🙋” which returns a string (🔡). The 🍎 is just a “return” statement, which in this example returns the name of the person.

Let’s call a callable

As mentioned at the beginning of this article Emojicode features closures and functions. In Emojicode we call functions “callables” due to the fact that it is the only type you can actually call. Let’s add a method that returns a callable to our person class.

🐖 🕵 ➡ 🍇🔡🍉 🍇
   🍎 🍇 greeting 🔡
     😀 🍪 greeting name 🍪
Here “🍇 🔡 🍉 ” denotes a callable type that takes a string argument and does not return anything. The 🍇 in the body of the class method creates a closure that captures the environment.
So we can now create a person instance, call the 🕵 method and use the returned closure.

🐇🐖 🏁 ➡ 🚂 🍇
    🍦 charly 🔷👤👶 🔤 Charly🔤

    🍦 greeter 🕵 charly

    🍭 greeter 🔤 Hello🔤
    🍭 greeter 🔤 Howdy🔤

    🍎 0
As you can see the code above also defined a new method, more specifically a class method: 🐇 🐖 🏁 ➡ 🚂 🍇 . This method is key as it is the starting point of the program. Then there’s

another new emoji that we’ve used here: 🍦 . 🍦 declares and initializes a “frozen variable”. A frozen variable is like a constant, a variable whose value you can’t change after it was initially set.

The output of the above code is:

Hello, Charly
Howdy, Charly

All this was probably very quick, but as said in the beginning that’s just a very quick tour through the most powerful features of Emojicode.

Generics for the win

Last but not least: Generics. Generics are one of my favourite features in Emojicode since they are a great way to avoid duplicate code, which is one of my main principles when writing code.

The generic type with which you’ll probably interact most is the 🍨 class which represents a list (like an array). Now, we’ll create a 🍨 instance, and since lists are very common there’s a shortcut to do this:

🍨 🔤 Enterprise🔤 🔤 Excelsior🔤 🔤 Relativity🔤 🍆

This will return an instance of type 🍨 🐚 🔡 . And that’s the cool thing. The compiler inferred the concrete list type, that is the generic argument, for you. It detected that the list only contains strings (🔡 ) and therefore used 🐚 🔡 . If you access the list now you’ll get a 🔡 object and you can only ever add 🔡 objects.

Now let’s suppose we want to create a new array from these value by prepending “USS” to all strings. And guess what, this is easily possible:
🍦 starships 🍨🔤Enterprise🔤 🔤 Excelsior🔤 🔤 Relativity🔤🍆
🍦 g 🐰 starships 🐚🔡 🍇 starship 🔡 ➡ 🔡
   🍎 🍪🔤USS 🔤 starship 🍪
🐰 is like “map” methods in other programming languages. It creates a new array and calls the given callable for each value of the old array and appends the returned value to the new array. So “g” should now contain an array with “USS Enterprise” etc. To check that we’ll iterate over the array and print the values:
🔂 ship g 🍇
   😀 ship

If we run this snippet you’ll see:



Ok, so you managed it to read through this high-speed language tour.
And now that you have seen how powerful Emojicode is, head over to the Emojicode Documentation and get started! I’m excited to see what you’ll build with Emojicode!

Theo Weidmann
Theo Weidmann is the creator of Emojicode. He loves Ruby and Jazz.

Inline Feedbacks
View all comments
Potato Head
Potato Head
3 years ago

This articulef is stuipid as hel. U guys suc

Ms. Potato Head
Ms. Potato Head
Reply to  Potato Head
3 years ago

No u