Here at Intent HQ we believe how important it is to write good code. Why? First, because writing good code is much cheaper and more fun than writing bad code. Second, because if you write good quality code chances are that the product you are building will be much better. Third, and more important, because writing good quality code is what we are supposed to do: after all, we are getting paid for doing our job well.
For Those About To Code (We Salute You)
Looking for a memorable and fun way to explore programming languages? “Nevermind” the rest, this technique rocks!
As programmers, a large portion of our job is to stay aware of, research, and assess new technologies in an industry that evolves at breakneck speed. Being continually bombarded with such information it can seem like an uphill struggle to process this information in a memorable fashion.
How we cope with this varies on an individual basis, and my method for learning, exploring, and (crucially) remembering a new programming language has been pointed out to be somewhat unconventional, yet strangely effective – perhaps it could be for you too?
THIS IS MAJOR TOM TO GROUND CONTROL
The ubiquitous “Hello World” scenario – whereby you are shown the code necessary to output the words “Hello World” – has long been the defacto introduction to a new language. While this is extremely useful as an indicator of complexity and verbosity, it is soooooo immeasurably dull that it is almost instantly forgettable. The fact that there are so many other “Hello World” examples seems to work against its memorability, as there is nothing to make it stand out.
EXIT HELLO WORLD, ENTER SANDMAN
There have been many studies into the positive effect of the senses on memory. A smell can remind you of a place visited long ago, a song can trigger the memory of a specific moment in time only rememebered subconciously. So can this be utilised for learning a new programming language? Fo’ shizzle! Attempt to apply the language to the lyrics of a song of course!
THIS IS HOW WE DO IT
Now you can’t pick just any song, and this is a key factor to get you highly invested and start priming the memory. It has to be a good fit for the language, which is great for researching and remembering best practices, and hence learning to avoid the bad ones.
For example, take Mark Morrison’s seminal “Return of the Mack”, if you wish to explore Scala, and your idea was to use the
return keyword to accomplish the namesake lyric, you would find that explicitly returning values in Scala is not considered good practice, so may not be a good candidate song. However, you will have learnt something even though it is not an easy fit, from the very fact you evaluated it for a particular scenario, and discounted it, rather than simply reading about the languages nuances. Hence, you are much more likely to remember that in Scala, The Mack never returns!
On the other hand if you wanted to experiment with ranges, symbols, and enumeration in Ruby, Jay-Z’s “99 Problems” could be the perfect fit…
Once it is chosen it likely won’t be a smooth ride. This is fine, it will help!
- Write a rough outline that represents the lyrics well, but likely doesnt compile or run.
- Every time an error is encountered, research the reasons why
- Refactor bit by bit in a manner that still conveys the lyrics or the concepts contained in the song
- Rinse and repeat until compiles and runs
- Evaluate entire program against song lyrics (optional)
- Refactor to better fit song with your newfound wider knowledge (optional)
IT’S LIKE THAT, AND THAT’S THE WAY IT IS
The benefits I find are two-fold:
- In the desire to convey the complexities of a song, you will inevitably run into and experiment with many low level characteristics of the language that you would not encounter in a “Hello World” exercise.
- Recollection of the exercises results is enhanced by having engaged both the creative and analytical functions of the brain and creating a direct mapping between the two, much like the Picture Superiority Effect attempts to do via imagary. In this case it is easier to visually recall the song written in code from memory as there is another stimulus to aid you – the song playing in your head – the same stimulus as when you were performing the excercise.
BACK TO LIFE, BACK TO REALITY
While you may be thinking this as all fun and games and not at all applicable to real life situations, this was used to great effect when I was tasked with interviewing candidates for a QA Automation Lead role. In order to do so, I had to very quickly familiarise myself with Gherkin. Admittedly, this was a much easier task given the limited scope of the language and its human readable syntax, however I decided to make it more interesting by attempting to research and incorporate all the features of the language into a single memborable song.
After toying with Michael Bolton’s “How Can We Be Lovers” (due in equal parts to the conditional structure of the lyrics, and my lifelong admiration of his majestic flowing locks), it was eventually decided to settle upon The Human League’s anthemic “Don’t You Want Me”.
IT’S THE FINAL COUNTDOWN
Hopefully you will find some merit to this “Off The Wall” technique, and perhaps give it a try. However, even if you do not find it useful as a learning tool, consider its potential uses elsewhere, here are some for consideration:
- Recruitment: Candidate employees complete no end of boring coding challenges prior to inteview. Will they put more effort into a challenge that is fun and differentiates itself from the rest? Very probably! Would they be attracted to a company that stands out in its more interesting and relaxed approach? Hell yeah!
- Motivation / Team building: Why not introduce a recurring challenge between teams of your programmers? Rewarding perhaps a team lunch for the winners, for a fun activity that gets them working together, thinking outside usual constraints, and lets them experiment with new languages furthering skills within the company.
- Brand Image: When the idea for a “code wall” came about at IntentHQ to showcase excerpts of what is under the hood, these were deemed perfect material for promoting our light hearted attitudes and abilities simultaneously, whilst also creating a talking point for intrigued visitors.
Above all have fun, and make of it what you like – I’ll be seeing you at the first Programmy Awards ceremony!