Live data from Hacker News

Ask HN: Should I learn C?

news.ycombinator.com

61–70 of 98 posts

Re: Ask HN: Should I learn C?

#61
Yes, it is worth learning C even though most CS programs do not use C now. C is an excellent abstraction of the actual machine. Python is great, but many of the constructs used in python do not map directly to the CPU. Like many have said, C is portable assembly.

Re: Ask HN: Should I learn C?

#62

Absolutely, yes. + From the point of view of Python or Java (say), it's close enough to assembly language to let you understand how things might work; + If you need speed or control over hardware, sometimes it's your best route to extend whatever you're working in; + In many jobs you'll be the only one who has the knowledge to do unusual things, hence you'll be more valuable; + It gives you another point of view when…

I'm not sure about aiming for "pure" languages. Lisp is functional enough that one can learn pure functional programming using it, if he tries. And Ruby is OO enough that one isn't missing much, isn't it? Nothing wrong with the pure languages as options, just I think impure languages can fit the categories too.

I would recommend Ruby, too. Even though I don't write large programs or webapps in Ruby, I use it to write the occasional script to glue different things together.

I think that there's probably more (practical) benefit to be had with Ruby than Smalltalk or Self.

Re: Ask HN: Should I learn C?

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

Re: Ask HN: Should I learn C?

#65

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

since I had to look it up, maybe others don't know:

K&R refers to: The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie

http://www.amazon.com/exec/obidos/ASIN/0131103628/thedinosau...

Re: Ask HN: Should I learn C?

#66
I've only had a few months of experience with Python, but I had no trouble learning C (it only takes a week or two to get used to the syntax). I'm pasting this from my reply in a Reddit thread:

If you're going to read K&R, make sure you visit the Errata page. There are a bunch of examples that have typos (some of them are not on the Errata page though).

But reading one C book isn't going to teach you everything about C. A lot of the C code out there makes heavy use of macros and multiple pointer indirections, which isn't covered in much detail in K&R. And if you're interested in the newer C99 standard, The C Primer is a great book (but it's quite thorough, which imo, is a good thing).

If you're going to try out the examples from K&R, pass these arguments to gcc: -ansi -pedantic -Wall -Wextra -g

The -g flag is for debugging symbols. I think I still have most of the fixed examples from K&R that will compile, if you're interested in these. Also, make sure to bookmark these two links:

http://www.eskimo.com/~scs/cclass/krnotes/top.html

http://users.powernet.co.uk/eton/kandr2/

The first one gives you some better explanations of what has been said in the K&R book (divided by chapters). The second one has most answers to the exercises in the book.

Re: Ask HN: Should I learn C?

#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 on linux or some other os a better start?

Re: Ask HN: Should I learn C?

#68
You should learn C and Java. These languages seem to be the most commonly used in college classes right now, and if you are already fluent in them, you can focus on the actual lessons much more easily, rather than wasting time with the nuances of the programming languages.

Of course, it will also help if you start working on the following things, as they will show up in your classes. Don't worry if you don't understand it all right away, that's why you're going to college, right? :)

- How to debug (go read the book by Agans if you haven't already. It's short and fun to read.)

- How to do base conversions (eg. how do you convert decimal numbers to binary? decimal to hexadecimal?)

- How to work with sets (If you know how to work with list comprehensions or the set objects in python, or have played with SQL, that's quite handy)

- How to write a proof. (Here are some handy words to google for: "modus ponens", "modus tolens", "propositional logic", "truth table", "logical fallacies" and, once you get a feel for propositional logic, go look for "first order logic".)

- How a computer works at the level of logic gates. (Go play with the java applet "xLogicCircuits": http://math.hws.edu/TMCM/java/xLogicCircuits/ and see if you can figure out how to design a CPU. It can be pretty fun, although the applet's a little clunky.)

- What state machines are, and how they relate to regular expressions.

- While you're learning C, go look at assembly languages and see if you can understand the relation between C and assembly, and also between assembly and logic circuits.

- How to study and manage your time (Yeah, I'm still working on that one myself...) :)

Re: Ask HN: Should I learn C?

#69
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…

There's a still a lot of C questions in interviews, plus usually bonus points for knowing it - it can definitely be literally profitable even if you never use it for anything substantial.

Re: Ask HN: Should I learn C?

#70

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

Post reply on HN