Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have to admit that after reading that over, I find myself wondering why we teach students C as their first language...


I agree; we should start with assembly language. Students will never understand why these are dumb things to do until they can visualize the assembly code they get translated into.


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.


A 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.)


I 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.


The 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).


My school has a CS 100 course that everyone has to take, but in the second half of the semester teams have to use PIC Assembly to program a microcontroller on an RC car/truck (that can go up to 20mph) to navigate an obstacle course with its four IR sensors. There's also a concurrent CS 120 class that is basically a standard C course.

Unfortunately the Assembly scares off a lot of people from looking at the Computer Engineering degree, as does the very minimal breadboard wiring they have to do, since they assume that's all CE students do. It's a tradeoff of getting more people for a degree program vs. starting off low level. Why do you think so many schools teach Java or C# and never touch an assembly? If your school has to justify keeping a program alive, they're going to have to make it more appealing to a larger audience which unfortunately means creating an easier program or first few semesters, and targeting big-industry popular languages so you can keep subtly hinting at potential good jobs on graduation.


That sounds like something http://tenaciousc.com/ can help with.


What do you think of Randall Hyde's HLA?


Better than java, what my uni teaches CS students. Other people get to choose between c++ and fortran.


Few schools teach C at all anymore, let alone as a first language.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: