Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

As someone who learned to program in my 30s (spent my 20s as a professional musician) I can't agree more. The book that was recommended to me was K&R, which I found so dry as to be impossible to read through. The first book I really used was C++ in 21 Days, which has you writing working programs from...well, from day 1.

I always thought the reason for this problem in teaching programming is that what you need to know when switching to a new language is totally different from what you need to know when you don't know how to program. If you already know how to program, the first thing you need to know is the syntax: data types, iterators, etc. It's like being a carpenter and going to a new shop -- what are the tools? But if you don't know how to use the tools, being told the torque on an impact wrench is completely useless information. Not only is it useless, it's easy to look up, and therefore a waste of time to teach.

I now help teach the Boston Python Workshop, a weekend workshop for non-developer women and their friends. We do cover loops and data types on Saturday morning, but then all afternoon is projects -- building programs that cheat at scrabble, access twitter, and draw colored grids.

I totally understand why experienced programmers teach the way they do -- it's what they'd want to know. But the focus should not be on the language, it should be on the skill of how to program regardless of language. And yes, that's really hard to teach.



sort by: page size:

Maybe Joel is right, maybe not. It might depend on the person. At 13 years old I tried learning C++, at 14 Java, at 16 C.

None of them stuck. Part of it was that the concepts were too difficult to understand. In which case Joel's list might help, as it is more about concepts than teaching programming. I think a bigger part of the problem was that it was too difficult to write anything useful in those languages. After a semester of C (Intro to Programming) I don't think I could write a single useful program. If it was a semester of Python I'm damn sure I could write useful code after it.

I wish a book like "Learn Python The Hard Way" existed back then. It would have been great to understand the basic concepts of programming, and see the code actually work. I remember a C class where the instructor was teaching about arrays. I don't think a single person in the class really understood what he was talking about. Compare that to Python lists and dictionaries, you can see them work, you understand what they do and how to use them immediately.

I'll take Joel's advice and read those books. But I'm not sure they are best way for people to start.


I feel like the average person already knows why. They know what they want and they just want the info on how to do it.

I don’t think the order of teaching presented in the article as bad actually is bad. What I think the problem I and others had is learning from a book to start with is really hard. Stuff doesn’t get retained well or make sense.

Programming finally clicked for me when I did the codeacademy class for JavaScript in 2012. What helped was it wasn’t just shoving walls or text at me. It was “here is a very tiny concept, go try it. Now here is another tiny concept, try this”


Hi Zed, I'm Al, the author of article. I'll admit the title is hyperbole. There are people who want to learn programming for the sake of programming, just like there are people who like learning math even though they don't see immediate practical applications.

I teach programming to a tiny class of 10-12 year olds on Saturday mornings, and have taught a couple one-off classes at Stanford's Splash program to a classes of a dozen students. I've found that having an end-goal in mind of what they will create is a much better hook than just explaining what for loops are (or the idiosyncrasies of the languages are, which Python & Ruby are good about keeping to a minimum.)

I don't think graphics and cute cartoons are needed to make programming engaging either. My book "Invent with Python" has games that use ascii text up until the last few chapters. There's a pretty low standard for games/programs that are cool enough to show off to other people, but nobody ever shows off code snippets.

I think the best thing about "Learn Python the Hard Way" over a book like O'Reilly's "Learning Python" is that your book cuts it down to the bare concepts: "Type this. This should appear. This is what is happening." That's great compared to most computer books where there are paragraphs upon paragraphs that could be whittled down to a single sentence or cut out entirely. "Learn Python the Hard Way" is barely over 200 pages. That's much more digestible than some 600 page tome.

I just think that many classes where the students aren't CS majors or necessarily dedicated to learning programming forget that it's not just the concepts that people want to learn but what they can make using those concepts. Small games and web apps are great for that. Like in Exercise 22 of your book says, "It’s important when you are doing a boring mindless memorization exercise like this to know why. It helps you focus on a goal and know the purpose of all your efforts."


This is one of a very very small number of programming-related articles I've ever been glad to read. Programming should be taught as an approach to problem-solving and structured logical thinking, not as an approach to a particular language.

If you can understand the core concepts of programming, the individual languages begin to matter a lot less. Python is great. Java is great. C++ is great. But they are just tools for solving classes of problems; if you don't understand how to, as the author says by way of example, deconstruct problems and understand the advantages and disadvantages of various solutions, then the software you write will never be as efficient or as elegant as it could be.

