Make Coding Fun
--
I love puzzles. I love memes. Stick figures are the peak of my artistic abilities. These are the reasons I love coding.
A Little Background
I’m lead engineer for Major League Soccer’s mobile team, and we’re in the process of building out a (🔥🔥🔥) new app for our fans. It’s a lot of fun, and writing code is a daily part of my work.
But if you’re anything like me, your daily routine may get a little dull. And in a field like software, the challenges never stop. The inherent risk then, is losing the joy that brought you to work that day.
Aside: I’m not talking about burnout here. Burnout is real, and rest is important. Take time off (and I mean actually off), and look after your mental health. That being said, I’m not here to address that. Many others have articulated that issue better than I could.
What I am here to tell you is that the act of writing code doesn’t have to be serious. It can be playful. It can be creative. It can be fun. And it should be. The following, are just a few of the ways I’ve done so. You’ve been warned.
Making Everything a Meme
Over the past year, I’ve taken every opportunity that I can to make references to Harambe in my code (and if you’re not familiar with Harambe, enlighten yourself). And by every opportunity, I mean it.
I needed a placeholder image
I needed a sample class name
I needed an address
I just needed some body copy
Harambe can (and has) filled all of those spaces. I mean, I had to have some placeholder data. I might as well make it funny. As a result, the code that I write makes me smile. Even when I least expect it. Maybe it’s a test case that’s failing. Typically, this would be irritating, but how irritated can you really be when you see:
Utilizing Emoji
Emoji 👏 are 👏 beautiful 👏 and should be used everywhere. Sure, they should be used in conversations with coworkers and friends, but why not code?
I’m not going to say that I’ve gone to the extent of naming variables with emoji, although I could. Or replacing try catch blocks with table flip variables, although I could.
Really, this just boils down to me writing commit messages with emoji in them or adding emoji to pull request titles and comments, readmes, or code comments. The possibilities are endless!
I just have fun with it. Sprinkling a little bit of 💯 and 🤘 and 🔥 and 🎉 has never hurt anyone, and I’ll use them until they do. And then I’ll replace them with ☹️.
Going Analog
I’m not an artistic person, and I’ll never lie to myself or anyone and say that I am. But I can make a hell of a chart, scribble out an algorithm design, write some mean pseudo code, and draw some wire frames to help me conceptualize layout.
Sometimes the act of picking up a marker and ruining a nice piece of paper with some (pretty shitty) diagrams can help me think and reason about an algorithm. And at the end of the day, that’s what I’m paid to do: think.
So I keep a legal pad next to my desk. And whenever a problem is difficult to solve, I draw it out (and later destroy it out vengeance). This way, I get three victories: one for solving a problem on paper, another for solving it in code, and a third for throwing away the work that made me angry enough to get out a legal pad in the first place.
Writing beautiful code
This one’s in a bit of a different spirit, but I believe that it falls in the same category for me.
When writing out code, it’s often said that code should be stupid simple, and easy to reason about. But honestly, writing `for` loops dozens of times can get old.
JavaScript is a beautiful language that lets me do wonderful (and awful) things to code.
Like replace
With
Or replace
With
Don’t get me wrong, the second example looks atrocious at first glance, but it’s a lot of fun to write. And it just _looks_ more whimsical. I mean, I even used my second point of advice and used emoji!
I got this idea from a book called Beautiful Javascript (highly recommend), and it’s changed how I write code.
Challenging myself to write code in ways that I may not have thought of originally has a lot of benefits. It helps me to grow as a programmer, discover features of a language, and even have a little bit of fun. Those are some of the reasons that I find so much interest in functional programming and languages like ReasonML. It’s a different way of thinking, and it challenges me.
I do think there’s a limit to this, and I’m not advocating making a codebase a puzzle with a bunch of missing pieces. But there’s no reason not to try out new paradigms and make your code a little more pleasant (with some emoji-filled comments describing what you did, of course).
Conclusion
Every workplace is different, and some are more strict than others (so maybe no Harambe references for everyone), but there aren’t many downsides to making the act of coding more enjoyable.
Every person has a different sense of humor and different interests, and the same ideas definitely won’t work for everyone. I’m just on a mission to make my days as interesting as I can, and to bring a little fun into the workplace.
I hope this has been as enjoyable to read as it was to write. If so, hit me with some of them fresh claps, leave a comment, or hit me up on Twitter!