Live data from Hacker News

Why Learn to Program in C?

philipbuuck.com

51–60 of 123 posts

Re: Why Learn to Program in C?

#51
post #28
post #20

Earlier quoted context omitted.

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

What language would you suggest is friendlier, and less rife with gotchas? I find the rules of C fairly reasonable, at least on the surface.

In no particular order any of the following as an introductory language.

Ruby -- puts "Hello World"

Python -- print "Hello World"

Lua -- print("Hello World")

Personally I wish every programmer would eventually learn C. Getting down to that low level and really understanding how things work is important, but if it is the first language I think we would end up with a whole lot less programmers as many would give up early.

Re: Why Learn to Program in C?

#52
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.

Probably because some modern CS programs use Python for their intro courses and Java for the advanced ones.

That's about right, I think. Mine started with Java (because the school was heavily supported by Sun). Some more advanced courses went into other styles of programming (Prolog for logic programming, Lisp for functional, ARM+MIPS assembly for low-level understanding). The C++ courses were purely electives and were taught in a "C with classes" style when I took them around 2005.

Of course the compilers, networking, and robotics classes all assumed fluency in C, and of those, the series on compilers was required, so it was impossible to escape learning at least some enough C to pass those classes.

Re: Why Learn to Program in C?

#54
One of the best academic decisions I've made as a student was to take a course on Operation Systems in C. I did take a beginners course in C previously so it was an intermediate class.

Nothing compares to spending hours and hours grinding through thousands of lines of C and building your own passable OS from a skeleton kernel. It was the hardest course I've ever taken in college and it was my favorite.

I can honestly say I'm a better programmer and engineer after that experience and would recommend anyone to take a course in OS (hopefully in C), and you'll know what I mean.

Re: Why Learn to Program in C?

#55
Why do so many people seem to think the author is advocating that you learn C as a first language? Did you read the article? He explicitly says the opposite:

Does someone brand new to programming, who’s excited about making changes in the HTML on a page or setting up a blog to later customize, or just wants a slow introduction to more complex topics, really need to worry about cache coherency? Or threading? Clearly that’s a problem for down the road. Maybe that’s a road that some developers will never need to walk down at all, depending on their focus.

His position is that, while C may not be the best language for everyone coming into programming it is beneficial to learn it eventually because it allow you to peel back the layers of abstraction underneath all of the goodies in your high-level language. This allows you to better understand and reason about even your higher-level code and opens the door to fixing and understanding a lot of things that would have constrained you previously.

I completely, whole-heartedly agree. We don't always need to be able to plumb the depths of our abstraction stack. I don't believe it is necessary for a beginner. But having the ability to go up or down in the stack is extremely valuable. C is worth learning.

Re: Why Learn to Program in C?

#56

Earlier quoted context omitted.

> 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. You have no control over C's register allocator. (Well, very little, `register` doesn't mean much.) Assuming you use it, you have no control over how the standard library's malloc() and free() work. malloc() could be best-fit, first-fit, something else entirely, who knows.…

Yes, but interpreted is slow, and garbage collection causes pauses at essentially random times. These things are fine for one off sorts of problems where it doesn't matter much if it takes a little longer. If you are writing an application that is meant to be run thousands or millions of times, I start to wonder why people don't care more about these trade-offs (the answer is, of course, they do . . . if they are, fo…

The main language at Amazon is Java. Lots of Java code is being run millions and millions of times there. Java isn't as slow as you think it is.

Re: Why Learn to Program in C?

#57
post #50
post #5

Earlier quoted context omitted.

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…

> a healthy dose of Hennessy's book Most any CS book seems to have been written in C, Java, C++ and lately, Python. Are there books on computer architecture, algorithms, compilers, whatever written in Scheme?

I have no idea what you're talking about.

Are you interested in finding such a book? Do you try to refute any of my points? If so, which one?

Re: Why Learn to Program in C?

#58
You can write very C-like code inside of Java or C++. Just write one class and stuff all the variables and subroutine methods inside it. Many years ago I had to fix some bugs in such "converted" code. The programmer just wrapped old C code into one humungous dummy class.

Re: Why Learn to Program in C?

#59
post #49

Earlier quoted context omitted.

#include int main(void) { (* * * * * * * * * * * * * * * * * * * * printf)("C is awesome\n"); return 0; }

In C99: #include int main(void) { (* * & * * * * * & * * * * * * * * * * * * * printf)(&1["C is awesome\n"]-3/2); }

I proudly display my "Best Abuse of the Rules" category win of the Int'l Obfuscated C Coding Contest on my resume.

Re: Why Learn to Program in C?

#60

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…

My first language was C and I loved it. Maybe it takes a certain type of mindset and tenaciousness (madness?) that will put up with the gotchas. It was exactly those gotchas that got me hooked though. It was similar gotchas that made me love Linux the terminal, vi etc ... The argument that one "should study other languages before they're fit to learn C" is terrible IMO and somewhat condescending. It's like saying one…

It sounds to me like you haven't spent much time trying to teach a class to program. Most introductory courses these days focus on trying to teach students to understand how to solve problems (usually to some degree agnostic of language) and then how to turn their solution into code. The largest mental leap seems to be with the former, and using C as a starting language makes the latter unnecessarily difficult compared to, say, python (which is why it's gaining such popularity among intro. courses

I can understand if one is a) very motivated and b) has the right mindset to properly frame their ideas at the low level c operates at, C could be a good starting language. But this is not the case for many beginners.

Post reply on HN