3 ms·
C, being the glorified assembly language that it is, would be an excellent intro to programming if we didn't insist on teaching it as a high-level language. A
by Animus7 16y ago
C, being the glorified assembly language that it is, would be an excellent intro to programming if we didn't insist on teaching it as a high-level language.
A beginner's course in C will tell you "uninitialized variables are bad", and "don't use pointers after free", but it won't explain the stack frames or heaps that underpin so much of our computing.
I happen to think that having C blow up in your face (and fixing it) is one of the best ways to learn the subtleties of programming.
- pjscott 16y agoA lot of students would not respond well to that kind of approach. It's too much at once; you're trying to teach them to think like an idiot savant computer, and teach them common patterns for translating their thoughts into code, and hit them with a bunch of low-level details about pointers and stacks and instructions? Some exceptional students would thrive. Others would dig in and do sort of okay, passing the test and then maybe learning it properly later on. Many -- maybe most -- would just get discouraged and switch majors to something where they'll never have to deal with null pointers or case fall-through or (god help us) malloc alignment along dword boundaries. If you want to do it that way, you've got to take one thing at a time. Colin's idea of starting with assembly language isn't nearly as crazy as it sounds; I know several people who learned that way. Personally, I would start with very simple, linear programs in a high-level language like Python. Let them get a feel for it, and fiddle around. Then gradually start introducing more and more difficult concepts, like if statements, or looping, and how to use these strange new wonders. Later -- much later -- you'll be able to talk about the low-level details exposed by a language like C. If you try it too early, you'll either get head-explosions or blank stares. (Incidentally, head explosions are preferable. One of the greatest horrors of teaching is that there will always be students who stare at you with looks of blank incomprehension, and it always might be your fault.)
- h0bbit 16y agoI mostly agree with this answer. However, in my experience, starting with a high-level language (like python) is a double-edged sword. a) It fails to get people interested in low-level things like call stacks and frames. Someone once told me, "My language frees me up to think about the really important things: like solving the problem at hand. I don't have to worry about things like the stack and where my memory is going or coming from." Perfectly valid point maybe, but I didn't learn about these things because I needed to, I did it because I was interested and curious. I think C and it's pointers played a big role in helping me "get interested". b) People take the _awesome_ things in high-level languages for granted. When I first moved into python from C, functions as first class entities blew me away! Lisp macros were like learning to do magic. People who have only used a high-level language don't give these features the credit they deserve. (Alright, this might just be a pet peeve of mine...) I think that C _should_ be taught to students, at a slower pace and in more detail than it was taught to us. And if it occasionally blows up in their face, I think they'll be better off for it.
- jules 16y agoThe abstraction of C over assembly is just high enough to make it completely unclear to students how a machine could execute that. Teaching assembly is much more valuable form a CS perspective (though perhaps not from a Java/C++ school perspective).