Learning to Code vs Learning Computer Science


It's always very tricky when people who aren't educators start banging on about what should or shouldn't be taught in schools. My own school days are but a hazy memory of hormones, angst, and boring homework. Yet here I am, pontificating.

With the current "fad" of encouraging children to learn to code, I thought I would be worth looking at the difference between coding and computer science.
 Creative Commons Attribution-Share Alike 2.0

History

I learned the infamous Logo Turtle at school and BBC BASIC at home. That is learning to code. I followed instructions, copy-typed from books, and made minor adjustments to "personalise" my programs.

At A-Level I started studying "Decision Mathematics". Rather than esoteric calculus, and prosaic formulas, it looks at how to solve problems logically. It was the perfect primer for learning how to become a programmer and I firmly believe that no conversation about teaching coding in schools is complete without a theoretical understanding of the science behind the code.

An Example

This is an exercise I run through with people wanting to understand the basics of computer science:

Sort the following numbers:

7, 8, 1, 3, 2, 7, 6

Easy enough to do in your head, no?

Ok - explain to me how you did it?

We then talk through what we think the problem is - in what way do we want the numbers sorted? High to low? Low to high? Alphabetical? What, in fact, do we want to do with the sorted numbers?

What series of very simple instructions could we give to an absolute idiot such that they could follow them and get the right answer?

Where are the "gotchas"? If two numbers are the same, how should they be sorted? Does it matter?

Are there more or less efficient ways to sort numbers? Are there times when less efficiency is good?

Hey presto - we've begun to explore Computer Science. We can craft algorithms, learn how and why they are important, write out pseudo-code, hunt for bugs.

Learning To Code

The above is a great introduction to Computer Science. Now let's look at what learning to code teaches people.

sort([7, 8, 1, 3, 2, 7, 6]);

Or, perhaps

var numbers = [7, 8, 1, 3, 2, 7, 6];
numbers.sort();

What has that taught anyone? Merely syntax.

I learned the BASIC and Pascal languages at school. Who uses those now? No one. Learning to code an iPhone or Android app is great fun - but in 10 years time when those children are adults, the world will have moved on and Objective C will be yet another obsolete language.

Yes, learning the rudiments of one language can be helpful in picking up another - but it's no substitute for understanding the fundamentals of why you are doing something.

That's why I'm a big supporter of the Apps For Good initiative. Rather than just teaching kids how to build an Android app, it takes them through the process of design, user research, competitor analysis, testing, monetizing, building a team, and legal / social ramifications of releasing an app. All of which are vital tools to any would-be programmer.

It's not just about learning which buttons to press in order to make an app - it's about a deeper understanding.

if ($thou >= $summers_day) {$darling_buds.winds($rough, $shake);}

Let's put it in language the humanities graduates can understand.

Learning to code is merely teaching people to spell.

Computer Science is about what makes a poem beautiful, why alliteration is alluring, how iambic pentameter unlocks the secrets of Shakespeare.

That is what I think we need to be teaching.


Share this post on…