There is a compelling argument that, in the age of nearly limitless computing resources, it doesn't matter anyway. You will in all likelihood be a glue programmer: you'll rely on APIs and libraries, most of which have been written by someone else, and you will simply string them together by applying the functions that most obviously address whatever problem you're trying to solve. Who cares, really, if you're using Quicksort or heap sort, you're just going to call sort() on your array (or map, or key-value store, or whatever), and define a callback function that will evaluate any two given values in the array to be sorted, and that's it. Who cares if one requires a little more memory than the other, or a little more time to execute?

Just knock it out, and then get back to arguing online about the One True Language, or the One True Framework.

But, I've been programming for about 25 years now, in dozens of languages, and I can't help but feel that this language-specific approach to programming is producing anemic programmers.

Programming can be a craft; in can be done well, and elegantly. I can hack together a decent, reasonably strong wooden workbench for my shop, but it doesn't possess the same craftsmanship as a dedicated wood worker. It does the job, but it is ugly and uninspiring, and nobody admires it.

So, I guess I think that programming is similar, and moving from SICP to teaching Python or Java is just another representative sample of a disappointing sea change away from what I've come to know and love about programming.


I'm sure this isn't a new thought, and I will also admit I didn't finish the article so this may have been brought up, but I strongly consider 'teaching someone to program' and 'teaching someone to program using language X' completely different topics with very little common ground that must be taught using entirely different methods.

The first few paragraphs of the article point out problems with some tutorials/manuals for languages getting too deep too fast, but I like that feature now that I know (in some manner) how to program.


In my years of mentoring and tutoring, I've run into a number of students of programming (and, indeed, teachers) with the same problem.

Programming is about problem solving first, and teaching programming is about teaching someone to look at a problem analytically, and how to use an abstract flow of logic to solve a problem, and how to diagnose issues with your own logic when things go wrong. It's about critical thinking. It's about attention to detail.

It's about all of these things first, and about slapping keys second. But too many people see learning programming as learning the act of typing code, and focus too much on rote memorization of syntax, or teaching tools instead of thinking. Someone should come out of a course saying that they learned how to think in this new way as programmer, not that they learned a new programming language.


The problem here isn't that there's two perspectives (in fact, there are many more than 'two cultures of programming'), it is that you tried to teach people programming by bombarding them with 50 new tools (git, LaTEX, shells, piping, etc). Yes, those are extremely useful tools for engineers and serious programmers. However, they really aren't necessary or core to programming so much as they are core to engineering, sysadmin-ing, typesetting, etc. To be honest, using LaTEX for your resume is just a bad decision unless you happen to be very good at it and very incompetent with Word. Not only was the author teaching them irrelevant tools, he was stretching them to bizarre use-cases that conflict with how any productive human would approach an everyday task.

The essence of programming that needs to be taught is how to think about problems. Those are harder to grasp, but really they are just different ways of thinking. Programmatic thinking is clearly applicable to many things and enriches your life beyond just programming. Throwing tools at people is only important after you've learned how to reason about problems and begin tackling them.

Like 1t1337 said, HTML is a good place to start for the basic concept of writing plaintext to control the computer. Beyond that, Python is great for teaching programming as it has an easy, intuitive (relative) syntax and supports many concepts without being too demanding re: types.

Don't forget that people new to programming are really new to programming. Just the concepts of int, double, and string can be daunting because people just don't think that way.

The biggest challenge I've seen in teaching/coaching new programmers is the concept of assignment vs. equality and how that interacts with variables. Even very smart (young) math majors can get very caught up on the following:

number = 5

number = 6

In math (as everyday people understand it), that would clearly be incorrect. I suspect for math-oriented students, functional languages would be a better place to start. I personally learned about programming variables before algebra variables, so my experience was the opposite.

I truly believe an excellent introduction to programming course really doesn't even require a computer to be involved, although of course when used correctly computers and live demos add a lot of value. Rather, an excellent course will teach the concepts (variable, typing, what memory is, functions, recursion, iteration, and turning real-world problems into computable problems, and so on) which are completely tool agnostic.


Thanks for the book recommendations - I will definitely look into getting them.

