10 ms·
Is this a good book, can anyone comment?
by aportnoy 7y ago
Is this a good book, can anyone comment?
- torstenvl 7y agoI'm not a fan so far. Lots of deliberately bad C code. Using uninitialized variables, etc. Explanation of jargon seems to take priority over explanation of the language - the term "string literal" is explained before the concept of a function.
- tym0 7y agoWhat book would you recommend as an alternative?
- jacobkg 7y agoI learned C from “C Primer Plus” about a decade ago and I thought it was terrific: C Primer Plus (6th Edition) (Developer's Library) https://www.amazon.com/dp/0321928423/ref=cm_sw_r_cp_api_i_bgNGDb3GWV3VF https://www.amazon.com/dp/0321928423/ref=cm_sw_r_cp_api_i_bg...
- AlexeyBrin 7y agoC Programming: A Modern Approach, 2nd Edition by King is a good beginner book. 21st Century C by Ben Kelemens is also a good book.
- learc83 7y ago> C Programming: A Modern Approach, 2nd Edition by King is a good beginner book. I would recommend that as well. Dr. King was one of my favorite professors, but I bought that particular book on my own.
- Apocryphon 7y agoHow about Zed Shaw's Learn C the Hard Way?
- ScottFree 7y agoI just finished Learn C the Hard Way and would be interested in a comparison between it and those other books mentioned. Just from a quick glance, Modern C appears to be a much more in depth book. It appears to cover things like memory alignment, advanced types like unions, malloc, threads, etc. Learn C the Hard Way is more of a quick introduction. You learn the basics, like pointers, basic data structures, basic types and then learn to do something interesting with those basics (build a web server). It also teaches some valuable real life practices that Modern C doesn't touch on, like how to structure your project, makefiles, how to use Valgrind and gdb.
- tom_mellior 7y agoWait what, Learn C the Hard Way doesn't teach malloc? Programming without dynamic memory allocation is pretty restrictive. What "data structures" does it even teach if it doesn't cover malloc?
- ScottFree 7y agoLike I said, it teaches the basics. There's a single page on heap vs stack allocation and it says malloc allocates memory to the heap. That's it. That's all you really need to know to do stuff and it doesn't go into what malloc actually does under the hood. Modern C has an entire chapter called "malloc and friends" where it goes into much more depth about malloc, calloc, realloc, etc. The book is a good introduction to programming in C and I'm glad I read it. You obviously have a history with the author and I'll thank you to keep your past impressions out of this particular discussion.
- tom_mellior 7y ago> There's a single page on heap vs stack allocation and it says malloc allocates memory to the heap. That's it. That's all you really need to know to do stuff Every other C book seems to disagree, but OK. Does the book cover the -> operator? Does it mention free and realloc? You need those to do stuff, at least. > You obviously have a history with the author How is this obvious, since it is incorrect?
- afroisalreadyin 7y agoI would second 21st Century C, it's an excellent book. It has a very pragmatic approach, skipping features like unions that are not used in modern C, but going into great detail on the important things like memory management.
- flukus 7y agoThirded, especially on the pragmatism, this by far the most pragmatic programming book I've ever read. I fell in love with the C as a scripting language parts (https://github.com/RhysU/c99sh https://github.com/RhysU/c99sh), now I don't have much of a use for a scripting language to sit between bash and "proper language" (apart from some occasional awk).
- RhysU 7y agoGlad it has been of use!
- armitron 7y agoRead the reviews on Amazon. It's not a good book, the author makes embarrassing mistakes to the point where you start questioning his programming knowledge.
- psibi 7y agoFor others, this is the review that the OP seems to be speaking about: https://www.amazon.com/gp/customer-reviews/R3IQKSK19FIEI5?ref=pf_vv_at_pdctrvw_srp https://www.amazon.com/gp/customer-reviews/R3IQKSK19FIEI5?re...
- feanaro 7y agoHuh? Since when are unions not used in modern C? Tagged unions are a really common pattern in language interpreters. What are they supposed to be replaced with?
- kimown 7y agoAn Introduction to C & GUI Programming - Simon Lon is also good for beginners, especially it's easy understand content and beautiful typographic style.
- whydoyoucare 7y agoThe C language can be best learned from "The C Programming Language, 2nd Ed" [1], also known as "K&R book". Pair it with excellent notes by Steve Summit [2], and you don't need any other book to master C. [1] https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628 https://www.amazon.com/Programming-Language-2nd-Brian-Kernig... [2] https://www.eskimo.com/~scs/cclass/notes/top.html https://www.eskimo.com/~scs/cclass/notes/top.html
- boring_twenties 7y agoNo doubt K&R is second to none, but it only covers C89. Since then we have 99, 11 and apparently now 17 too?
- whydoyoucare 7y agoA useful approach is to learn 95% of the language from K&R, and then refer to the newer standards for the incremental changes. If there is a book as good as K&R and covers the new ideas, I'm interested to learn about it! :-)
- ndesaulniers 7y agoMy two favorite C books are: Head First C by Griffiths and Griffiths and Expert C Programming: Deep C Secrets by van der Linden
- nineteen999 7y agoLove Deep C Secrets. I have it and flick through it whenever I want to remind myself about the dark corners I never mastered during the last 20 years of programming in C.
- tpush 7y ago> Lots of deliberately bad C code. Using uninitialized variables, etc. You do realize he's doing that for illustrative purposes, right?
- torstenvl 7y agoYes. As I said - it was deliberate. That does not excuse it. By the very fact that this is a book, it presumes that the intended audience consists of visual learners. When working with visual learners, if something is erroneous, it is imperative that it be explicitly and visually called out as such. In linguistics pedagogy, for instance, this is done by marking any ungrammatical construct or example not found in natural language with an asterisk every time. https://www.ling.upenn.edu/~kroch/courses/lx101/assign96.html https://www.ling.upenn.edu/~kroch/courses/lx101/assign96.htm... https://linguistics.stackexchange.com/questions/338/meaning-of-star-asterisk-in-linguistics https://linguistics.stackexchange.com/questions/338/meaning-... https://www.departments.bucknell.edu/linguistics/lectures/asterisk.html https://www.departments.bucknell.edu/linguistics/lectures/as... This book does not do this. It freely uses deliberately bad code in example programs. This can only result in confusion on the part of learners. It is therefore inconsistent with pedagogical best practices. I would not recommend it.
- ndesaulniers 7y ago> Takeaway 1.5.5.1 All variables should be initialized. pg 59
- aidenn0 7y ago[edit] This was originally a comment about a book I thought was the same but merely had a similar title.
- abainbridge 7y agoLooks reasonable to me. I've been programming C daily for 25 years. Cosmetic but it is nice to see "int const foo;" being preferred to "const int foo". And "We define variables as close to their first use as possible". Less cosmetically, section 5.6 on named constants is great. That's a fiddly area of C from which to pull out reliable advice.
- kazinator 7y agoThere is no technical reason to prefer one or the other; they are both declaration specifiers which can occur in any order. long const int is valid, even. The const qualification is in the type; it is not a direct attribute of foo, so putting the const closer to foo means nothing.
- eMSF 7y agoThe point isn't about putting it closer to the variable name, but consistently to the right of what it applies to. But yes, it is a matter of opinion.
- mumblemumble 7y agoI'm only an infrequent C programmer, but that goal interests me simply because it seems unattainable given other aspects of C's syntax. If qualifiers went to the right of things they qualify, I'd expect variable declarations to look more like: foo: int const; And similarly, function declarations might also take a more ML-like syntax. C seems more like it wants to be an adjectives-before-nouns type of language.
- guerrilla 7y agoSee wahern and my response to the grandparent.
- mumblemumble 7y agoSo, IOW, it's not purely a point of style, it's more about what's a sane way to write things given the requirements of the language's syntax when you're dealing with pointer declarations? Which would explain why it seems so odd to me; I spent a fair amount of time in C-style languages, but typically only ones that lack pointers.
- deleted 7y ago[deleted]
- sosodev 7y agoI really like the first edition. Old C diehards hate it because it breaks a lot of tradition. Personally I think it's really refreshing and made me appreciate C and lot more.
- SAI_Peregrinus 7y agoThe first edition has been my go-to for introducing some of the newer (1999 and later) features of C (and some of the subtle footguns) to people. I'd definitely recommend it as a first introduction to C.
- ndesaulniers 7y agoI'm perusing the Takeaways highlighted in yellow; there are multiples per page. Seems like some hard learned advice that I mostly agree with. > Takeaway 1.4.5.2 Don’t use the , operator. Yep: https://news.ycombinator.com/item?id=20773742 https://news.ycombinator.com/item?id=20773742