C Books and C++ Books You Don't Want
cs.technion.ac.il
cs.technion.ac.il
You can guess K&R is one of my favorites.
I understand that C++ is a huge complicated language, Scott Meyers puts it very aptly by stating its a federation of languages, and this makes hard to write pithy pedagogic books. In spite of that, the ever too common 800+ page tomes have always worked against me.
Stroustrup's 3rd is probably a mighty fine book to learn from, its just not for me and its definitely no K&R.
I think my favorite is a little known book by Dirk Vermier http://books.google.com/books/about/Multi_Paradigm_Programmi... It should definitely not be one's first programming book, perhaps not even one's first C++ book. A shade shy of 300 pages, it did serve me well with its terseness, correctness and clarity. The only thing is that its too pricey for its size, its a bit dated now because it covers c++98.
I think C++ is best understood from one pithy book that shows you the just the language to get started, and then a series of Scott Meyers, Andrei Alexandrescu, Herb Sutter style books to get good at it.
i have sent koenig an email asking about this, and he replied, and said he will start working on a new version with barbara moo as soon as she finishes working on the new version of C++ Primer
http://www.ksetindia.com/books/let-us-c
Ironically this book is quite popular with students in Indian Universities (I guess mainly due to ignorance)
Even the wikipedia page for the author admits this fact
The gross thing is that the content is toatally based on Turbo C/C++ compiler for windows and is full of errors, with no attention paid to standards
> assert is used for algorithmic error detecting instead of for debugging only. This is a serious error, common to many, otherwise good, books. But here it is very widely used.
One man's error is another man's programming style. Using asserts as comment-like statements to declare invariants is a very useful a well-established practice that leads to a more concise code. Perhaps it's a nuance not fit for the novices, but to call a book bad because if that is unreasonable at best.
In a deeper problem compared to when I don't turn it off? Are you sure about that? The only reason asserts are turned off in the production code is the performance considerations, nothing else.
You have fundamental misunderstanding of what asserts() are for. As GP said, they check for invariants not errors. Here -
+--------------------------------+
| |
| ASSERTS ENFORCE INVARIANTS |
| |
+--------------------------------+
They aren't meant for checking if socket() returned -1 or user entered an empty string. These are not invariants. An invariant is a condition that must always hold true or the code that follows will go off rails. An ordered list to be ordered, a pointer passed to a function to be pointing at a valid and consistent representation of a respective data type... this sort of thing. A foo(void * ptr) not being called with NULL may or may not be an invariant depending on what foo's documentation states. For internal code it probably will be, for a library version is probably won't. In any case, these invariants is what you assert().If your code runs into a broken invariant and you let it continue forward, you simply push the problem deeper and let it metastasize. Compare abort'ing program to letting it go on, fubar'ing user data and then over-writing a disk file with the resulting garbage. A medicine worse than a disease, eh?
All you have to realize is that not all problems need the same cure. Using your example, if it is found that a list broke it's invariant, isn't it enough to stop using this list (isolating it, not freeing it) and then gracefully terminate the program? There is more to elaborate here, but most readers can draw the correct conclusions. Maybe this discussions exposes how much more we need to learn about software quality - where my page on bad books (the ones I have encountered) is just a very narrow opening to the real problems.
I own the 3rd special edition: http://www.bookdepository.co.uk/C-Programming-Language-Speci...
and have pre-ordered the 4th edition which includes c++11 info: http://www.bookdepository.co.uk/C-Programming-Language-Bjarn...
I've only probably read like 5 c++ books, but this one kills all the others for explaining how things work, teaching good programming style, and giving you a great all round understanding.
I don't think being disdainful of Microsoft is interesting either but it makes more sense in context.
Overall, the website comes across as bitchy and pretentious. especially considering how their own HTML comes across as flagrantly hideous.
And the validity of "void main" doesn't depend on whether the system uses exit statuses. An implementation may accept forms of main other than the ones defined by the language, including "void main()" -- but if it doesn't, the behavior of such a program is undefined.
The rules are different for freestanding implementations, which are generally for embedded systems; for such systems, the program entry point is entirely implementation-defined, and might not even be called "main". But for hosted implementations, there's no advantage at all in using "void main" vs. the correct "int main(void)".
Interesting. I wonder why gcc does it that way.
> And the validity of "void main" doesn't depend on whether the system uses exit statuses. An implementation may accept forms of main other than the ones defined by the language, including "void main()" -- but if it doesn't, the behavior of such a program is undefined.
I don't think we're disagreeing. I'm saying that "void main" is never preferable to "int main", and the only time it's equal to "int main" is if you're writing code specific to an implementation for which "void main" is not undefined and which lacks exit statuses, making any return statement in "int main" equivalent to returning from "void main".
> But for hosted implementations, there's no advantage at all in using "void main" vs. the correct "int main(void)".
Agreed. That's why it makes no sense for textbooks to teach void main.
void main(void) { init(); for(;;) { web_tick(); serial_tick(); tcp_tick(); etc. } }
An example is the horrible Dynamic C compiler from z-world (or digi as they are now called). Guys who complain about "violating standards" clearly haven't worked in diverse enough fields on broken, shitty and half-standard compilers ;)
Has anyone noticed how many books on C are 4 times the size yet leave you with less valuable information than K&R?