> Personally, I've seen very little benefits from this new method of learning.

What I meant by this statement is that I saw very little benefits from this method in comparison to the traditional method. While it is not entirely impossible to go back and relearn the basics the right way assuming you've already taught them to yourself, it is most definitely a waste of time and something that should be avoided. As I said before, I think the first introduction to programming is the most important part of the learning experience. If the formal introduction is done well, you should be able to go off into the real world with what you learned and discover new languages by yourself. However, the lack of this introduction makes kids go off and teach it to themselves via the Internet. The solution? Schools should offer the basics of programming at an early age (10-11 years old). From there, those who want to pursue programming in greater depth can seek more instruction or do the learning by themselves.

> I learned well before the internet, and let me tell you that it's easier and better with it than without.

While I'm sure it's easier with the Internet, it is not necessarily any better. The easier it is, the less time you'll spend learning it.


I agree.

A fundamental problem with how we teach programming is that we focus on writing, instead of reading, software. To borrow terminology from the language arts; we don't focus enough on reading comprehension.


I've been really involved in teaching people with non-traditional backgrounds (e.g. no cs degree) to program lately, and this has been my biggest struggle. There are people who are working in the field as a web dev and have been for years and can't do simple stuff like iterate. They have no understanding of what the stuff they're actually doing means or does. It's just copy and pasting snippets they see online and fiddling with it til it works.

I've taken to offering three pieces of advice to these people:

1) Go through the basic language tutorial of whatever language you use (e.g. how to declare variable, conditionals, loops)

2) Go read through the essentials guide to your languages (will be slightly higher level stuff)

3) Go read the sections on Data Structures, Concepts and Algorithms and Knowledge Base in Cracking The Coding Interview skipping the problems that aren't answered in chapter. Why? Because it's a solid primer for CS Concepts that people just don't pick up unless they have to, and most importantly short enough (< 100 pages) people will actually go through it. Large CS books with the dense writing intimidate people and so they never follow through.

I've had a lot of success with this method. It's not a formal cs education by any means but I've found it's enough to get people past the constant beginner part.


I think there is a fundamental problem that isn't addressed in teaching people how to code. The problem is that every single course/book talks about the tools of the trade but not the art. Most books start with:

  - Variables
  - Loops
  - Functions
... etc.

In doing so, it is simply overloading the student with syntax memorization and conceptual overload. It bothers me so much that very few books (Kernighan) talk about WHY. WHY. WHY is a variable needed? WHY is a function needed? WHY do we use OOP? Every single book out there jumps straight into explaining objects, how to create them, constructors, blah blah blah. No one fricking talks about what's the point of all this?

Teaching syntax is like muscle memory for learning Guitar. It is trivial and simply takes time. Syntax - everyone can learn and it is only one part of learning how to code. Concepts are explained on their own without building upon it. The famous book for Python (Learn Python the Hard Way) explains Loops in its own chapter and provides examples. But, they never build up on the idea. There should never be a separate chapter for variables, loops, functions, etc. Chapters should be:

  Chapter 1. Setting up the problem (Goals)
  Chapter 2. Defining Inputs/Ouputs (API)
  Chapter 3. Automating something (Variables, loops)
  Chapter 4. Abstraction of something (Functions)
  Chapter 5. More automation! (Combing all)
  Chapter 6. Splitting code into multiple modules (Growing the project)
  Chapter 7. Objects (New type of abstraction, OOP)
  Chapter 8. Reusability of Classes (Inheritance)
  Chapter 9. Safety/Security (Encapsulation, tie it back to Chapter 2.)
  etc...
Best coding resource I've found is things like:

  NAND to Tetris [1]
  Handmade Hero [2]
  The Nature of Code [3]
  Harvard CS50 [4]
  How to Design Programs [5] (thx minikomi)
This is learning how to produce music. Not learning the F chord. Teaching how to code is fundamentally broken and very few books/courses do it well.

References:

[1] http://nand2tetris.org/ [2] https://handmadehero.org/ [3] http://natureofcode.com/ [4] https://cs50.harvard.edu/ [5] http://www.htdp.org/


I agree — I like to learn new programming languages from books precisely because I have to type in any tutorial material by hand.

Thanks for starting this — all this talk of closed systems keeping kids from playing with programming, and whether video games/programming was art or not was distressing.


