Have you ever yearned to unlock the mysterious and abstract language of your coding friends? Maybe you’ve gazed longingly at your ashen, sleep deprived dev team hunched over screens of technicolour code straight from a Wachowski fantasy.
Tip 1 – Just code it
Tip 2 – Build something real
For me, my boss at Glasshat wanted a page of automated charts comparing several SEO metrics from 3rd party and internal sources, benchmarked against a series of competitors; what we’ve “creatively” termed the One Pager. For this I had to learn about data structures and authentication, plus connecting to APIs from Glasshat, Facebook, Twitter and Google, as well as JS charting libraries to make it look pretty.
Tip 3 – Get a mentor
If you don’t have the luxury of working with really smart people like I do, then register a Github account. Github offers the developer community “distributed revision control and source code management”, which is kind of like social media for nerds.
It’s a place where people share (and show off) their accomplishments in an open source tradition. And this is gold dust for a budding programming newbie. Lurk around projects which interest you, and when you feel comfortable, start contributing by fixing small bugs, and even building upon the original author’s ideas with new features. Be humble and open to constructive criticism, but like with anything in life, jettison the negative.
Tip 4 – Obsess over the browser console
alert(“Goodbye Cruel World!”);
and pressing enter. Congratulations and well done! You’ve just wrote your first program.
Tip 5 – Embrace laziness
Larry Wall of Perl fame once said there are three great virtues of a programmer; laziness, impatience and hubris. I’m becoming a big believer in laziness, or the ability of writing code in a way which saves considerable time and energy.
One of the problems with the code now, learn later mentality is your technical ramblings will quickly degrade into a maze so complex and repetitive, even yourself will have difficulty understanding it. As Marijn Haverbeke so eloquently puts it:
“The art of programming is the skill of controlling complexity”.
Once you’ve written your first piece of code, expect to spend double the amount of time pulling it apart and re-writing it so it’s more generic, elegant and reusable.
A big thing for me early on was the discovery that functions can have parameters. While I saw people using them in countless examples, it took a while to fully appreciate how fundamental this is to programming laziness. Using functions and parameters means you can reduce repetitive code by creating little generic “machines” which accept one or more input variables. All you need to do is feed the machines your input, and you’ll get a nice output which can be reused again and again. Think of functions as the Ikea of programming. You can create one generic furniture module, say the wooden slats of a bed, and use these slats in many different bed designs.
Take the following conceptual coding example using two repeat functions to create a single and double bed:
(the following should be coloured with syntax highlighter to make it more legible)
Now check out the same conceptual example using a single generic function to create both single and double beds:
The generic example has fewer lines of code and doesn’t repeat itself. Now imagine writing an entire application using this mindset. It’s far easier to read, debug and reuse. But most importantly, other people will be able to understand it.