Monday, May 19, 2014

Don't learn to code. Learn to think.

This blog post was covered on Lifehacker and translated into Spanish and Chinese. 

It seems like everyone is trying to learn to code: has celebrities like Bill Gates, Mark Zuckerberg, and Chris Bosh telling you anyone can code; CoderDojo's are springing up all over the country; the UK has made it part of their official curriculum for all grade school kids.

I think this is slightly misguided. Don't get me wrong - I do think the world would be better off if everyone had some familiarity with coding - but coding itself should not be the goal. Computers and programming are just tools. They are a means to an end.

The real goal should be to teach people a new way to think. In other words, we should be trying to teach computer science and not just coding. In this blog post, I'll explain the difference between the two, and why focusing on the right one is critical for the movement to succeed.

If you prefer a video explanation, I highly recommend Simon Peyton Jones' wonderful TED talk Teaching Creative Computer Science, which was the inspiration for this post:

Still here for the written version? Great. Let's get started by asking a key question: why should you care about coding or computer science at all?

To answer that, we'll take a walk.

Welcome to the real world
You're probably reading this blog post in Chrome or Firefox, running on Windows or OS X, on a laptop or desktop. I'm guessing you also spent some time today reading email, checking your friends' Facebook statuses, or watching a video on Youtube. Much of your life is on computers these days: your medical records are in a database; you resume is on LinkedIn; you use Google and Facebook to market your products; you use Amazon to buy them; you file your taxes online; you manage your bank account on a website; perhaps you even dabble in digital currencies.

Now, look up from your computer: in your pocket, purse, or on a desk nearby, you may have a smartphone. It's loaded with a GPS, camera, touch screen, and tons of apps. If you're in your living room, you might also have an LCD TV hooked up to digital cable, a DVR, DVD player, Apple TV, XBox, or PlayStation. The movies, music, and games you may play on those devices are packed full of computer graphics and digital audio processing.

Let's head outside. Did you walk past your car? Modern cars are designed using software, built in a factory full of robots, and stuffed full of computers. If you drive your car, you might use Google Maps to find your way around, Yelp to find a place to eat, or TripAdvisor to find a place to stay. Now, look up: somewhere above you, a plane will pass by that is controlled by auto pilot, has in-flight Wifi and entertainment systems, and is constantly communicating with other planes, traffic controllers, and its manufacturer. Somewhere above that, satellites and space stations are orbiting the earth, taking pictures, measuring the weather, and routing phone calls.

Software is eating the world. But this is only the beginning. Before you know it, you'll be wearing technology, locking your doors with computers, using robots to deliver goods and clean your house, building your own electronics, running your own manufacturing plant, living in virtual reality, traveling in self driving cars, and flying to space.

The matrix is everywhere
Absolutely all of the technology I just described is powered by software. In every aspect of your life, you are surrounded by code. And the amount of code is only going to increase in the future.

Now, just because a technology is ubiquitous doesn't mean you have to study it in school. For example, we all fly in airplanes, but getting your pilot's license is not part of the K-12 curriculum.

However, the tools you need to understand how to think about flying are part of the curriculum:
  1. Physics and math help you understand gravity, forces, pressure, velocity, friction, and lift.
  2. Biology teaches you what happens to the human body at high altitudes, with limited oxygen, and extreme cold.
  3. History explains how the airplane was developed, how it evolved, and its role in travel, commerce, and warfare.
By the time you graduate high school, you have an idea of what a plane is, how it works, and how to use it safely. General purpose classes like physics, math, biology, and history teach you how to think about a wide variety of topics, including airplanes; this is in contrast to a class that teaches you how to use a tool, such as how to fly one specific type of airplane.

For the same reason, we should focus on teaching computer science and not just coding: the former is a general purpose way of thinking, whereas the latter is a specific tool. Let's look closer at computer science to get a better understanding of the distinction.

