Live data from Hacker News

Ask HN: Should I learn C?

news.ycombinator.com

71–80 of 98 posts

Re: Ask HN: Should I learn C?

#71
post #21

C yes, C++ no. Make sure you're using a C compiler, not a C++ compiler Here is why not C++: http://news.ycombinator.com/item?id=1463592 and why not java Edit: Was there something wrong with my comment? Or were you downvoting merely because you disagree?

Those are not reason on not to use C++, but reason on why some people shouldn't be using C++ in the first place. Yes you can do it in python unless you want speed, if I am to interface my python code with C or C++ why can't I write them in C++ in the first place? Also if I were to interface any scripting language code with C I would probably go with Lua.

Re: Ask HN: Should I learn C?

#72
post #67

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

You, and it seems most others here are suggesting that you learn C by doing some systems programming; I was thinking of dabbling in C, but maybe starting out by doing something with AVR/arduino or something like that.... Is the C your write for embedded stuff fundamentally different from the C you write for linux? I would eventually like to know how to write a php module or something like that, is starting by hacking…

I think the real value of C is how it deals with lower-level stuff- embedded systems, drivers, kernels, etc. Writing something like a PHP module would make more sense in another language (and then wrapping it in C if you need to).

Re: Ask HN: Should I learn C?

#73
post #64

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

For learning C I strongly recommend C: A Reference Manual (Harbison and Steele), not K&R. Read K&R for context, sure, but Harbison and Steele is more up-to-date and comprehensive while still a concise language reference. That book can basically answer almost any question about the language standard that isn't compiler-specific. http://www.amazon.com/Reference-Manual-Samuel-P-Harbison/dp/...

Read both, and then C Interfaces & Implementations by Hanson. Best advanced C book, ever!

Re: Ask HN: Should I learn C?

#74

I would suggest Python and C, in that order. Python will let you quickly have fun building large applications, and it will teach you object oriented programming. Once you know what a loop is, though, go by "Advanced Programming in the Unix Environment" and a decent C book and trip out on that for a year or so to really understand how computers work. I don't write C for a living at all, but it is great to know how eve…

I just checked Amazon for that book and it looks like you can get used copies of the first edition for under a buck. http://www.amazon.com/gp/offer-listing/0201563177/ref=dp_olp...

True, but the Unix world has changed quite a bit since then...there was this thing called "Linux", maybe you've heard of it?

1st ed. APUE won't cover e.g. epoll/kqueue at all. Get the 2nd. Fantastic book, though.

Re: Ask HN: Should I learn C?

#75

Absolutely yes. There's no downside in learning C, and there's not much fluff in the language core to complicate things, or slow things down. I'd suggest you get a copy of K&R: The C Programming Language and just work through the text and examples. You might also want to pick an existing C-based project and work on bugs in it, maintenance programming being one of the best ways to get to grips with using the key tools…

One downside to learning C is that you will have to resist the temptation to use C on projects where much safer and more productive languages are feasible. Being able to use it speaks well of you, but actually using it is rarely a good decision these days.

Re: Ask HN: Should I learn C?

#76
post #5

Earlier quoted context omitted.

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

agreed ... since you seem to be proficient in Python, one potential exercise is to write a C extension to the Python interpreter or C library modules for high performance

This also has the extended benefit of learning more about how Python is implemented, which always helps!

Re: Ask HN: Should I learn C?

#77

Absolutely yes. There's no downside in learning C, and there's not much fluff in the language core to complicate things, or slow things down. I'd suggest you get a copy of K&R: The C Programming Language and just work through the text and examples. You might also want to pick an existing C-based project and work on bugs in it, maintenance programming being one of the best ways to get to grips with using the key tools…

One downside to learning C is that you will have to resist the temptation to use C on projects where much safer and more productive languages are feasible. Being able to use it speaks well of you, but actually using it is rarely a good decision these days.

I get your point, but there's a lot of pretty solid apps running just fine on iOS that are primarily written in (objective-)C.

Re: Ask HN: Should I learn C?

#78
Yes.

I'm sure there are many reasons to know C/Assembler. But I felt like learning things like why:

obj.getField().setFirst("random"); obj.getField().setSecond("random");

is worse than

Field field = obj.getField(); field.setFirst("random"); field.setSecond("random");

Another reason I used to like C was that it always made me want to make my code run as fast as it was possible to run. When I write code in Java, I'm looking to make the code work. I'm not saying either is better, they just each have their plus points, but I enjoyed C more due it's challenges and feel I'm a much better programmer for knowing it.

Re: Ask HN: Should I learn C?

#80
post #45

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

A good book that goes over both C and assembly is "Hacking: The Art of Exploitation". The first 100 pages alone will give you a solid understanding of what is happening behind the code.

I can't recommend that book for learning C and assembly. Its coverage is amateurish and unprofessional, which are indicative of or at least encourage fuzzy thinking. You can read it for a time-efficient overview, but please don't go thinking you know C or assembly if that's all you've read.
Post reply on HN