Improve Your Coding Habits With Emojis
When I first began learning Software Engineering at the Flatiron School I was fully prepared to learn brand new coding languages and complex methods, but never expected it to intersect so closely with a language I was already completely fluent in.
As a millennial youth (dare I say an elder Gen Z), I am no stranger to the emoji. At this point, I am sure very few in the internet-engaged world are. Honestly, their universality is astounding. Aside from playing a role as a visual shorthand, emojis tend to be used to fill in the emotional and reactionary gaps created by having text-based, non face-to-face interactions. Not to mention they’re just plain fun. Nothing spices up a group chat like the beloved salsa lady who just won’t quit 💃.
That’s why I was so excited when I found out that emojis could be incorporated into my code. As a still budding programmer, it felt like I could use this tool I was already really comfortable with to make my coding habits even better.
How do emojis work in code?
The reality of using emojis in code is that they function just like strings. As explained by Tom Lord, senior engineer at carwow, every emoji is made up of characters supported by Unicode, sometimes even multiple different characters to modify for skin tone or gender (they look like this U+1F600 = 😀 , find the whole library here).
Your device then translates those characters into an emoji with what is essentially just a font. This is why they sometimes look different on different devices or browsers. (This resulted in one of my top favorite news stories in 2017, otherwise known as “burgergate”).
Any programming language that supports UTF-8 encoding will allow you to implement emojis, so you can already go ahead and start using them in your code. (Think Ruby, Python, Perl, and PHP).
In programming, code readability and organization is key. This is where emojis can really come in handy. Here are a few ideas for how to implement emojis in your coding habits:
Emojis in Comments
Comments within code are meant to be used to make the code easier to understand, or to note important sections. Since their goal is all about human readability, emojis can really help play a role here. Although when an emoji is used in a comment it is not being used within the code itself, this type of visual shorthand helps to break up long chunks of text while adding simplicity and fun. Not only does this help as a solo programmer, but especially when working on a team when many eyes are constantly reviewing the same big blocks of code. Try throwing in a ✨ or a 🚨 next time you want to be sure to catch a co-programmer’s eye in the comments:
Names and Labels
Clearly naming and labeling your many methods, variables, and classes is a key component to creating organized and clear code. More often than not in the debugging process, the error can be attributed to a simple misspelling. This frustration can be avoided by implementing emojis as names and labels within the code. Additionally, aside from its consistent “spelling,” an emoji will stand out and communicate clearly and visually its purpose. Thus, implementing emojis in your naming can be a way to achieve maximum readability. Using emojis is just like using regular strings, so be sure to use all the same rules, such as using quotation marks when setting them as values:
Keep it Fresh
Any experienced programmer (and even newbies) can recognize the experience of staring at the same word for hours across repeated lines of code until it dissolves into visual gibberish. (Try typing and reading the word “search” repeatedly over 3 hours until your brain will just 🤯) Inserting emojis in such places can create a type of speed reading effect, and prevent this phenomena in a fun and colorful way:
Finding elegant solutions in as few characters as possible is one of the things that gets me inspired and excited when developing my own software. I’m thrilled to now know that emojis can be used as an additional tool to achieve prime clarity and readability in my code, and look forward to the creative (and possibly hilarious) ways my peers will be using emojis in their code as well.
Any creative emoji-coding hacks? Be sure to send them my way!