What?! 😳 In my code? Yes! 😁19 Aug 2016
Emoji’s might be one of the coolest inventions to hit cell phones. Just behind the Internet. And texting itself. They’re capable of adding so much meaning, but probably most importantly, they’re fun to use.
And clearly, people tend to agree. Most people litter their texts with them. In fact, I can tell when my wife’s displeased with me just by the decreased frequency of smiley faces in her texts. Facebook recently added them. Hundreds of people took the time to write an entire book using nothing else. GitHub even took the time to make them a part of the software development process.
But you know where I haven’t seen them? Comments. And why not? I’d be willing to guess most people (certainly millennials and younger) use them in their text message conversations all. the. time. To convey that extra level of meaning. Because “😂😂😂” shows your amusement better than “lol”. And “👌” is
quicker cooler than “ok”.
What are comments if not quick text messages to your future reader? By adding emojis to our comments we can convey not only the technical details of why we wrote the code we did, but also how we felt about the code when we wrote it. And I’d argue that can be valuable to your future reader, be that yourself or someone else.
Not to mention, it can make the drudgery of documenting code more bearable. You know…slightly…
Let’s look at some examples from codebases I’m juggling at work right now:
I think adding this “exasperated sigh” emoji helps draw attention to our comment. It adds my emotions at the time of writing. I was exasperated with this code. I felt like my hands were tied. I needed an association the legacy database didn’t really support, and so we’re stuck doing something kinda gross. The words convey the technical details of why. The emoji? That cues my future reader into how I felt about this code. All with a simple keystroke.
An Inside Joke, Just for Fun
Perhaps, not the most necessary usage. But sometimes it’s important to have fun with your code and your future reader. Especially, in test code, which isn’t always the most fun to read or write. At least now the reader knows there’s an inside joke here, and, if curious enough, could look it up.
Who Designed This?!? 😡
(See what I did there? 😂 And again.)
This defines a quick helper method that lets us know if we should alert a user based on his alert settings and the type of alert we’re processing. But, of course,
user.alerts_type don’t use the same verbiage so we have this complicated
case checking. Me being me, I added some sarcastic text explaining this, and my personal “wtf?!” face emoji.
Normal prose has both voice and style. I think style comes pretty naturally when writing code. Whether good or bad, most developers have style in their code. How they indent things, when they comment, what constructs they use to do X vs Y, those are all part of a coder’s style. But I don’t think voice comes through as evidently. Emoji’s add the voice. They make your code more personal, and ultimately more enjoyable to read.
If you’re sold, here is the emoji plugin I use with Sublime Text 3 which makes it super easy to search for and insert emojis. Here’s hoping we see more 😁’s and 💯’s than 😑’s in our comments!