Hacker News new | ask | show | jobs
by dasimon 3164 days ago
While well-constructed C programs are as minimal and straightforward as programs come, the language is certainly full of pitfalls (just look at the underhanded C contest). Keep in mind that most computer science students in their first intro course have not yet developed the mental models that experienced programmers take for granted. Students will try doing all sorts of things which don't make much sense, and C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost.

I agree that C0 on its own is overly simplistic, but the way it is used at CMU is as 'C with training wheels' - strict type checking, no potentially-unsafe pointers to the stack, dynamic array bounds checking, etc. Then, two thirds into the semester, students transition to real C, and learn how to correctly manage those potential pitfalls.

This is how students at CMU have been learning C since 2010, and graduates don't seem to be any worse off for it.

1 comments

>... have been learning C since 2010, and graduates don't seem to be any worse off for it.

[Citation needed]

> C is overly permissive of these things unless you introduce additional tooling, e.g. valgrind, which can become very overwhelming for intro-to-CS students who are still feeling lost.

Sure, but isn't the the POINT of college? To push you into unfamiliar territory? To force you out of your comfort zone, and then hand you the tools to learn something new?

It may just be my arrogence speaking, having already taught myself C. But I taught myself C, when I had to fix a bug, I taught myself asan, and valgrind. None of that was very overwhelming. Complicated, very. Confusing, occasionally. But Once I learned them, they became easy, and intuitive, and helpful.

I think the problem I have with your argument, is; when you apply it to math, the argument becomes painful.

You don't want to learn algebra, it' too complicated; lets learn this subset of algebra, without irrational or imaginary numbers.

I don't get the analogy. Every algebra course goes over the material in order of complexity. You don't go over real analysis until the students have mastered the basics.

The problem with c is that the advanced things get in the way of the basics. You get students asking why their if statements didn't work and to answer you need to teach them GDB and valgrind and different compiler flags and how the stack works. This is a recipe for students that don't end up learning either thing. And it slows everything down so in the end of the year you can't cover everything properly and end up with mediocre C programmers you would never trust near a real C codebase

---

Another thing to remember is that we should be very careful about that drill sergeant mentality that intro to CS should be hard and painful. This advantages students that had the opportunity to program before university and often ends up turning away women and other minorities from the field

You actually managed to change my mind and I now agree C isn't a good first language. Mixing C with data structures / algorithms in the very first programming course is probably not a good idea for the reasons you mention.

Although I am kind of miffed by the last sentence, I admit I'm one of the people who programmed WAY before college but in my experience most CS majors who didn't simply didn't choose to do so, as opposed to having lacked the opportunity to do so; you're dismissing the thousands of hours spent coding as a child (more than most CS majors invest in programming during college...) without the internet or anyone to teach me anything as "opportunity"

Why stop expectations for self-study at the programming part of the degree program? Math textbooks are available from any library. Rather than continuing mathematics from where high school left off, we could skip past the beginner stuff. The students who really care about computer science will have already learned the basics of discrete math, linear algebra and theory of computation.
Where did you get the idea that I said we should skip anything or that there should be "expectations" for self-study?

I have an issue with someone dismissing thousands of hours of invested effort as "having an opportunity". And the same is of course true for someone who went to the library and learned first year math.

My apologies. I misunderstood you.
I didn't "choose" to program before college because I didn't decide to major in CS until I applied to college. And I suspect that unless "WAY" means high-school, you programmed before college because of your parents.
Nah my parents are barely computer-literate even today. I found QBASIC that came with DOS when I was like 10 which had the source code for 2 simple games and decided I wanted to learn how to make stuff like that. A few years later I read about Linux somewhere and found someone who baked and mailed me Slackware on CDs for a small fee so then I had gcc
If you're learning C, as a basic intro into programming concepts... you're gonna have a bad time. Try python. However, if you're learning C because you'll need it later for [any reason]. You should learn gdb, and valgrind (asan has replaced valgrind for most of my usage, valgrind is often my last ditch now) on day one... I guess I mean to say, if you have better things to teach than gdb, then C isn't the language you should be using.

I would gladly hand over some C code to someone who's really interested in programming, but has only ever written python. I can't say the same about someone who's only known Java. So experience with C, isn't really a good bar to judge programmers by, not by itself anyways. You don't need to know how the stack works for most issues in C, and after you can make you stuff compile, without asking questions, is the time to learn about compiler flags.

So if that's the only argument for using an obscure/broken version of C, then it's a crap argument. If you've been doing CTF for years, the school needs to offer you CBE, not force you into a class where you'll only break the curve, and still be bored.

Also, I'd gladly turn away women and minorities both. If you're handed a problem you know has a solution, and you give up because it's hard. Your skin color or sex is irrelevant, if you're the type that gives up when it's hard; you're worthless as a programmer. (But that might just be my obsessive need to solve any problem I don't understand, so I might not be the best judge)

>>... have been learning C since 2010, and graduates don't seem to be any worse off for it.

>[Citation needed]

https://www.cmu.edu/career/about-us/salaries_and_destination...

I would agree the point of college is to push you into unfamiliar territory.

But, that's why we have dedicated classes that challenge you. This language is meant for a course to try to bring everyone to the same level. Some students enter the course having done CTF's since middle school and others just took the AP exam. C0 is used only for one course, and the course that follows it uses C in depth.

My reply here https://news.ycombinator.com/item?id=15505649 also kinda responds to you, and rather than rehash... I'm just gonna link you.