This year I spent my summer vacation on the island of Gotland. A remarkable place. It felt like a mixture of some Greek island and Lapland. The initial idea of writing a new text for students was born there: A text on learning to program. A text on learning to solve a problem.
The reason for writing this text was the poor outcome of the practical in “Computer Organization and Computer Networks”. In the recent edition of this practical it became apparent that far too few of the registered students could successfully master the problem of the first assignment. In this assignment, the students got asked to first solve a rather simple problem by coding it in C. Based on this C code, they should then manually compile it to assembly language for a simple computer named TOY. This second step is in fact an exercise fitting to the first part of the material taught in the course.
The problem results in typically less than 100 lines of C code consisting of just the function “main()”, a few global variables, a couple of for-loops and while-loops, some if-statements, and accesses to elements of an array. In addition, the program needs to read values from standard input, and write to standard output. The specification of the assignment requests to use no local variables, no use of the heap, and no function calls within “main()” since the program stack and its use will only be covered later in the course.
The lack of skills to translate a problem description into working code in C seemed to be the major initial hurdle. Despite the fact that they were exposed to all major C language elements in the first-semester course on C, all too many could not solve the problem, and thus gave up early on.
In response to this apparent deficit on problem solving skills, I have written the new text. It shows students how I approach a rather simple task and how I incrementally craft a solution. You can find the text here: https://seafile.iaik.tugraz.at/f/d1b0e83828/. In case you want to download all the example files, here is the link: https://seafile.iaik.tugraz.at/f/d06df6373c/
The final chapter of this text is called “The most important lesson in programming“. It reads like this:
Whenever you want to learn something new, it is a good idea to check out how people who have been in this “trade” for quite some time are doing it. Once they show you how they do, you can still decide whether you want to acquire a particular trick and add it to your own bag of tricks, or shake your head and look for a better solution.
Think of a bicycle repair shop. Think of a carpenter’s workshop. Think of going to such a place to become an apprentice. You might see many tools you have not seen before. You might wonder what they are good for. By watching the more experienced workers in this workshop you learn. You see the use of new tools. You see typical situations arising over and over again. Maybe you also see behavior where you wonder why it is done in this particular way. You might decide to try to improve it. By trying, you get the chance of making errors. By making errors, you find out ways to avoid these errors. You learn.
In your computer you have almost all the tools you need. And whatever tools are missing – you can make them yourself. As a beginner, you have the problem of how to go about all these tools. Which one to take first?
Think of having the task of building all the furniture for a simple kitchen in some carpenter’s workshop. Where would you start? How would you learn to finish in time? Maybe, the master might give you a simpler task for the beginning: Just make the kitchen table. It should be rectangular and should have four legs. Simple enough, isn’t it? But which material should you use? Where to get the material from? Which tool is appropriate for cutting? Which blade? How to make round legs? How to attach the legs to the board? Do you need to paint the parts?
Is it better to first watch an experienced person doing this task? Or is it better to just try?
My answer is: Anything goes. You decide. But do not expect the teacher to teach you anything. Be grateful if she spends time to show you this or that. But only by doing it yourself you can learn. Only by making mistakes, you learn. Only by devoting enough time to a particular task, you give yourself the chance to start enjoying it; you might even get into the flow. Being in the flow is a wonderful feeling.
Are you overwhelmed by the sheer unlimited details you got exposed to in this document? Don’t get scared. If you want to do an expedition to Mount Everest, your first moves are simple: Decide to do it. Think about it some time, but not too long. And then you make the first step. Literally. It is best to do lots and lots of baby steps. These are the building blocks of eventually becoming successful. Even if you do not immediately see that a particular baby step contributes to your gain in experience, it still does. Trust me in this. All computer experts started like you.
Avoid asking the question “What is this good for?” with the argument that “I will surely never need it in my future life.” Try to learn from each and everything that comes along your way. In other words: Avoid the idea that you were able know your future. Most things you will be in touch with in your future do not exist yet. Ask yourself better the question “What is this good for?” from an inventor’s perspective: Anything new you come across can be THE igniting idea to something GREAT. You just have not yet figured this out yet.
All you need is time and curiosity. The nice thing about time is its ultimate fairness: Everyone of us gets the same amount each and every day. The nice thing about curiosity is that you do not have to learn it; you were born with it. In case you forgot about it, just think back. Or just watch any baby doing its baby steps. You were the same.
Never be afraid to ask. Someone might be willing to show you her answer to your question.
Despite all the necessary baby steps, it is OK to aim high. Always aim high. But you have to do all the baby steps in order to eventually get there. Don’t forget to be grateful every day to yourself for all the baby steps you have been doing. Even if you find out that some of the baby steps led into the wrong direction: you have learned from them. No problem. They might be even more useful than the ones into the direction that were obvious from your teacher’s point of view. Be prepared that you are going to experience times where all the baby steps seemingly do not get you anywhere. Be patient with yourself. However, don’t forget that it is hard work. And don’t forget that it is in your hands.
As long as you take your time and nourish your curiosity, you are on the road to success. Your success. Whichever way you define it.
My inspiration for writing this final chapter about learning how to program came from Scott Devine. Spend 15 minutes with Scott – yes, you are at the right spot – about learning to play music. Just apply all the tricks he tells you to programming: http://www.scottsbasslessons.com/beginners/the-most-important-bass-lesson-i-ever-teach.html
I wish all students a good start into the new study year.