Live data from Hacker News

Ask HN: Should I learn C?

news.ycombinator.com

1–10 of 98 posts

Ask HN: Should I learn C?

#1
I'm a recent high school grad going into college as a comp sci major. I have 2 years experience in Python and JS.

Would it be worth my time to learn C (C++ possibly?)? (Or maybe you have another language that would be more profitable now.) I'm aware I will have to learn at least C for college, but is it something I should learn now?

I'm looking for your opinion because a lot of you have either gone through a comp sci degree or have done some programming in C.

Thanks HN!

Re: Ask HN: Should I learn C?

#2
Yes, you should learn C. And enough assembly language to understand aspects of how C works, like what a "stack frame" is.

Now is a great time to start. Go find K&R, fire up Linux and write and compile "hello, world". Then keep going until you experience your first segmentation fault. ;)

(Do not study C++ at this point. Study C. These things turn out to be very very different.)

Re: Ask HN: Should I learn C?

#3
Even though C is used more and more rarely outside of systems programming, I definitely recommend learning it. Learning about pointer arithmetic, memory management, etc... will give you a depth of understanding in other programming languages that other students will be sorely lacking the first few years of college. Other than a little OS-hacking on the side, I've never used it for a project, but understanding how C works has helped me debug much more effectively in several other languages.

Re: Ask HN: Should I learn C?

#4

Yes, you should learn C. And enough assembly language to understand aspects of how C works, like what a "stack frame" is. Now is a great time to start. Go find K&R, fire up Linux and write and compile "hello, world". Then keep going until you experience your first segmentation fault. ;) (Do not study C++ at this point. Study C. These things turn out to be very very different.)

> Then keep going until you experience your first segmentation fault.

Or your first cryptic compiler error. I'm pretty sure mine was "numeric constant contains digits beyond the radix".

Re: Ask HN: Should I learn C?

#5

Even though C is used more and more rarely outside of systems programming, I definitely recommend learning it. Learning about pointer arithmetic, memory management, etc... will give you a depth of understanding in other programming languages that other students will be sorely lacking the first few years of college. Other than a little OS-hacking on the side, I've never used it for a project, but understanding how C w…

It's also very useful for extending other languages by binding a library.

Re: Ask HN: Should I learn C?

#6
I, like many here, would strongly recommend learning C. I don't know if I'd call it "profitable" to do so at the moment, assuming you mean profitable in the money sense.

C is a good language to learn, and a lot of interesting, well-paying jobs use C, and a lot of interesting open-source projects use C -- but if you just want to make steady cash, you can do so much easier with Java or PHP.

That said, if you go about your programming self-education correctly, you won't have a problem using Java or PHP (well, you won't have a problem in the sense that it won't be difficult for you to design programs in those languages).

It's good to have a handle on how the architecture of your machine works. C gets you much closer to that, and you will learn about a lot of things that are hidden from you in HLLs like Python, but that are still relevant to non-trivial programs.

So yeah. Learn C if you're passionate about comp-sci, or software engineering. If you're learning programming only for a career, it may not be as beneficial for you. Learning C before college is definitely a good thing.

Also, if you learn C, the last chapter of SICP is much easier to do, and you should go through SICP at some point ;)

Don't touch C++ until you need to touch C++. You'll know when that time is, if ever.

Re: Ask HN: Should I learn C?

#7
A lot of people take the route of not learning C. If you do web development and your team finds something hard or impossible to do, watch their reaction when you say "I'll just write a C extension."

The stack-frame comment is spot-freaking-on. Knowing this level of detail will make you a way better programmer in every other language because you won't make stupid memory hogging decisions or mistakes. You also understand the complexity of doing things one way and the tradeoffs of another.

I best learnt C by re-writing large portions of the Pintos operating system. It's an academic OS and will be interesting to look at the source. Systems programming is where C packs the most punch, but all of those concepts can be re-applied in user land for some amazing effects.

Re: Ask HN: Should I learn C?

#8
post #6

I, like many here, would strongly recommend learning C. I don't know if I'd call it "profitable" to do so at the moment, assuming you mean profitable in the money sense. C is a good language to learn, and a lot of interesting, well-paying jobs use C, and a lot of interesting open-source projects use C -- but if you just want to make steady cash, you can do so much easier with Java or PHP. That said, if you go about y…

I don't know if I'd call it "profitable" to do so at the moment, assuming you mean profitable in the money sense.

I was meaning the in overall sense; "profitable" as in good for me. Sorry for the misunderstanding.

Re: Ask HN: Should I learn C?

#10
It's better if you dont ask!

I don't believe that Linus ever asked (someone else) if he should learn C. Or that Damien Katz (couchdb creator) ever asked if he should learn Erlang. Or if Brad Fitzpatrick (Livejournal & Danga) ever asked if he should learn Perl!

Just learn what you (from looking around) believe will make you a better or smarter, what is even more important use what you learn. Don't just learn to learn!

Post reply on HN