Live data from Hacker News

Learn C The Hard Way by Zed Shaw

udemy.com

61–70 of 100 posts

Re: Learn C The Hard Way by Zed Shaw

#61
post #56

Earlier quoted context omitted.

The problem is that the examples and explanations don't justify the level of castigation. Yes, you should always use strncpy() instead of strcpy() for instance, but that doesn't protect you from all bugs. The example of a safercopy() still relies on the assumption that the pointers given to it are valid, and that assumption is just as impossible prove as the assumption that copy()'s input strings are valid. Safercopy…

"Yes, you should always use strncpy() instead of strcpy() for instance, but that doesn't protect you from all bugs." I agree with your argument, but I don't enjoy encouraging programmers to use strncpy and co... the reason is simple, I don't want to encourage programmers to stop thinking about their code. Not having to think about something is great, when laziness is acceptable (RAD, web development etc.) but not in…

You're saying that the language should make the programmer's job harder, and that it's a mark of laziness to try to arrange things to make common mistakes less likely?

Re: Learn C The Hard Way by Zed Shaw

#64
post #54

Earlier quoted context omitted.

Nah, memcpy shouldn't exist (just not for buffer overflow reasons). memcpy is there because someone got their knickers in a twist over possibly being a few cycles faster than memmove, even though the chances that actually matters is tiny, while the chances that you'll accidentally use memcpy when your memory overlaps is much larger.

actually that justification for memcpy is quite poor. usually, performance wise, it is quite easily beatable once you start using the hardware. most implementations I've seen loop byte copies in the most naïve way possible... almost every architecture supports 32-bit copies, most support more... :) incidentally I've saved some .2-.8ms per frame in a "AAA" (I use the term loosely and with disgust) game title by replac…

"almost every architecture supports 32-bit copies"

How much of that was true at the time that function was created?

Also, on 'just use memmove': it would not surprise me if ancient Unices used memcpy instead of inlining it to copy really small buffers (such as 14-byte-max filenames), not for speed, but for the byte savings (even if singular 'byte' is the correct way to phrase that). With small buffers, the overhead of that 'if' can become substantial.

Re: Learn C The Hard Way by Zed Shaw

#65
post #9

Earlier quoted context omitted.

I always use “let's assume roughly X/hour” as a joke. You don't get paid for your spare time, except in opportunity cost. If someone applies 20 hours of their time at work, then yes, that's pocket change. If they apply 20 hours of their time at home, that's not time that they'd get paid for anyway, so the analogy is as foolish as the claim that every pirated copy of a movie would have been bought were it not for pira…

True, but by working for "roughly X/hour" you've established that the typical exchange rate for your time is roughly X/hour. If I were to ask you to do some work for my during your off time, I would have to pay about X ± X/2 depending on how you guarded your time. So what if someone only values their time at X/4? That's still $200 worth of spare time.

by working for "roughly X/hour" you've established that the typical exchange rate for your time is roughly X/hour

Well, I've established that I'm willing to work that many hours for that rate. That doesn't mean I'm willing to work more hours at the same hourly rate. Most people I know value their spare time enough to expect a higher rate for working more time.

Re: Learn C The Hard Way by Zed Shaw

#66
It's funny how, I started getting annoyed seeing people still learning to code on books while free tutorials were starting to pop up everywhere on internet.

And now people are starting to charge for those tutorials. And I know people here in HN love Zed Shaw. But come on, there are hundreds of free great tutorials to learn C on internet.

Re: Learn C The Hard Way by Zed Shaw

#67
post #29

Earlier quoted context omitted.

It's a bit like claiming memcpy() is bugged because it can crash your program. Well, true, it is good style to program defensively against memory corruptions, buffer overflows etc, and in that respect K&R may teach students bad habits. I think it's a bit much to say that it should never have been written like that, as at the time people knew so much less about building complex projects, sources of error and defensive…

heh heh. Who would have expected mercy and respect from the guy that made the (paraphrased) "pro-mo-fo" website (first saw it at Atlassian conference about 2 weeks ago, pretty funny though perhaps a bit rude). I think the guy is more than willing to point out any practices now deemed harmful, tradition be damned. I'm over it.

I prefered the original, less designed version - perhaps because it's more "programmer-ish" than the current one:

http://web.archive.org/web/20110710194634/http://programming...

but I can understand why it got changed :)

Re: Learn C The Hard Way by Zed Shaw

#68
I disagree with your disdain for IDEs... I hope that you are not totally misleading the people who will learn from your book because learning how to use the capabilities of Visual Studio or any decent IDE is very valuable. How are they going to debug complex graph data structures in their CS class if they don't have a great debugger? How are they going to understand the power of intellisense in modern programming? How are they going to learn about compiler flags without getting a headache? How much time are they going to waste compiling and linking with the commandline?

I like the no-copy-paste and straight notepad approach trust me. It works for everyone, it's a solid way to get these things into your brain. You need to write code, there's no way around it. But to tell people to never use IDEs because they are bad and they make you a bad programmer is BULLSHIT.

Re: Learn C The Hard Way by Zed Shaw

#69
post #66

It's funny how, I started getting annoyed seeing people still learning to code on books while free tutorials were starting to pop up everywhere on internet. And now people are starting to charge for those tutorials. And I know people here in HN love Zed Shaw. But come on, there are hundreds of free great tutorials to learn C on internet.

[deleted]

Re: Learn C The Hard Way by Zed Shaw

#70
post #68

I disagree with your disdain for IDEs... I hope that you are not totally misleading the people who will learn from your book because learning how to use the capabilities of Visual Studio or any decent IDE is very valuable. How are they going to debug complex graph data structures in their CS class if they don't have a great debugger? How are they going to understand the power of intellisense in modern programming? Ho…

and what would they do if they cannot use this functionality, for example debugging something embedded, or something that cannot be debugged the way you pointed out
Post reply on HN