What is computer science?
Computer science is the study of computation: that is, how to represent and process information. Here are just a few of the concepts you might study:
  1. Problem solving: you'll learn algorithms - that is, general strategies, such as divide and conquer, recursion, heuristics, greedy search, and randomized algorithms - that help you model, decompose, and solve any kind of problem.
  2. Logic: you will start to use precise and formal methods of thinking, including abstraction, boolean logic, number theory, and set theory, so you can solve problems in an air tight manner.
  3. Data: you will touch information theory and start asking questions like what is information? How do you represent it? How do you model the real world?
  4. Systems: how do you design and build complex systems that satisfy a set of requirements and constraints? Systems engineering is an essential topic in almost every business.
  5. Thinking: one of the best ways to understand the human mind is to try to replicate it. Topics like artificial intelligence, machine learning, computer vision, and natural language processing are at the forefront of not only computer science, but also biology, psychology, philosophy, and mathematics.
Note that the above list doesn't really mention coding or programming, because they are just tools that can perform computation: they are not, in and of themselves, computer science.
Computer science is no more about computers than astronomy is about telescopes, biology about microscopes, or chemistry about beakers and test tubes. Science is not about tools. - Michael Fellows and Ian Parberry
It turns out there is another tool that we rely on for computation even more: the brain! The goal of computer science is to teach your brain new, general purpose, and widely applicable ways to think. As technology becomes more and more ubiquitous, this new way of thinking will become just as important as physics, math, biology, and history.

All that said, thinking alone is not enough: we need to know how to apply it. In physics, you do experiments with scales, prisms, and magnets; in biology, you might use test tubes, plants, and petri dishes; in computer science, you learn programming.

What is programming?
Programming, or writing code, is how you instruct a computer to perform some operation. If you've never written code before, you're probably used to interacting with a computer by clicking on things in an existing app. Under the hood, this app consists of code that tells the computer how to display the application, where to store or retrieve data, and how to react to your clicks.

All of programming is based on the principles of computer science we discussed above. It is remarkable that the same set of concepts - logic, algorithms, data, systems engineering - can be used to build everything from the web browser you're using to read this post to the autopilot software on an airplane. Although programming involves lots of math and structure, it is also a remarkably creative exercise: you think products into existence, one line of code at a time.

Learning programming as part of a computer science education brings about a number of benefits:
  1. DIY: if you can code, you can build things for yourself. You can start simple: create a script to rename a bunch of travel photos or an Excel formula to help calculate your taxes. Then, get fancier: create a website for your portfolio; create a mobile app for your company; build a game to play with your friends.
  2. Troubleshooting: once you've built a few apps yourself, figuring out other apps is easier. Once you stop fearing the computer - the unknown - you will become a master of tech support. As technology touches every part of your life, knowing how to navigate it will become as important as knowing how to read.
  3. Career: the goal of learning computer science is not to become a professional programmer. We all study math, physics, and chemistry in school, but we don't all become professional mathematicians, physicists, and chemists. However, if you do have a passion for it, you'll find that software engineering is one of the highest rated, highest paid, and fastest growing jobs out there.
Putting it all together
Let's recap:
  1. Computer science is a new way of thinking. The concepts in it are useful for every single person in a technology-filled world.
  2. Programming is an essential part of learning computer science by applying the new way of thinking. However, by itself, programming is not nearly as general purpose.
Confusing these two concepts is causing problems for the learn-to-code movement. Slate published an article called Maybe Not Everybody Should Learn to Code; the Atlantic wrote Should Journalism Schools Require Reporters to 'Learn Code'? No; Jeff Atwood wrote Please Don't Learn To Code, where he asks a question that neatly summarizes the confusion:
"How [would] Michael Bloomberg be better at his day to day job of leading the largest city in the USA if he woke up one morning as a crack Java coder?"
This is, of course, the wrong question. It is the result of public campaigns that suggest that learning to code, as opposed to learning to think, is the end goal. If even Jeff Atwood, an experienced and respected programmer, is fooled by this distinction, then the average person has no chance of getting it right. The question we should be asking is:
Would Bloomberg - or anyone else - be better at their job if they improved their ability to think by learning new problem solving strategies and developing a better grasp of logic?
I think the answer here is obvious. As the world fills up with more and more technology, I think the answer becomes even more obvious. This is why we need to focus on teaching computer science and not just coding.

How to get started
The good news is that you don't need to wait for to get this message - you can start learning computer science right now! In fact, it's one of the easiest topics to learn, as all you need is a computer and an Internet connection, and if you're reading this post, you probably have both.

