In amongst all of the Christmas festivities, I’ve finally had the chance to do something I have neglected for some time – program for fun. I enjoy teaching programming at school, but I very rarely find myself doing any programming outside of school – perhaps teaching it every day has burnt me out somewhat.
In the past week or so, I feel as though I’ve reverted to my university lifestyle – staying up until the early hours of the morning, blasting metal music through my headphones and working on programming projects. Nowadays however, there are no looming coursework deadlines or dissertations to write. Instead, I find myself programming purely for fun. But what exactly is it that makes it so fun? The fact that I’m terrible at it.
Yes, I’ve got a Computer Science degree. Yes, the pupils at school think I’m some kind of prodigy when I instantly spot the error which has been giving them grief for the last 30 minutes. However, when I go away and program for myself, I still feel the same as I did when I first started programming:
- I’m constantly making stupid mistakes: whether that’s forgetting a semi-colon, forgetting to call a function or writing far more code than necessary. I’m only human.
- I’m constantly challenged: there are times where I get completely stuck, spending hours trying to work out the solution for a problem.
- I’m constantly learning: in solving those new challenges, I’m learning new programming techniques, either to complete new tasks or improve the efficiency of my code.
However, that’s what makes programming so great – you’re always improving.
I recently started using CodeWars & HackerEarth to develop my C# programming further. These sites are brilliant as they give you a series of programming challenges which you can tackle in a language of your choosing.
What I really liked about them was the fact that you are not only assessed on the correctness of your code, but also the efficiency. Upon submitting your solution, you can compare your code & performance to others, which will open your eyes to alternate (And possibly better) ways of solving the same problem.
In fact, I was just doing one of the early C# challenges on CodeWars, which asked me to write a function which returns the number of vowels in a string. Having done this task with both my Year 10 & Year 12 classes earlier this year, I was quite confident that I could quickly come up with an efficient solution.
I managed to solve the problem with a single line of code. With a smug grin on my face, I pressed submit and waited for the confirmation that there was no better way to do this. Alas, there was.
Now there’s nothing in this solution which is new to me, however I haven’t yet developed my programming skill enough to independently come up with this kind of solution. I made the mistake of going for the first solution which came to my head, instead of considering the possible options. Now on a small scale programming challenge, this is fairly meaningless. However, as you begin to work on larger projects, these small decisions can add up to serious performance costs.
“First, solve the problem. Then, write the code.”
The takeaway from all of this is that you never finish learning to program. There are so many different techniques to learn and problems to solve that you can never possibly expect to understand it all. What is important however, is that you maintain a positive attitude, even when things go wrong. If code always worked first time, there would be millions of unemployed programmers.
So if you’re never going to understand it all, and you’re always going to get stuck, then why should you bother learning to program in the first place? Because it feels great when you do finally manage to solve that problem which has been the bane of your existence for the past few hours/days/years.