Teach Writing Code First
Throughout my career as a software engineer, many people have told me that learning to write code is difficult. I challenge this claim. The real difficulty lies in the fact that most people are taught computer science before they are taught to write code. By computer science, I mean fundamental concepts such as the number of bits in an integer or how various pieces of data are stored in memory. Most people would not fully understand these concepts no matter how well explained because they have no context from which to base an understanding. That context is provided by learning to write code first. When I say “writing code”, I mean it literally. The only expectation on a learner at the beginning is to type code and see that code execute. They should see software do meaningful things before any of the subtleties introduced in computer science are explained to them.
A lot of software engineers would disagree strongly with that last statement. Computer science is taught first because it explains how code works fundamentally and the thinking is that programmers who lack an understanding of the foundational concepts will produce substandard code. However, would you teach a toddler English grammar and linguistics theory first? Or would you start with simple words and sentences? Grammar cannot be understood without first learning the words to make use of it. Code is written in “programming languages” because there are many similarities between a programming language and a spoken language, and the method of learning should be similar as well. Much like how we first teach words to someone learning a new language, we should first instruct a programming student to write as much code as possible before introducing the “grammar” of computer science.
Furthermore, teaching computer science first introduces a pace that is not conducive to learning. Traditional methods of teaching will introduce the learner to a lot of theory and then require them to only write a small amount of software. Before they fully grasp the code that they have written and how the theory applies, they are taught more theory. This cycle of lecturing and reading, with very little practical application can easily discourage a new learner. People want to learn how to write code because they see all the fantastic things that can be accomplished with software. They want to be able to do those fantastic things as well! Personally, I did not write any interesting software until after I completed six months of college coursework. That is a long time to spend on something without a substantial reward for your efforts. For many, there is a temptation to say “programming is too hard for me!” and give up. This could very well happen within days from what I have seen.
So what would a lesson plan for teaching writing code look like? There is a saying that a product is not complete when there are no more features to add, it is when there are no more features to remove. The same goes for a lesson plan. What can we avoid teaching at the beginning? It is tempting for a teacher to introduce a dozen data types right when a learner is introduced to variables, one of the most basic programming concepts. However, in order to teach writing code first, that list should be cut to one or two data types. There are also seemingly basic concepts, such as division, that should be avoided until absolutely necessary. Trying to explain to a first time programmer why 2 divided by 4 does NOT equal 0.5 according to a computer is a nightmare, especially when the computer will display “0.5” on the screen when you ask it to display the result of 2 divided by 4. Plenty of software can be written without even touching that topic. Plenty of software can also be written by teaching 1-2 boolean operations (e.g. comparing 2 pieces of data to make sure they are equal) instead of a dozen. Lessons about how data is stored in computer memory can definitely wait. While being an essential set of knowledge for a programmer working on complex software, most of what a learner works on at the beginning will never actually hit an issue with memory.
This need-to-know lesson plan must be curated carefully, and is thus more work on the instructor’s part. The nice thing about throwing every possible boolean operation at a student at once is that the instructor no longer needs to keep track of which operator was introduced when. They can assume that past a certain point, a learner should know all of them even though they may have only written code that used a couple of those operators. To optimize the learning experience for the student and teach writing code first, the instructor must now know every specific detail of what they taught (and when) instead of general concepts. They must now ensure that every assignment can be completed by a learner using just what has been taught. This will also require many more smaller assignments because instead of one assignment for boolean operators, that concept must be taught over the course of a dozen. The task for the instructor is clearly more challenging, but it is essential to provide the right pace for someone to learn how to write code.
All this may sound as if I don’t care about computer science at all, but nothing can be farther from the truth. Computer science is important and absolutely required for building complex software. However, it is less vital to those who have just begun to learn programming. They do not have the context to truly appreciate computer science. Teaching them how to write code first provides a smoother progression that is more fun and gives a greater sense of accomplishment. Eventually, they will start hitting limits with the software they can build and realize that there are gaps in their knowledge. At this point they will want to fill those gaps. Computer science fills those gaps. Teaching people to write code first teaches people why they need to learn computer science.