Here are some great resources to get you going:

University courses
  1. Coursera
  2. Udacity
  3. MIT OpenCourseWare
  4. Stanford Engineering Everywhere
  5. Academic Earth
Online tutorials
Communities and clubs
  1. CoderDojo
  2. Girls Who Code
  3. Girl Develop It
  5. Coding meetup Groups


Pramit Singh said...

I wish this idea of first learning to think got more traction. I also believe this is not only true in case of computing but in other areas of study as well.

Good post.

To your list of useful education sources, please allow me to suggest - a free tool to test and improve your basic knowledge of anything.

Gianfranco said...

An excellent post to read first thing in the morning. I suppose the confusion stems partly from the idea that "software engineers" get highly paid, but fewer think about "computer scientists," yet "biologist" is a common term compared to "lab technician" for an analagous job.

Kurt D said...

If only the idea of learning to think and use logic were a requirement for anyone wishing to write code--sort of a coding "driver's license", though I don't mean a degree from a university when I say that. I've seen many bumbling idiots that had earned a degree in computer science.

I have been programming professionally for almost 20 years, and for over 30 if you count my programming on my old Apple II+ as a child--and I don't mean just "hello world" programming back then. I learned logic very early on with my computer experiences as the old computers did not have IDE's and languages that did a lot of work for you.

Unfortunately modern computers, programming languages, IDE's, and code snippets available via a web search have given anyone the ability to create something and make it work--sort of. All of the software projects I've worked on were written by someone with a bright idea but with no ability to think and therefore code properly.

In the end every bit of code I've seen in my career is garbage and should have been thrown out or rewritten while still in its infancy. However, it was allowed to live on too long. I tried everywhere I worked to get the insanity to stop and to get things rewritten with some genuine thought put into the final product--no luck!

This post mentions the existence of so much code already that runs cars, airplanes, cell phones, ATM's, etc. Sadly I'm sure much of that code was written, as I have experienced, by someone with a good idea but with no programming skills--yes, even the autopilot on the plane in some cases I'm sure. I hope for the future's sake that logic and reasoning is indeed taught rather than just giving the hammer to every man, woman, and child to hit his or her thumb with so they learn the hard way.

I'm about done with software engineering as a career due to being worn out, feeling that way even as the industry grows and my options for better opportunities and income increase. It's sad, and I blame all the so-called-programmers out there that really should have their hammer taken away so they stop hitting MY thumb with it.

Dodgepodge said...

Kurt - cool story, and its amazing how you learned early on.

Sadly, there are a lot of bad programmers out there, but its the same with every other profession.

It's also sad that the blame is passed on to the fellow programmers - at your level if experience, you can take into teaching that logic and reasoning to the new breed of programmers.

That would be a better way of fixing the situation.


Kurt D said...

Dodgepodge, thanks but I have to throw in the towel soon. I don't even want to try to teach others at this point, plus I would not be taken seriously in that role despite my experience as I never bothered to get a degree.

I would love for anyone who is a programmer or who interacts with programmers that reads this post or our comments to do a test at their workplace or school. Ask someone who claims to be a good computer programmer to write a hello world program. If they ask questions of you about what is needed, then that is a great first step and a plus for that person. Once verbal questions are answered and clarified, let them take the next step.

If they come back with a written hello world program, then never hire them anywhere, period. If they come back with a written specification or statement of work in the native language of the country one resides in (English, German, etc.) with details about the program, the GUI (if there is one) with mocked up screen shots or hand drawings, and how it all is going to work then you might just have yourself a very good computer programmer--a real "engineer" I guess you would say.

My guess is most will fail the first step and just get right to the keyboard and crank something out in 5 minutes (or less)--that's a big fail.

I would say I spend about 7 hours a day thinking and maybe 1 hour coding (ignoring meet time, etc.). The work I do rarely needs to be fixed or reworked again though I am only human and do still make mistakes.

I've worked on something for 10 workdays, only to feel the need to ask for another pair of eyes on the problem as I seem to be stuck. The other eyes sometimes "fix" things in 30 minutes and make me look slow. However, I say "fix" because one month or one year later their "fix" turns out to have broken something else in the software--the very thing I avoid that ends up making my work take 10 or 100 times longer than some other so-called programmer.

