Live data from Hacker News

Why Learn to Program in C?

philipbuuck.com

11–20 of 123 posts

Re: Why Learn to Program in C?

#11
I find it odd that anyone would question the value of learning C. I find the negative attitudes toward C to be very odd in general. Now, it is clear to me that I am in the minority, but I can't understand why people would be doing serious work in an interpreted language. I detest garbage collection as I have no control over it. I am sure I could write statements like this all day.

Don't get me wrong: I use perl when it makes sense; I use Java when it makes sense. I quite like playing with new languages and seeing what I can do with them. There are many languages that are safer than C or easier to do particular tasks than with C, but I am very rarely happy with the trade offs. When I am trying to do serious work that is meant to stand the test of time, I'll use C.

Re: Why Learn to Program in C?

#13
C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it.

Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about the stdio functions 'not working right' and asking how to do menial things like collect keypresses.

C works well as a first language if you teach it like assembly (use of which as a teaching language is another debate): flip some bits and do some loops. But not for collecting user input/output. Half of your students are going to get stuck trying to collect a list of names from the user, before they even get a chance to get stuck trying to sort the list.

Re: Why Learn to Program in C?

#14
I enrolled in my university the same year they switched from teaching C to teaching Java in the CS curriculum. As someone that learned C++ in high school I was less than enthusiastic about this change.

But what surprised me more was that the courses became more institutionalized. Professors were bettering you for a cushy career as an employee at a bank or large corporation instead of showing you how to use the computer to solve a dizzying amount of technical, social and and financial problems. I could understand a technical college emphasizing a safe, risk-free entry into a nice career but I expected better from a university.

Re: Why Learn to Program in C?

#15
post #5
post #2

I'm surprised that people have managed to get through a CS program without learning C (or, at least, C++)! It seems to me that programming should be taught simultaneously in Haskell (or Lisp?) and C. - C teaches you how computers work. - Haskell teaches you how programming logic works.

C doesn't really tell you how computers work, a healthy dose of Hennessy's book and an accompanying lecture works much better than learning C. But C has immense cultural value. Lots and lots of extant source code, important source code: Linux. The BSDs. PostgreSQL, SQLite, whatever. C is the lingua franca. "Everybody" speaks at least a little C, so it can be used as pseudocode notation (without learning some specific…

> C has immense cultural value. Lots and lots of extant source code, important source code

Yes, exactly! In my opinion, C for a programmer or computer scientist is like Latin for a medieval scholar. You don’t need to speak it fluently, but it’s good to know enough to read other people’s works and understand how concepts are expressed.

In practical terms, I think that almost any programmer can benefit from reading K&R and doing the exercises in it, even if they never go on to write “real” programs in C. The book is very short and readable, and finishing it is a much tinier task than learning the standard libraries and toolchain options and best practices and all the other stuff you need to be productive writing production-quality code.

Re: Why Learn to Program in C?

#16
Whenever I don't quite understand how something works in a programming language, I try to imagine how I might implement it in C. Or I look up the implementation, or write it myself. This helps me understand from 'first principles' or near enough.

Re: Why Learn to Program in C?

#17
I think it doesn't really matter what people learn as a first programming language. Eventually, any serious programmer will become familiar with the most common languages and paradigms, C being one of them. It may not be the best choice for beginners, but it's valid nonetheless. People can have fun learning algorithms without worrying too much about pointers and complicated type declarations. It's not like it's going to mess up their brain and prevent them from learning higher-level languages later on.

Re: Why Learn to Program in C?

#18

Until not too long ago, De Anza College still taught C as an introductory programming language (I think because some recently retired instructors wrote a textbook on it). Even now, from what I've seen of the syllabi online, their C++ course that replaced it is still mostly C with some sprinkling of classes added on. I thought it was a horrible idea, and I had a pretty miserable experience at De Anza. If you're just s…

My experience is the reverse. I think that beginning with C gives you the necessary knowledge of the inner workings of programs and systems that is required if you want to end up with a degree in CS/CE/similar. I've seen too many programmers that started with Java or Python and then didn't know what exactly is memory, what is "allocation" or similar concepts that are required if you want to understand what's going on with your programs.

Re: Why Learn to Program in C?

#19

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

Overcoming goofy shit and gotchas is part of any programming system.

Re: Why Learn to Program in C?

#20

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

Overcoming goofy shit and gotchas is part of any programming system.

Yeah, but why start with an exceedingly painful one except to needlessly inflict pain and suffering on students. Better to lay the groundwork with a friendlier language, learn the basics, and then move on to the more complicated gottchas (at least in my amateur opinion).
Post reply on HN