268 points · by shawndumas · 14y ago · 96 comments
You see, "K&R C" is actually riddled with bugs and bad style. Its age is no excuse. These were bugs when they wrote the first printing, and the 42nd printing. I hadn't actually realized just how bad most of the code was in this book and recommended it to many people. After reading through it for just an hour I decided that it needs to be taken down from its pedestal and relegated to history rather than vaunted as state of the art.
This seems a bit hyperbolic to me... I just read K&R several years ago during school (could definitely use a re-read) but remember absolutely loving it for the combination of brevity and density of information conveyed. I'm not much of a C programmer though so I don't really know. Could a modern C programmer respond / elaborate?
[1]: http://c.learncodethehardway.org/book/learn-c-the-hard-waych...
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 programming.
Keeping a book up to date takes a lot of effort, as I'm sure Zed (npi) appreciates. It's an old book, it has warts. As you stated, the density of information was what many people like about the book, so any replacement for it will have to replicate that. I don't think the criticism is unfounded though.
http://web.archive.org/web/20110710194634/http://programming...
but I can understand why it got changed :)
Guitar however is a weird instrument that doesn't really work with notation, so guitarists have an alternative notation called "tablature".
This is incorrect. Guitar works perfectly fine with standard notation. It may be somewhat difficult to figure out fingerings if the music isn't arranged for guitar, but it's not much harder than playing piano without fingering information. I agree with the overall analogy (that tablature is initially easier than sheet music, but ultimately restrictive), though.
Beat 1: root-position C-Major triad (C,E,G) fingers: (1,3,5)
Beat 2: first-inversion a-minor triad (C,E,A) fingers: (1,3,?)
If the pattern is legato or fast and you can't lift up your hands, playing both G and A with the 5th finger will be difficult for most players. The easy solution is to finger the first triad with (1,3,4) or (1,2,4) so you can move 4 to 5. The latter being preferred if possible, to reinforce the weak 5th finger. (1,2,5 is probably the most natural fingering for the a-minor6 triad)This is a trivial example, of course. With real music it's usually much more complicated and learning how to handle fingering challenges is one of the more important things you learn as a student of piano. Even classics often have fingering suggestions included, if not by the original composer than by subsequent editors.
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 the general case...
Most of the time, the programmer should be smart enough to not fall foul of the problems strncpy avoids. The argument against the copy function in "learn C the hard way" implies that the programmer doesn't understand the code, language, or platform particularly well...
Mine is a fundamentally flawed argument though... as much as I want to live in a world where people can write code properly, the truth is idiots will always be out there. Although, as such, I would rather my code did shoot them in the foot if they were stupid enough to load it up and point it that way before firing... :)
I would suggest using strlcpy.
You bet it will be hard to learn when you shun the best book ever written on the language, coauthored by the designer of the language!
You talked about installing xcode. For newer osx versions, people may be able to install just the [command line tools for xcode][1], which is only about 170MB or so. It might save some people from waiting around for the full xcode.
Just looked at it:
preferences -> downloads -> command-line-toolsFrom now on, it's PDF and HTML only.
What we really need is a format that works across different devices. If only there were a portable document format that solved this problem...
[1] http://c.learncodethehardway.org/book/
EDIT: By posting the link to the book, I by no means meant that the videos are redundant. I would love it if more people en-roll for Zed's Udemy course and support him.
Took part of an afternoon to figure out how to build it.
Books, videos and course materials don't just happen because we say so. Real people create this stuff.
There's a really good argument to be made if the OP were linking to a bootlegged free version of a book that costs money, but it's really silly to criticize him for pointing out the free version of the free book on the thread about its companion course.
I'm not trying to be confrontational here. Online education/coursework/learning needs a pricing structure that makes sense. One that enables thousands of qualified instructors to participate without going broke in the process.
I think I understand Zed's "freemium" model in that context. But I disagree with his approach.
Our local high school district pays some teachers over a $100,000 a year. That's 3,448 students at $29 each -- per year. That's roughly equivalent to the entire student population!
Look for yourself: http://www.familytaxpayers.org/salary.php
Find a district: type in '230' Select 'Cons HSD 230' from the list presented.
There is no disruption in education until there is parity between what Zed is able to make and what these people make.
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 pirates.
Instead, I'm choosing between 20 hours of reading a book and maybe 20 hours of watching television (for example), which costs the electricity that the television consumes (since the cable or internet is paid for already). I suspect you'll find 20 hours of TV will cost less than $29. Or maybe it's 20 hours of running over the course of a couple of weeks. That's free, except maybe for the cost of the water to rehydrate. That's probably cheaper than $29, too. If you want to do the analysis in terms of how much it will earn you in the future, that's also valid I guess. But it complicates things, since it's hard to quantify how much the relaxation you get from watching TV or destressing from running is worth.
Let me just say, I don't think people should complain about the price of a good book when it's <$50-100 (depending on material). But the X/hour analogy only works if you're taking work time, and then many companies will often be willing to refund you that money anyway.
Last note: this isn't $29 for a book. It's $29 for a video course (though admittedly a non-HTML version of the book is thrown in at the end). The book itself is available for free, which is all that the OP was pointing out.
For what it's worth I plan to read the online beta then print out a bought PDF for easier reading.
So even though I love python I want to see if the same technique can introduce me again to C, a language I never felt comfortable with.
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.
IDEs are usually useful if you're stuck using them to build GUIs or use specialized build tools they require.
- find in files (in vim, not in bash)
- replace in files
- rename symbol (uh-oh...)
- quick open file in project (visual assist feature)
- list of files in project (not in directory)
- build system (something easy to use, not that make bullshit)
- go to declaration/definition ( sometimes I get a list of 30 matches from ctags, so I would like something that actually works )
- view call hierarchy (callers, callees)
- code completion (something that works and is easy to use, like in visual assist)
- watches
- breakpoints in disassembly
- step into disassembly
- memory view while debugging
- edit & continue
- memory (data) breakpoints
We're talking about large C/C++ codebases, obviously. You might get 50% of the features above after tinkering for a few days/weeks/months with your vim with (probably) much worse usability, when you could have used Visual C++ from the get-go and enjoyed a "real programmer's editor", as you put it.
This bullshit religion you are introducing only hurts potential programmers because instead of focusing on getting their job done they have to reinvent the wheel every time they have to write a line of code. I'm not saying it's a bad thing for a young mind to experience the horror of having to debug a 500.000 LOC codebase with a stone-age debugger, just for the kicks ("that's how your old man was programming back in the day, son"), but when you have to meet deadlines and release something going vim-only can quickly become a liability.
But I agree with overall sentiment. We shouldn't try to make programming hard. It is hard already.
If you are more productive in IDE over text, what is the benefit of using text editor?
You probably want to fix that.
But, I say try going through the HTML version online, and as you do get stuck write comments to ask me questions. That's why I put it online for free, so that I get student feedback while I write the book.
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.
Chances are though, you're someone who read the K&R chapter, then went through nitpicking minor semantics about things like "NULL is 0" and then consider all the code broken in the book.
But, any errors you find, let me know and I'll fix them. Just don't call me an inexperienced C programmer.