⇦ Ramen Development_

Coding with emojis?

Cover Image for Coding with emojis?

Emojis are truly useful in some cases, they can add emotions to our messages so their true meaning doesn't fly over our recipient's head, but should we use them for coding?

Emojicode is an open-source programming language that uses emojis instead of words for tokens, and it might not be a great programming language for your upcoming project, but if you're interested in how a compiler works you should definitely check out the source code.

We've made compilers before for school projects, but none as cool and original as this one, it's truly worth checking out.

Hello World

As you can see in this snippet, the checkered flag represents the start of the program, as the main function, the grape emoji would represent a { and the watermelon one is the } in any other language to group code blocks, the smiley is the equivalent of a print statement, the ABC emoji represents a string and the exclamation emoji means that we are finished sending arguments to our function, kinda like a closing parenthesis ).

A bit overcomplicated? for sure, but fun! and you can learn a lot, by not having very readable code you need to really understand what you’re doing and if you’re interested in how compilers work, this is a great opportunity to understand and think how syntax analysis works (If you’re interested in compilers check this post by Gustavo Padilla).

Now let’s dive a bit deeper, I made this small program to calculate an average between various grades given by the user, try to decipher it yourself before the explanation:

🏁 🍇
  0.0➡️🖍🆕 finalgrade
  🎞🐇💻❗️➡️🖍🆕 grades
  🐨grades 0❗️
  🔂 grade grades 🍇
    finalgrade⬅️➕🍺💯grade❗️
  🍉
  📏grades❓ ➡️ ngrades
  finalgrade⬅️➗💯ngrades❗️
  😀🔤Final grade: 🧲🔡finalgrade❗️🧲🔤❗️
🍉

Here’s the code explained:

🏁 🍇
  💭 We initialize finalgrade as 0.0 (the .0 to specify as a floating number)
  0.0➡️🖍🆕 finalgrade
  💭 We get the command line arguments
  🎞🐇💻❗️➡️🖍🆕 grades
  💭 We delete the first argument from the list (./hello)
  🐨grades 0❗️
  💭 for each grade in the list grades...
  🔂 grade grades 🍇
    💭 turn the grade into a float and add it to the finalgrade
    finalgrade⬅️➕🍺💯grade❗️
  🍉
  💭 get the length of the list into ngrades
  📏grades❓ ➡️ ngrades
  💭 divide the sum of the grades by the length of the list
  finalgrade⬅️➗💯ngrades❗️
  💭 print it as a string!
  😀🔤Final grade: 🧲🔡finalgrade❗️🧲🔤❗️
🍉

I think the comments help a lot to understand this messy code, except for a couple of things:

🎞🐇💻 the laptop emoji is the operating system object, the rabbit is like a dot to access its methods and the 🎞 is the method that returns the arguments.

🍺 the beer emoji is used when you’ll work with optional values that can fail, like in this case we’re converting the arguments to floating numbers, so if the user uses a string as an argument the code will panic, to avoid this you should check the values through an if first.

🧲 the magnet emoji is used to interpolate values in a string, think of it like the f”{value}” in python.

Emojicode:

😀🔤Final grade: 🧲🔡finalgrade❗️🧲🔤❗️

Python:

print(f”Final grade: {str(finalgrade)}”)

To compile it you just type in the command line emojicodec + the name of your file and it will output 2 files, just like a C compiler, and following this logic, you run it with ./filename just like a compiled C program.

Output:

Output

Check the code on github

Learn more about emojicode

Learn about compilers with the source code of emojicode!

Cover Photo by Domingo Alvarez E on Unsplash

More entries

Cover Image for How I translated my portfolio with JavaScript and JSON

How I translated my portfolio with JavaScript and JSON

I didn't want to get into any extra trouble on my personal portfolio to have it ready a bit faster and try something new. So, I came up with a straightforward solution using only JavaScript. Let's get into it.

Ivan Orozco
Ivan Orozco
Cover Image for Flags to represent languages?

Flags to represent languages?

Should I use the flags of the countries with the most population speaking that language? what’s the best way to design the options for language switching?

Ivan Orozco
Ivan Orozco
Cover Image for Coding with emojis?

Coding with emojis?

Emojis are truly useful in some cases, they can add emotions to our messages so their true meaning doesn't fly over our recipient's head, but should we use them for coding?

Ivan Orozco
Ivan Orozco
Cover Image for Easy Simple Job backstory

Easy Simple Job backstory

The story behind our game isn´t complicated, inspired by a video narrating a story on Reddit that tells about a guy that gets a simple but suspicious job in an office, and certain scary things happen.

Ramen Development Team
Ramen Development Team
Cover Image for Dear LinkedIn recruiters...

Dear LinkedIn recruiters...

It is important for recruiters to take the time to review a candidate's profile before sending a job offer.

Ivan Orozco
Ivan Orozco
Cover Image for Lexical analyzer automaton

Lexical analyzer automaton

In this article you will understand how to code your own lexical analyzer.

Gustavo Padilla
Gustavo Padilla