In 2013 I turned 40, and as is traditional for a man of middling years, I embarked upon a path of self-examination and reflection which ultimately resulted in me buying a new motorbike. I also decided it was high time I learned to code.
I’ve been fascinated by computers since I was a kid, and was lucky enough to start a career writing for IT magazines while I was still a teenager but, despite having a fairly technical mindset, I never got around to learning to code. That all changed last summer when I finally decided to make time for it.
My first step, and one which I’d highly recommend to anybody who wants to learn how to create software of any kind, was to start working through the free online version of Harvard University’s CS50 introduction to computer science. It’s aimed at complete beginners and is quite easy to follow – it’s also available on iTunesU if you have an iPad.
I started by watching the recorded lectures on the train to work, and then working through the problems/exercises at home in the evening. It’s a great introduction to some of the key principles of coding, and very quickly I was able to write and compile programs in the C language, something which seemed intimidatingly difficult just a few weeks earlier. C is the Latin of programming languages – if you learn how C works, you’ll find it easier to learn any number of other languages.
For this, I turned to Codecademy, an interactive tutorial site which features courses on various languages, including simple things like HTML and CSS, so it’s a great place to learn about the basics of web development as well as more in-depth coding.
PHP is a bottomless can of worms
I worked through the Codecademy PHP track to get up to speed with the basics of the language, and got hold of a copy of Programming PHP, which is a useful reference and tutorial. Since I already had a clear idea of what I wanted to build, I decided to get stuck in and start creating the app that I had in mind, learning as I went along.
Learning PHP is something of a trial. The language itself was fairly easy to pick up, but I’ve found that every time I ask for help online (usually on Reddit’s PHP community, or the coding Q&A site StackOverflow) I seem to open a can of worms. There are a number of issues with PHP that learners should be aware of; mostly the problem seems to be that the language has evolved quite dramatically in recent years, so a lot of the online tutorials you will encounter are out of date and will teach you bad things.
Usually when I ask a question about PHP to fix a small problem, there are a lot of helpful people who will explain at length why everything I think I know is wrong, out of date, insecure and likely to cause the internet to explode. To make things worse, the people who reply to your questions online will not only explain why you’re wrong, they’ll also put a lot of effort into disagreeing with each other about the best way to do things.
It’s a painful process, but it has forced me to learn a lot more about best practices, instead of simply hacking together a solution that ‘just works’.
The app I’ve been working on is almost finished, and every single piece of code has been rewritten several times, even when it worked fine to begin with, just to make the code cleaner, more optimised and secure as my understanding has evolved. Although I’m sure that in the eyes of a veteran developer my spaghetti code still looks appalling – but it works, it’s stable and secure, so that’s a start.
During the learning process I’ve been compiling a list of ‘known unknowns’ – stuff that I need to learn to grow as a coder, but that has had to remain on hold until I’ve built a working version of the app that I can share with the outside world.
Frameworks – a framework (like Cake PHP or Laravel) is a library of code that takes care of common tasks so that you can focus on building your app instead of reinventing the wheel all the time. Apparently all professional developers use frameworks, so I think I need to learn how to use one, and Laravel seems to be the way to go.
More professional tools – I’ve been doing all my coding with Notepad++ so far, but I want to learn how to use a more heavyweight IDE and things like Git for better version control (I’ve accidentally overwritten new code with old a couple of times, which is enough to convince me of the value of this).
Object Oriented Programming – my first experience of programming was with BASIC as a child, so the procedural model of coding makes sense to me (do this, then do that, but only if X is true), OOP is an entirely different way of thinking about code and it’s a bit of a tricky concept to grasp. I’ve started to get my head around it while I’ve been building my app, but there’s a way to go yet. Still, it seems to be something that all ‘real’ coders use, so I think it’s an essential next step.
It’s taken me about six months to get to my current level of being able to build a functioning app with fairly clean code (albeit old-school procedural style code), and my next exercise is to overhaul and rebuild the app using the tools I’ve just outlined. Once I’ve done that I think I’ll be able to reasonably call myself a professional level coder.