>>Let me start by saying that unlike Mr. Shaw, I am not a writer. I'm an engineer.
Zed Shaw, whilst his approach to certain issues may be questionable, is not "a writer rather than an engineer".
Zed is known as one of the most prolific and capable software engineers around and I have heard his C code for Mongrel 2 server https://github.com/zedshaw/mongrel2 described as being amongst some of the best examples of C code to study, learn and understand (trying to find the link that said that). I hold his work in high regard.
I don't agree with everything that Zed does and think it's a pity that his combative and dogmatic nature detracts from the core message about his work, but the author of this blog post is off track if he is trying to suggest that Zed doesn't know what he is doing and is "a writer" rather than "a software engineer". Zed is a (cantankerous) software engineer and a writer.
The attempt to discredit Zed's credentials just discredits the blog post and its author. When criticizing, criticize the work rather than the person.
At this point people just keep trying to pick fights with Zed. He's not out there picking fights with others (well any more than anyone else).
And all of the posts pointing this out all disclaim that "while they don't agree with Zed about some things..."
It's just kind of sad from a rhetorical perspective.
It's clear that the guy who wrote this post doesn't agree with Zed's pedagogical style, but that doesn't make Zed's book wrong in detail or approach. It just means this guy doesn't agree with the style. And he's not upfront about it either due to a lack of introspection or forthrightness.
I agree that the tone of the blog post could have been less combative, but essentially all of this complaints are valid. Zed's does introduce things in the wrong order and in a very confusing fashion. The rant about C strings is also completely misguided and would lead a novice off course into using ugly thickets of macros and crappy frameworks rather than simply using C strings correctly. Any C function will misbehave if passed invalid input... and things like valgrind, which Zed is clearly well aware of, make C-style strings much less dangerous.
Zed also made many completely unjustified attacks on the K & R book, which is a well-written, easy to read book which introducse C concepts in a clear and readable way. Even if this was justified (and it's really, really not), that all belonged as a separate blog article rather than as part of an alleged "tutorial."
Finally Zed published a "rebuttal" to all of this in which he basically says that C sucks, is not worth learning, and he's learning Go. So the author quite reasonably asks, why would you want to learn C from someone who doesn't like the language or think it's worth learning?
I think we can all agree that Go (or some other high level language) probably is the better choice for most projects. But after all, there are still many places where C will continue to be used like the Linux kernel. Those people would be much better off reading K&R, as old as it is, than anything Zed has written. And his attacks on the K&R authors are just sad.
It sounds like more than a just a "style" disagreement.
In the discussion of C strings, the author is arguing that Zed's arguments are nonsensical, maybe even objectively wrong. I write a lot of C, and the author is right in this case about C strings and undefined operations. In C you must arrange your code so that you always supply valid input to functions, there is no way around it, and it is perfectly safe once you do so.
I'd rather see discussion of the actual arguments, rather than complaints about the article's tone. :)
Zed's book is concretely about introducing programmers (particularly new ones or ones going from higher level managed languages down into C) to where and how C can be dangerous especially around string management.
And that's why this is a style issue. Even if he disagrees with Zed's approach (and in particular how undefined behavior is discussed) it's just mendacious to claim that Zed isn't introducing his readers to the idea that one needs to be careful with strings and understand what kind of inputs one will receive.
This is a critically different behavior when compared to Ruby or Python where string management is done for you, and coming from the POV of someone who's familiar with those languages... Zed's approach makes sense. Especially when the alternative being suggested is "you absolutely must go read the C spec and K&RC".
People who behave in a combative and dogmatic manner have not programmed in to themselves a check to ask "does this issue really matter?". There is no decision making code in their brain to work out if something REALLY matters. Many things, even small things, matter enough to go to war.
They also value the war/being right/the point more highly than they value maintenance of positive human relationship.
What they don't understand is that people forget the issue and remember the grace (or not) with which you handled it.
Often they are not very good at empathizing with others and find it hard to imagine what it is like to be someone else interacting with them.
This is the second time this post has been voted to the front page of HN. It's puzzling. Are C programmers supposed to find this compelling now, when they didn't the first time around?
I think it's a pity that people can't see past him being "combative and dogmatic". I don't agree that it takes away from the core message of his work at all.
A lot of really smart people are cantankerous, and often they can afford to be.
The only time I've met Zed I found him to be a perfectly pleasant and non-cantankerous person.
My understanding of his approach to teaching is that it's based getting people to do things that bring results and then getting them to understand why after - which I think is a perfectly sensible one for beginners
It is very good. There's an educational philosophy around this that state that people who are new need to know "why should I care" first, then "how do I do it" next, followed by "ok, why does it work that way?" last.
When you're cooking, you follow a recipe. When you are learning to be a cook, you graduate to figuring out why you do it the way the recipe did.
And when you get really good, you start saying things like "Well, I wouldn't teach people to cook THAT way! That's wrong!"
The full quote is "Let me start by saying that unlike Mr. Shaw, I am not a writer. I'm an engineer. Thus, this will be written from that perspective."
By implication, Zed's book is not written from the POV of an engineer (otherwise why would this be worth noting in any way shape or form? The topic under discussion is already software engineering).
That is not the implication that I took from it; as I read it, this is an apology of sorts that the critique is not informed by the perspective of a writer.
"Wait a tic... Where's the Makefile? I've got just about as much chance of finding it as the FBI does of finding Jimmy Hoffa. Am I just supposed to imagine it into existence?"
I think the point is that the make command can use implicit rules even if there is no Makefile. It knows how to compile C source files. (This could be confusing if you know about "make" but don't know about implicit rules.) For example:
$ ls
hello.c
$ cat hello.c
#include <stdio.h>
int main(void) {
puts("hello");
return 0;
}
$ make hello
cc hello.c -o hello
$ ./hello
hello
$
Later: "So, I'm just supposed to poke in some code, go to my terminal, type this magic 'make' word, and expect a built and working program, right?"
Yes, that's exactly what you're supposed to do. Try it, it should work.
strncpy, when used as designed, can leave the target array without a terminating null character. Using that array later with any string function causes undefined behavior.
strcpy, when used as designed, always leaves the target array properly null-terminated. Using it properly is a bit more difficult; you have to make sure the target array is big enough to hold the source string.
The entire article reads as a thinly veiled diss on Zed by someone that (badly) skimmed LCTHW.
Things like:
1. Griping about format strings not being explained until it's necessary to understand them even though it's suggested that you look into them right away in the extra credit section.
2. Griping about non-existent Makefiles even though they are explained in multiple sections, one where he chose to spend time dissing on the section title instead of actually reading it and seeing that you write a makefile.
It feels like the author believes that there's a "one true way" to teach a language and that Zed's way isn't it.
I for one am grateful for alternatives to textbook-style books, be it Learn X the Hard Way or the O'Reilly Head First books.
> C was designed on UNIX, and was basically made for UNIX. That's a matter of historical record. But to say that on Windows everything is a little "off", doesn't quite do it justice. I understand that the book is aimed at the uninitiated, but to put it that mildly is an understatement of epic proportions.
Yeah, this was the fist sign I wouldn't read to the end, and I was right. The author just says this, and leaves it at that. As if we are to just take his word for it. This is essentially what this argument boils down to:
"He said X, I say X++." No explanation, nothing to backup what he says, nothing other than a to suggest it's a epic understatement.
Let's put this another way: my comment is has more to backup what I say than this article. The author might be right, but he doesn't back it up.
And I don't even understand why he doesn't agree that C is a second-class citizen on Windows. Microsoft would rather have you code stuff in C++ or .Net and MSVC is stuck with the C90 standard (although apparently that is finally improving)
On the bright side, the author's hate for implicit make-rules, and inability to grasp the pedagogic value of showing implicit includes first, and -Wall later made me go and test the following in a "command prompt for VS2013" on windows:
>more hello.c
int main(int argc, char *argv[])
{
puts("Hello world.");
return 0;
}
>cl hello.c
Microsoft (R) C/C++ Optimizing Compiler Version
18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.c
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
hello.obj
>hello
Hello world.
My reading was that the author just didn't know about implicit make rules. Shaw's book apparently suggests using "make" to compile and link a simple C program. The author goes on at some length about not being able to find the Makefile, apparently unaware that no Makefile is necessary.
The "make" command is rarely used without a Makefile, so this is a fairly easy mistake to make.
Not quite sure what is new here. The MSVC compiler has been available for free for close to a decade at least and command line compilation was available ever since I first used it (in the mid 90s)
I wasn't aware of that. I suppose it came with the driver dev kits? I've not really been into windows development, but I thought I'd at least have brushed up it accidentally if one could use the official MSVC compiler to produce shareware and commercial software for free?
Were there any (free) IDEs that took advantage of this? I thought one of the reasons Stevens used DJGPP was that MSVC wasn't available for free? I suppose I could just be that it wasn't freely distributable, which makes it hard to bundle with a book (at a time when people can't just go and download megabytes of data from microsoft.com).
Or maybe MSVC was free, but not the c++ part? See eg:
(It's not my intention to move the goalposts, you say close to a decade, which means 2005 -- it's quite likely that I'm just biased due to my old age...)
I did literally mean a decade for the compiler (so 2005). While it is not a full IDE by any means, VS Express did include the standard VS compiler. You could compile most standard C programs on windows with that. For some time prior to that you could get a compiler with the DDK as well (but I don't remember since when; it has been a long time). Of course express didn't pack some of the libraries that came with VS; you could get most of them via the SDK and DDK however.
In the 90s though, I used the non-free VS for the most part along with some Cygwin until Mingw's appearence in the late 90s.
The author's jumping off point seems very much to be "I dislike Zed Shaw" versus, say, an earnest attempt to prevent novices from learning C the wrong way. That's a shame, because I think that would make for an interesting article.
Learn C The Hard Way is more like opinionated tutorials not a textbook. It's great for someone just getting started. If I were to hand someone K&R - The C Programming Language, their interest would instantly vanish. Why not start with something small (like The Hard Way) and work your way up from there.
To get good at anything, you have to constantly read and apply your knowledge. Why should this be any different?
Here's my 2 cents. Learn any language any way you want and don't give a shit for pretentious blowhards who tell you otherwise. Peace and love !
https://www.youtube.com/watch?v=hIJdFxYlEKE
I just read the entire article and I can't find one decent comment about why Zed's teaching methodology is wrong or why he shouldn't be writing a book on C.
All I see is the author fussing about coding style and some such.
I'd like to hijack part of this discussion and ask, if any of you know about a good modern c programming book.
Because I'd like to read the K&R C destructuring book, not just a removed chapter at the end of the book :-)
I somehow thought that notion, that K&R C is somewhat outdated in their code examples is widely accepted (biggest gripe is little to no input sanitation, afaik (?)), so a book about "this is what we learned about c in past 30 years" would be splendid :-)
Zed Shaw, whilst his approach to certain issues may be questionable, is not "a writer rather than an engineer".
Zed is known as one of the most prolific and capable software engineers around and I have heard his C code for Mongrel 2 server https://github.com/zedshaw/mongrel2 described as being amongst some of the best examples of C code to study, learn and understand (trying to find the link that said that). I hold his work in high regard.
I don't agree with everything that Zed does and think it's a pity that his combative and dogmatic nature detracts from the core message about his work, but the author of this blog post is off track if he is trying to suggest that Zed doesn't know what he is doing and is "a writer" rather than "a software engineer". Zed is a (cantankerous) software engineer and a writer.
The attempt to discredit Zed's credentials just discredits the blog post and its author. When criticizing, criticize the work rather than the person.