Live data from Hacker News

Ask HN: Should I use K&R to learn C?

news.ycombinator.com

61–70 of 70 posts

Re: Ask HN: Should I use K&R to learn C?

#61
post #40

A small detail that has been missed by most responses to the question is OP isn't asking how to learn how to write the best possible 2015 C code for 2015 C tasks, but asked for reverse engineering previously written code (perhaps written VERY long ago). Depending on the age and quality of the code OP is reverse engineering, learning a very modern style of coding might somewhat oppose OPs goal. I'd advise OP to rephra…

hmm, I think my question is fine how it is. I want to learn C, I am asking HN their opinion of a book I am thinking about. If you want specifics, I would revise my question to something like "I really want to learn how to reverse engineer malware so I'm starting this goal by learning C, is K&R a good resource to learn C from?"

What kind of C? 1980s K+R or 2015 or ...

Its like the difference between "Programming Perl" 1st edition manual and 2014 edition of "Modern Perl"

Re: Ask HN: Should I use K&R to learn C?

#62
I feel K&R is an important classic from which one can still take a lot of valuable jewels in a pretty concise way. If possible, complement it with other books like Peter van der Linden's Expert C programming (although I don't like his opposition to static linking).

If possible, check the suckless.org projects, they tend to have pretty idiomatic and clean source codes.

Re: Ask HN: Should I use K&R to learn C?

#63
post #4

There was a very good critique of K&R in Learn C the Hard Way that got taken down because of (IMO) undue backlash. The gist of it was that K&R ignores the safety problems in C and there is no discussion of the habits/constructs seasoned C programmers have developed to make sure their code is safe. Of course, many of those habits were developed after K&R, but that's why we need revisions and new sources. In its place,…

There was a very good critique of "earn C the Hard Way": http://hentenaar.com/dont-learn-c-the-wrong-way

I'm biased, I have used Zed's books many times, but I found that critique to be far more detailed than it was "good." I got the impression that the author perverted Zed's writing just to take shots at it. LearnCTheHardWay, like all of Zed's other books is of the "write the code first, try to figure out what's going on your own first, and then I'll explain it to you" style. I get that some people don't like that, and if you were just learning how to code, I could see how the C book would be particularly annoying, but he clearly states it's not for people new to code. Mr Hentenaar also can't seem to make up his mind as to how he would like a how-to book to be written. In the first couple sections he complains there isn't enough detail, and then as soon as printf() is introduced, he is whining about the fact that every line of code was explained. Further, as he complains that Zed does with K&R, Hentenaar takes a lot of LCTHW out of context to show why it is "wrong" (such as the "make is the new python" example). Maybe he's trying to be meta in the way he wrote the review, but I doubt it.

As a side note, it is (nearly) impossible for something that hasn't changed in almost 30 years (k&r) to keep up with something as dynamic as a program language. Even if the standard hadn't changed, the way a language is used is practically guaranteed to change over a period that long. Although, as somebody else said, the exercises in k&r are great and it covers a lot of interesting information, but does seem pretty light.

Re: Ask HN: Should I use K&R to learn C?

#65
post #46

Earlier quoted context omitted.

Interesting, last time I asked on various C boards about learning resources, Zed's book got ripped apart. http://www.iso-9899.info/wiki/Books

The man who moved my book into the "avoided" category admitted to me in an email that he did it just because of my K&R critique, not because of the book's quality, is not a C programmer, hasn't coded C professionally ever, and works doing PHP with almost no C experience.

Yeah I am not picking sides here but they really sold me against your book on freenode. As a newbie I didn't know any better. Come to think of it, I was doing just fine following your book, until I went on #C at freenode.

Re: Ask HN: Should I use K&R to learn C?

#66

Earlier quoted context omitted.

Yes and no. Perhaps when the first edition was published that was true, but the second edition was published 11 years later.

When the second edition was published in 1988, there were seasoned C programmers, but security wasn't nearly the issue it is today. Since there was no World Wide Web yet, most computer systems weren't exposed to a global network full of people who wanted to crack code for profit. There was no e-commerce, no on-line banking, etc.

Was the Morris Worm, which brought down a huge percentage of Unix Servers in 1988, the result of C?

In any case, there was definitely a network that was being used by a lot of people by 1988.

Re: Ask HN: Should I use K&R to learn C?

#67
post #66

Earlier quoted context omitted.

When the second edition was published in 1988, there were seasoned C programmers, but security wasn't nearly the issue it is today. Since there was no World Wide Web yet, most computer systems weren't exposed to a global network full of people who wanted to crack code for profit. There was no e-commerce, no on-line banking, etc.

Was the Morris Worm, which brought down a huge percentage of Unix Servers in 1988, the result of C? In any case, there was definitely a network that was being used by a lot of people by 1988.

I think you're overestimating the impact of the Morris Worm - there weren't all that many servers to bring down.

The first commercial ISP in the U.S. was founded in 1989.[1] Until then, only a few people in universities and the tech and defense industries had access to the internet. According to this chart[2], the number of internet hosts in 1992 is barely distinguishable from zero on today's scale.

[1] https://en.wikipedia.org/wiki/Internet_service_provider#Hist...

[2] https://en.wikipedia.org/wiki/File:Number_of_internet_hosts....

Re: Ask HN: Should I use K&R to learn C?

#68

I would recommend "A Reference Manual" by Harbison and Steele jr over K&R... But to be honest, if you want to do reverse engineering, I would instead pick up a copy of "80386 Programmer's Manual" from Intel as you'll be living in assembly.

Did a quick search and found it: http://www.logix.cz/michal/doc/i386/ I must ask though and I don't mean this in a challenging way but isn't this teaching ASM for an old cpu? I'm largely ignorant of ASM so feel free to correct me. I just don't see the point of learning asm for that (As I believe that ASM changes from cpu to cpu).

It will give you the foundation to advance to modern day Intels. You won't last if you jump straight to x86_64

Re: Ask HN: Should I use K&R to learn C?

#69

A much more complete book than K&R is "C: A Reference Manual", which has much better explanations. See it here: http://careferencemanual.com/ , at its home page. Or at Amazon here: http://www.amazon.com/Reference-Manual-5th-Edition/dp/013089... . Turn to this book when you have questions. The authors are Harbison and Steele. If you become a C programmer, you will want and need this book. So you may as well get a copy…

CAR is a great reference book and something that I will use when I am writing embedded C even today.

But it is still a reference book not a get started with C guide.

Re: Ask HN: Should I use K&R to learn C?

#70
post #4

There was a very good critique of K&R in Learn C the Hard Way that got taken down because of (IMO) undue backlash. The gist of it was that K&R ignores the safety problems in C and there is no discussion of the habits/constructs seasoned C programmers have developed to make sure their code is safe. Of course, many of those habits were developed after K&R, but that's why we need revisions and new sources. In its place,…

To criticize like Zed Shaw is easy, but create something which would be used around the world for so many years - a different story. That critique is just not respectful marketing to promote the books which isn't very good by itself.
Post reply on HN