Such is the story of the life for 20 years. Again, too tired to keep it up. Thanks for the support.

Neil Smith said...

A big thing in teaching computing in UK schools at the moment is "computational thinking." Unfortunately for me, I've been doing this for so long that it's just "thinking" to me. Any insight into how I think is different is useful to me. Thanks!

(It doesn't help that no one has an uncontentious definition of computational thinking.)

The Geeks said...
This comment has been removed by a blog administrator.
The Geeks said...
This comment has been removed by a blog administrator.
hnr said...

Kurt D: Want a kitchen sink with your hello world program?

Mauricio de Abreu Antunes said...

Nice post! I think some people go straight to learn how to code instead of having some background of CS. It is bad for them because code is just a tool like you said.

Vijay1 said...

Great job on separating the thinking and tools (applying) part! So your title should read "Don't just learn to code. Learn to think." ;)
Unfortunately in our field a lot of emphasis is placed on tools and they are perceived/advertised as the next silver bullet. There is false hope that the new language/framework will solve all the problems that were part of a previous project - without making this distinction that perhaps new thinking/approach rather than simply new tools maybe more of what is required. As it has been famously stated "A fool with a tool is still a fool".

Serguei Vinnitskii said...

Can anybody recommend a good book about problem solving. There are some on amazon but it looks like the author know what he is talking about. Awesome post, btw.

Yoni Risqilana said...
This comment has been removed by a blog administrator.
Critias said...

You don't teach 'thinking' as an abstraction...even more for 'critical thinking'. You do it by thinking about something with a good coach (or teacher). It may as well be coding as anything else...stats is just as good in many ways, as is literature, politics, history. Learning to thing through any of these disciplines involves not the routine, but critical reflection on the outcomes you've achieved from your effort, and, for the richest development, in conversation with another who wants to think critically about a topic.

james igoe said...

Below is is my usual response when I see an article stating that everyone should learn to code:

Rather than programming, it is more important to impart the thinking of computer science (CS) than a specific implementation. Programming can be an end point for some students, but it is likely that programming itself will be increasingly automated, so that one needs more the general concepts common in CS. Even then, programming itself is to some degree a grunt task that one progresses beyond:

The following are typical components of a CS degree:

- algorithms & flowcharting
- systems thinking
- logical systems and set theory
- object-orientation & patterns
- probability, statistics, mathematics

All of the above can be useful in an increasingly automated and data-driven world.

mica said...

@Kurt D @KurtD
Could you provide a list of resources so I could learn to think? I'm very serious about this. Books, classes, websites? I'm hoping you'll receive this so I could get a response..

A Loa said...
This comment has been removed by a blog administrator.
A Loa said...
This comment has been removed by a blog administrator.
Carlos SolĂ­s said...

I studied computer science for about four years and a half. I learned the syntax, I learned the theory of algorithms and data structures, I learned the technologies, but in no moment was I taught to think. I always struggled with programming homework because I knew I would not finish it on time. Even to this date, anything beyond the trivial is too much for my brain to process and understand, sometimes to the point of falling into absolute despair after just seeing the sheet with the requirements. Right now I'm working on quality assurance, mainly because I became an expert in pinpointing everything I could not program without somebody else basically dictating me the pseudocode. The worst part? That's something I was supposed to have practiced in college, and now it's too late to just go rent a coder to grind me into the basics of programming logic and mental fortitude required to finish a project.

MB said...

I'm currently enrolled in a web developer bootcamp and I am confronted with precisely this problem - "monkey see, monkey do" mode is wearing thin, but I don't see any way to turn this ship into the direction of learning how to think. Is this a crafts (developer bootcamps) v. artists (CS degrees) issue? But the feedback from CS graduates isn't deeply encouraging either.

Mako Program said...
This comment has been removed by a blog administrator.
Roel Bobis said...
This comment has been removed by a blog administrator.
James Tuke said...
This comment has been removed by a blog administrator.
Amy Cock said...
This comment has been removed by a blog administrator.
Peter parker said...
This comment has been removed by a blog administrator.