I think it should be taught in school, but it shouldn't be forced on students; sorry, but some of your programming books are 600 pages of absolute boredom. I've wondered for years why computer programming books are so terribly written. It's not a crime to include diagrams, and highlight the really important concepts. I would like to see a Hacakathon for writers of programming books. The shortest book that got across the material would Win!

I think programming is more analogous to learning a new language.

I think your analogy is spot on, and yet reinforces the OP's point - one of the best ways to learn a new language is to read a lot of good writing in that language - you absorb idioms, subtle points of grammar, and vocabulary, all of which would be a struggle if you just try to focus on the basics or use a grammar textbook to help. Immersion in the right environment is by far the best way to learn.

The current situation with most people programming is that they spend years looking at code written by other beginners (stackoverflow, tutorial articles), and very little time studying real production code written by people who have been doing it for a long time. That is as the OP points out a huge mistake and one it takes many people decades to remedy if they ever do. It's like trying to learn a language by putting 30 beginners in a room with a textbook and making them speak to each other.

I'd honestly recommend absolute beginners to spend at least some time reading simple code by someone they admire, if only to demistify the process, and make them realise it is not as complex as they fear. Beginners almost never do this though.


such great points! I've always found the tooling lacking for teaching beginners programming, sure there are good languages, but as he points out the environment is also vital. I find it very hard to introduce programming to my social science friends (who would actually benefit greatly from knowing how to manipulate data), most of those who have extra time go to learn excel or spss.

The problem is when you sit down to teach the beginner, all the boilerplate clutter forces you to either A) teach them the magic incantation to be unquestionably written before they start writing any code, or B) you explain everything before getting into any real programming.

Both suck. In the first case, students are torn away from the mode of thinking that programming thrives in: that everything is made up of simple, understandable pieces, that can be built up into complex solutions. It ends up serving as a trap for the very kind of inquisitive student that is equipped to succeed in programming. In the second case, everyone's bored to tears, and you can be assured that your entire class will be hopelessly lost before they write their first line of code. It's a bad time all around.

Basically, programming wants to be built up with the following concepts, in order:

1. Algorithmic Thinking (solutions can be representing as a series of simple steps)

2. Structured Syntax (these steps can be represented as structured text)

3. Symbolic Reasoning (types, variables, arrays)

4. Control Flow (loops, conditionals)

5. Functions

6. Higher Structures (classes, objects, etc)

Python, IMO, is pretty good pedagogical tool in this regard

    print("Hello World")
"We want our computer to display to us (or 'print' in software terms) the phrase 'Hello World'. Python provides us with a built-in way to do so: the "print" function. In the majority of programming languages, we express a call to a function as a command, followed by its inputs (or 'arguments') contained within parentheses. As our one and only argument, we provide what we want printed, in this case the text "Hello World". By wrapping this text in quotes, we can tell the language that we intend this text to be interpreted as a chunk of literal text, called a 'String' rather than as a variable or other symbol for the language."

In contrast, explaining everything going on in the equivalent Java

    public class MyFirstClass {
        public static void main(String[] args){
            System.out.println("Hello World");
        }
    }
would take more text than I'm willing to hammer into a HN comment, but to be explained to a complete beginner would likely involve skipping, but promising to explain later: classes, functions, "public", "static", "void", command line arguments, and the uniquely weird "System.out", followed by a similar explanation to the Python example, with the added "we end each step with a semicolon".

"Don't teach coding until you read this book" by Lindsey D. Handley.

I've learned so many concepts since I started programming that I'm always forgetting how alien it seems for other people. This book introduces some nice explanations why we do have programming languages, the mechanism of learning and why we do program. My take from the book is to not teach a language, but how to transform your thoughts to something that the computer can accept.


"Programming is learned by writing programs"

- Brain Kernighan

And that is what anyone who goes through K&R will do: Reading and writing lots of real programs. A simple program is worth a thousand words!

Which unfortunately the majority of technical books just can't get right. Explain the concepts in 5 full dull pages, and then at the end "Hey, checkout this little snippet of code, which by the way does nothing really interesting, but is here to illustrate what the author was talking about :)"


You can teach the principles of computer science without forcing some obscure and difficult language on new programmers. Learning programming is hard enough, no need to add more bullshit on top of it!
next

Legal | privacy