Live data from Hacker News

Why I Chose to Learn C

viget.com

11–20 of 78 posts

Re: Why I Chose to Learn C

#11
post #5

Well now I feel old. When I was in high school, CS was a required course for graduation and it was taught in C++ (that being the pedagogical language of the APCS exam). It wasn't even that long ago (late 1990's).

> It wasn't even that long ago (late 1990's).

Well if you consider that the computer is still less than a century old, 15 years is a long time in the computer world.

Re: Why I Chose to Learn C

#12
Quote below from Learning C the Hard Way

"For Windows users I'll show you how to get a basic Ubuntu Linux system up and running in a virtual machine so that you can still do all of my exercises, but avoid all the painful Windows installation problems."

A bootable Ubuntu USB stick with persistent storage might be easier to get started with? Can be created from a Live CD.

Interesting idea.

Re: Why I Chose to Learn C

#13

I know learning C might seem a bit of a waste of time, but given Obj-C, C++, Python and Ruby can leverage it for performance it's not a bad thing to learn.

Who on earth thinks it's a waste of time? I think it's essential for every programmer. I certainly wouldn't consider someone fluent in the language (say, Python) until they understand how it is implemented.

Also, C++ is arguably faster than C (for the effort put in) and Objective C is a strict superset. Saying either calls into C for performance reasons is pretty silly and doesn't make any sense.

Re: Why I Chose to Learn C

#14
post #8

Earlier quoted context omitted.

From my experience if you are familiar with both C and C++, you do not end up writing C++ code that is completely obnoxious.

Indeed, given the option, you may not write C++ code at all!

I am a diehard fan of C, and even I think that C++ is preferable past a certain size of program. Classes and templates are far too powerful to not use; just consider things like `scoped_ptr`. Just because C++ has nasty parts doesn't mean you have to use them, in my experience most of my worst experiences with C++ come from reading other peoples' code (Boost.Spirit, I'm looking at you).

Re: Why I Chose to Learn C

#15
post #8

Earlier quoted context omitted.

From my experience if you are familiar with both C and C++, you do not end up writing C++ code that is completely obnoxious.

Indeed, given the option, you may not write C++ code at all!

I used to be super into using Boost, etc. I found that it became really unmaintainable (though compiler errors might be better now). My personal style is basically C with STL containers.

Re: Why I Chose to Learn C

#16
post #5

Well now I feel old. When I was in high school, CS was a required course for graduation and it was taught in C++ (that being the pedagogical language of the APCS exam). It wasn't even that long ago (late 1990's).

I don't know when it switched, but my APCS exam in 2008 was Java. The sample program we had to learn for the exam was also in Java, so I assume that was the default language.

Re: Why I Chose to Learn C

#17
post #5

Well now I feel old. When I was in high school, CS was a required course for graduation and it was taught in C++ (that being the pedagogical language of the APCS exam). It wasn't even that long ago (late 1990's).

Here's another surprising (but fully understandable) perspective given in the OP:

"Function pointers — It was interesting to me to see that such a low-level language contained functional programming concepts."

If you started from assembly and worked up, this looks very different, because at that very low level, functions and data look the same too. (Just like Lisp).

Re: Why I Chose to Learn C

#18
post #14

Earlier quoted context omitted.

Indeed, given the option, you may not write C++ code at all!

I am a diehard fan of C, and even I think that C++ is preferable past a certain size of program. Classes and templates are far too powerful to not use; just consider things like `scoped_ptr`. Just because C++ has nasty parts doesn't mean you have to use them, in my experience most of my worst experiences with C++ come from reading other peoples' code (Boost.Spirit, I'm looking at you).

I'm going to be a contrarian, and say that I've just never found a program that was more readable with classes. Classes tend to rip up your algorithms to shreds and spread them over dozens of different files, which is really painful.

I've been reading through the code in libfirm lately and it's incredibly refreshing. A pass is usually in a single file (how novel!) instead of being scattered around because of the visitor pattern.

Re: Why I Chose to Learn C

#19
This entire post just seems like mental masturbation. Questions like this pop up on Stack Overflow all the time ("Should I learn C?") and there is a very solid consensus in professional software development circles: don't learn C unless you have to.

Are you writing performance-critical functions for a game? Are you writing an operating system? Are you debugging legacy code? Maybe you have to create a custom allocator for an embedded system. Sure, use C.

But the knowledge gained by learning C will almost never (ever) help you in "real life" development situations any more than learning assembly will (learning assembly is probably more useful, actually). If you're already familiar with C-style syntax (which like 90% of languages out there use), delving into C will teach you nothing about "code organization" like the author claims -- that's actually kind of laughable since C code is notoriously difficult to read.

Not only that, but several "features" mentioned in the blog are known caveats of the language: varargs are bad (http://www.atalasoft.com/cs/blogs/stevehawley/archive/2006/0...), function pointers are difficult to work with and error prone, memory allocation is interesting to learn about in CS 101, but no real programmer wants to deal with it in most production code (that's why we have languages like C# and Java).

If you don't know C, you're not missing much. And unless you work in academia or very specific engineering fields, you don't need to know C. Want a challenge? Go rock climbing.

Edit: almost forgot about various C/C++ preprocessor nightmares (see double evaluation, etc): http://www.nongnu.org/c-prog-book/online/x843.html

Re: Why I Chose to Learn C

#20
post #16
post #5

Well now I feel old. When I was in high school, CS was a required course for graduation and it was taught in C++ (that being the pedagogical language of the APCS exam). It wasn't even that long ago (late 1990's).

I don't know when it switched, but my APCS exam in 2008 was Java. The sample program we had to learn for the exam was also in Java, so I assume that was the default language.

Wikipedia says 2003.
Post reply on HN