34 thoughts on “Learning to Code vs Learning Computer Science”

  1. Eddie Sammon says:

    Good article. Since getting in the real world I have learned how important maths is in problem solving. For instance, in finance lots of organisations produce different results to the same question, which one is right? It is impossible to say without understanding the mathematics and then testing it. I had to double down on maths after graduating to get better at my job. Maths and science really is the building blocks to so many professions, from coding to financial advice.

    Reply
  2. Speaking as a parent and a coder: I am firmly in the camp that primary-school-ads kids need to be getting computer science and coding as part of the regular curriculum in school. Terence, your sorting example is great, but even if kids only came out of this with an understanding at the level of "this is what a variable is; this is what an IF statement is; this is how a computer program executes; this is what an event is; and so on..." then this would be a big win. Then you start to open up a range of possibilities after that for those kids who have the aptitude and interest to pursue them. The initiatives I have seen making the most progress in this area with real kids are things like Codeclub (though not exclusively and only Codeclub - for example, the people at Codasign are running the after school that my daughter is attending and we are seeing some great results there). The focus in these clubs is making coding fun and engaging kids - absolutely the right approach. However, there is a limit to what you can do in a voluntary club. As with anything involving kids' education, people get very emotional about it. As with anything involving the government, people get very political. I think it's crucial for parents who care about these issues to engage with their schools directly and help schools connect with people and organizations that are doing the right thing.

    Reply
    1. Indeed. I love the approach of CodeClub and have really enjoyed using it as a teaching aide. The "learn to make video games!!!!" is a great hook to get kids interested

      Reply
  3. David Andrews says:

    "It's always very tricky when people who aren't educators start banging on about what should or shouldn't be taught in schools."

    A terrible start to an otherwise decent post.

    Reply
    1. Well, I'm the son of teachers. I had enough experience of hearing them complaining that people who aren't involved in education often have very little idea about how children are taught. Some people think that because they once went to school they are somehow experts on education. That is not the case.

      What I'm saying is that I am not a professional educator and, therefore, am not speaking from a position of authority.

      Reply
  4. "Yes, those primitives back in the 20th Century were fiddling around with these gadgets called 'computers', but really what they were doing was starting to learn how to formalize intuitions about process." (Hal Abelson in the recorded SICP intoductory lecture)

    As much immediate economic value as there may be in cultivating a generation of people capable of instructing computers to do their bidding (and, perhaps, having some idea of how to recognise and exploit the opportunities to do so), it's far more likely that greater and longer-lasting benefit will come from some more generalized understanding of the development and direction of process. That's what "computer science" (for want of a better term) can teach. Process is only incidental to "coding". Or, I suppose it would be better to say that "coding" is a mere notation for process. Concentrating on the notation is missing the point, really, rather like trying to teach creative writing by actually teaching word processing.

    Reply
  5. says:

    I might disagee. While I got the classic CS education, I believe the real value in learning code is learning how to think through how something will work.

    Your sort question is an example if that. But the sort algorithm isn't the only way to become good at thinking logically, and I believe the inner workings of basic algorithms and data structures, which nearly ever language supplies by stock, could be left out. Students can focus on building something useful (which will require the same skill set anyway), and address the lower level stuff later.

    Of course, this reminds me of the criticism professors in my school had for students learning java, instead of learning assembly and c first.

    Reply
  6. One of the problems I find, is when a new employee joins a "programming" department they may well be able to write code, but they won't understand what it does.
    Ultimately you learn to code because you want to write programs - however if you have a CS background you are able to comprehend different paradigms more easily.

    Reply
  7. slw says:

    Learning to code is about learning the tools to make your other jobs easier. If you won't be a programmer, you won't need computer science, knowledge how to code however helps you in whatever your chosen profession might be. If you teach someone to code and it drives him towards programming as a profession, the computer science will follow naturally. If however you teach computer science from the start, it will put off a lot of the students who would otherwise benefit from knowing how to code.

    I also don't understand how monetizing, market research and team building are useful programmer skills, majority of programmers have their business people handle those parts while they focus on actually programming.

    Your Shakespeare analogy is great: basic literacy is necessary at whatever you do. Being able to analyze poetry...not so much.

    Reply
    1. David says:

      I disagree. Learning to code helps to formalise thought processes and these can apply to all sorts of things, like how you organise work schedules, methodology for business etc. There are key transferable competencies that can be developed through coding.

      Reply
  8. Watching the video (http://adrianshort.org/2014/02/09/lottie-dexter-quit-year-of-code/) made me skeptical. She was talking about JQuery. How is "learning to code" and using JQuery in your first day (it didn't seem like they were long in their lessons) a good thing? What about variables? Function? How to write small methods. OOP.

    It seemed a little bit like an introduction lesson for fun. Like what could happen if you see a "scientific" mixing some products together and it makes a beautiful reaction. You don't really know what caused it, it won't make you a "scientific", but it can still be fun. Maybe you'll want to be a scientific after this? But is it really depicting what being a scientific is? It seems to me that it's just one small part of a bigger profession. But is it bad to do this? Honestly, I don't have the answer.

    Also, we are losing more and more the ability to understand the inner workings of computer programming. How is it stored in memory? What's a bit VS a byte? Web servers now are so fast that programmers don't really take the time to learn that stuff. Just adding more RAM to the computer is less complicated. But they'll get into trouble trying to program for "small computers" like phones and probably watches and other smaller materials coming into our lives.

    That being said, I think that it would be good if children learned "how to code" the "right way". Now the right way isn't easy to define, but it should look like how we learned mathematics at school.

    By the way, I think "Logo Turtle" is in fact "Logo Writer"? I also played a little bit with that turtle when I was younger 😉

    Reply
  9. Rob says:

    I'm with Kenny on this.

    As a self-taught programmer. I can write functional, reliable programs that do useful things. However, I never studied computer science. It's only more recently that I've been getting my head around the inner workings of quicksort, and the lambda calculus. I think it is important to have an understanding of such principles, but it's not the best introduction to programming..

    It's better (at least, for my learning style) to approach programming through "here's a problem, here's how you go around solving it". In the process, you can teach language structures - it doesn't really matter which language, since share common features (variables, loops, conditionals). Once kids have a grasp of one language, the second is much easier to learn, and the more fundamental principles can be taught as the problems to be solved become more complex.

    Coding is much more than spelling. It's how to construct sentences, and then to link sentences and paragraphs together in order to make a coherent whole. It's possible to write functional prose, even poetry, without a thorough grounding in prosody or formal knowledge of grammar.

    Reply
    1. I think you're both getting hung up on the quicksort example. I bet, even as a self taught programmer, you've had to break a task down into manageable chunks. You've had to think about why you are trying to solve a particular problem.

      That is Computer Science. Sure, no one in their right mind is going to reimplement a sort algorithm from scratch. Just like no sane baker ever breeds their own yeast - but they need to know how it works!

      As for language - I view that as a distraction. It's much easier to get people to talk in English (or diagrams) to make sure they've fully understood a problem - rather than wrestling with the precise placement of a semi-colon.

      Take Scratch, for example. All the kids I've taught have enjoyed playing with the coding blocks - but it's the ones who have sat down and thought about the problem they're trying to solve which have enjoyed it the most.

      Yes, we should get kids making and building - but they need to understand why a computer works, not just how.

      Reply
    2. nyrulez says:

      I think a better example may be how would you build a spell checker that highlights mis-spelled words in real time ? You can really go down the rabbit hole in solving this one efficiently and doesn't take a fair amount of the CPU/memory. Understanding string algorithms, dynamic programming, edit distances etc. can give a beautiful, concise and efficient solution without bogging the CPU down. And a background in CS gives you just that.
      A naive solution that just tries to guess if a word can be mistyped by trying various permutations would be too slow to use in practice for very large documents as the potential space could be exponential if one just knew how to code/write loops/manipulate objects.

      Another classic example is how would you go about programming delivery logistics if you worked for a courier company ? Or even flight connections for a source,destination pair that optimizes price or time (or both). There is no way just coding skills would help you build solutions that scale and be anywhere close to optimal. Having a good grasp on graph algorithms, shortest path algorithms, approximation algorithms (to the traveling salesman problem) would help you solve these fairly quickly. Without this kind of knowledge, it would take a fairly long time to try to come up with something from scratch.

      Not to discourage, there are a large number of problems that may not require serious knowledge of CS. Most web apps and simple games may fall under this category.

      Reply
  10. Some lovely resources on teaching CS without a computer from NZ based CS Unplugged, including some great material on sorting algorithms as it happens: http://csunplugged.org/sorting-algorithms

    I've been working with trainee infant teachers on this this last week, whilst we've had a fair few bubble sort and insertion sort algorithms, a couple have come up with quick sort without any prompting from me. Respect.

    Reply
  11. John Adams says:

    So, you've underscored a legitimate case then for teaching to code. Some folks have the logic and math training before they learn a programming language. Also, researchers have he propensity to become savvy programers even coming from the humanities. The programming language just becomes another tool to execute their logic. I would argue in favor of my own child attending the liberal arts college and studying stats on the side over a computer science degree that misses the big picture training.

    Reply
  12. nemo says:

    FWIW, pascal was the first language I learned, and I still use it today to contribute to the Hedgewars code. Well, the game engine piece.

    Reply
  13. I chuckled at "Objective C will be yet another obsolete language"..
    .. you do realize Obj-C debuted commercially with NeXTStep in 1988, and not 'popped up out of nowhere' with the first iPhone SDK in 2008, right?

    All of Mac OS X, and iOS have their foundations in Obj-C..

    It's not going anywhere.

    Reply
  14. gary says:

    So this article has prompted some interesting discussion - here, on HN, and I've seen another article that posits the opposite (i.e. learning the science without the practical is equally dangeours). As is usual for the field, everybody has a different opinion.

    I think you're either underestimating or understating the utility of being able to code, and overstating the need for understanding the science behind it all. To extend the spelling/writing metaphor, I think this line of reasoning is along the lines of "Spelling is not enough, you need to be able to be able to write at the level an author would", which is not true - literacy on its own is A Good Thing.

    The way I see these initiatives is that if they can get people coding to help them in their every day jobs and lives, then great. That what they've coded won't, say, scale to inputs of millions is OK if it works for the inputs they use it for. If they then need it to scale, they can enlist the help of someone more knowledgeable, and better versed in the field. As long as these people aren't using their programs for safety critical systems, I think I'm OK with this.

    I admit, there is a sliding scale of knowledge of the science-y aspects, rather than a simple binary choice, but we need to be careful of taking a stance where we warn people not to learn HTML until they learn about, DOMs, and TCP/IP stacks, etc. (I appreciate this isn't the main thrust of what you're saying)

    Oh, and the jibe about those with humanities degrees is not cool, it just reinforces the "This stuff is too technical for Joe Average, if you're not interested in pointer arithmetic, then stay out" tone. If that is your stance, fair enough, but I disagree - there is a middle ground.

    Reply
  15. LAKristopher says:

    I learned computer science and programming together, right before the PC was created. Learning the science makes you a much better programmer.

    Though I never wanted to be a programmer in the end, it was integral part of the degree of study, which actually called Computer Science for Business degree. Anyhow, I ended up learing several languages beginning with BASIC, Assembly 370, RPG II, ending with COBOL I & II.

    Assembly language being the best thing I could have learned as it is machine level language. Had to learn hexadecimal and code in hex. You can to think at what actuallyhappens at machine level, no ccompilers.

    We were taught the 10 steps to writing a program. The 10th being coding the program. I won't explain all ten, but the key to creating any efficient program is to start at the end and work back from there. "What is your end result? Then figure out how to get there."

    I didn't end up in the computer science field, but I understand and know how every program and computer that has been made works. I know what is going on in each program as I use it, along with how the device is dealing with the code too.

    My two on the questions is: Only code, and only science is okay; but learning booth gives a better edge and will help you understand both coding and the sciences much better. Teach both, simultaneously.

    Btw, to the affect of learning of each (coding/science) this will carry on with you throughout your life. I am an example of this. In everything I do, I perform in the most efficient manner timewise, cost wise, energy(physical) wise. And my analytical skill is very high, so I always over examine things.

    All in all my education has put me at an advantage in life.

    Reply
  16. Here in Australia we teach kids to use commercial software, not how to use a computer itself. I argue we need to teach kids how to use a computer to solve problems. So let's not get hung up on whether they are learning "coding", a term that for me implies an artefact of some sort is the desired outcome. Let's just teach them how to get the most out of the wondrous piece of technology on the school desk, not just the software the school has chosen to have running on it.

    Reply
  17. Eli says:

    It seems to me you can learn the "fundamentals of why you're doing something" at any level of abstraction. A sorting algorithm is merely an arbitrary point on a nearly infinite scale. Should you be allowed to just work with arrays and memory allocation and operators without understanding the internals of the language runtime, the kernel, the bytecode, the logic hardwired into millions of tiny transistors in the CPU? That's stuff that's nice to know but it explodes people's brains to try and grasp all this right off the beginning with no mental framework to stuff it into. Even computer science folks don't really care about things like list sorting - they just want it sorted as fast as possible so they can move on to solving actual problems with it.

    It's all mere syntax, or, they're two different things. We can, and should, teach people to reason using any syntax. The more powerful the words the better.

    Then walk through problems the same way. Except these problems are meaningful to the learner. We need the paddle to release a brick onto the playfield? What does that mean the brick should do? How do we have a brick "on" the paddle anyway?

    Reply
  18. Linda says:

    You raise a really important distinction considering the increasing number of initiatives advocating for kids learning to code. Coding is a rather small part of computer science and of the actual process of writing a program (as also pointed out LAKristopher). I totally agree with you that what is important is not the actual code but the thought processes that go before writing the code; the analysis, problem solving and structured thinking you have to go through in order to be able to tell someone (or something) how you went about sorting the numbers. Still, I do think that the example you give for the coding part is too simplified. Sure, no one expects a programmer to write their own implementations for sorting and other functions needed on a regular basis. But I cannot think of anyone teaching an introductory course in programming, who would let students use ready-made functions without first having implemented it themselves (that is, formalizing the idea/algorithm you describe in the "What is CS"-part).

    When discussing what should and should not be covered at lower levels of education, I prefer to talk about computational thinking instead of programming, coding or even computer science. To me Wing's idea of computational thinking, describing a toolbox of thinking skills related to computer science that everyone can benefit from regardless of their own discipline, feels like a more "neutral" and more widely applicable term than any of the more traditional ones.

    Reply
  19. Janet K. Cook says:

    Do you have a non-UK alternative for Apps for Good? It's a great idea, but limited to the UK.

    Reply
  20. Dave Leack says:

    I wholeheartedly agree with this article. Better than teaching any given language is teaching how to *think* about problems. If you can picture how computers work, understand what they can and can't do, and apply their strengths to a problem or data set, you can grab any old language's cookbook and bash out a solution. The algorithm is more important than the code.

    I've met people in the past who have been involved in writing software and firmware, and yet they just aren't in a position to design, analyse and optimise an algorithm. I don't know what it was they missed out in their education that got them to that point, but it seems so odd to me that you can get by slotting together snippets without ever really thinking through the overall architecture. Makes for some pretty slow problem solving and when one of a certain class of bug crops up, people who work like this have a *really* hard time killing it.

    Bravo for this article, expresses my thoughts on the situation precisely.

    Reply

Trackbacks and Pingbacks

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">