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?
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.
incidentally I've saved some .2-.8ms per frame in a "AAA" (I use the term loosely and with disgust) game title by replacing compiler generated assignment operator in one struct with an explicit 128-byte copy. copying individual bytes is slow, and the compiler is never as sufficiently smart as people claim.
in analagous cases involving memcpy, the fact that memcpy is not memmove saves much less than actually copying the data in a way that squeezes everything out of the data buses. :)
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.
Should we not make library calls because the programmer who wrote the library might have, maybe, possibly, screwed us over in some way perhaps, or because the mechanism can be broken with faulty input?
You trust, potentially, the same programmers every time you trust an executable loader to start running your code... which is pretty much every single time.
Permutations of input is not "wrong", its a valid mechanism for exposing unexpected/undefined behavior. "Massively outweighed by the convenience" is subjective and, in many circumstances, very suspect.
You can't then extend my argument to mean that all functions should not be called. All functions with unterminated while-loops shouldn't be called, but not all functions.
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,?)
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.
It is true that if you map in the reverse direction, tablature can represent playable music even if it's not particularly expressive, while piano fingerings can not. (Well, I suppose you could write music with only piano fingerings and let the performer improvise, but I'm sure that's not the point of this discussion :)
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... :)
It's surprising that people otherwise living day and night dealing with bandwidth and capacity issues of software systems ignore their own limits on bandwidth and capacity and are willing to put up with random bs in the name of some macho industriousness.
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], 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-tools
From 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...
Also, the author should stop promote the epub version if he won't do it.
No it's not. The kindle works fine for programming books, I'm currently reading Bjarne's "The C++ Programing Language" on my kindle, on PDF actually. The book itself lies on my bookshelf but why would I bother to open it?
The PDF isn't tailored for the kindle but it has wide enough margins so that when you crop it it works quite well on the kindle. The kindle is not the limitation nor the problem.
The problem is rather the crippled format that you get in a fullsize PDF. What exactly are you going to read it on? Print it out? (seriously?). On your monitor? Not really... On your tablet? You're joking right, reading a book on a glossy LCD?
Having a book as a PDF is quite useless for other than using it as a reference.
Now I don't know about any potential issues with epub/mobi, and honestly I couldn't care less in this case. The site mentioned (and still does) that an ePub will be available and if so I kind of expected an ePub version of it, in my eyes that was an incentive to take the course.
If that isn't going to happen an ~A5 PDF will work great too, since there actually exist devices that you can read it on comfortably.
And I kind of have a hard time to see why the book, as it is portrayed in the HTML-version wouldn't be able to work as an epub - but OK, if that's the case (or if epub truly is just a mess) that's surely not the case for a portable-device-friendly-PDF.
Also, it really cracks me up to see someone talk about broken formats and in the same post make an argument for PDF.
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.
I don't think Zed has trouble making $100,000 a year.
Disruption is taking a $100,000/year teacher from teaching 30 students a year to teaching 30,000.
5,000 students per instructor.
My point in all of this is that free is not free and that those who are willing to build courses and content at this scale need to be compensated somehow for their time.
Being able to make a living will draw more people. More instructors, more classes, more choices, better classes, better content, etc.
This is important point that seems to be missing from the online education discussion.
Only if you count all the classes they teach every day. However, kids don't come to school for just one class a day. Each teacher gets 15 to 30 kids 8 times a day for 1/8th of the day (assuming 8 classes a day). Not that that's really the important point here...
"My point in all of this is that free is not free and that those who are willing to build courses and content at this scale need to be compensated somehow for their time."
He is getting compensated though. At $29.00 a pop. The fact that he puts free material out there will almost definitely raise his compensation, not lower it.
"More instructors, more classes"
You don't necessarily need or want this. If one teacher can teach xx,000 people in a given subject, the teaching market will start to resemble a more 'winner take most' market, allowing those who aren't as good at teaching to find use elsewhere.
It will also allow everyone to learn from the best instead of only 125 people who happen to be in the right school district.
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.
Your free time is clearly worth more than your wage/salary. If your free time were worth nothing, it would make no sense to have it. You have extra time you could get another job possibly paying up to your existing rate.
Don't like the thought of taking a second job doing what you're doing now? That's because your time is worth more to you than that cash, by definition.
My spare time is worth happiness/distraction to me. Not money. I will confess that in that particular regard, I may differ from some, or perhaps even most, others.
As if that wasn't enough you have a lot of expenses that are flat-rate that you must pay regardless of how you spend your time (such as your rent).
All this is further assuming that your goal is to spend everything you make every month. Most probably put away some money to be able to buy a new car, travel etc. (or even just to be able to repair the car when it breaks)
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.
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)
- 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.