News for hackers. Stuff that matters.
Re:Modern C, Second Edition by torstenvl on Wednesday September 18, 2019 @01:52PM (#21008016)
I'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.

Re:Modern C, Second Edition by tpush on Wednesday September 18, 2019 @02:04PM (#21008171)
> Lots of deliberately bad C code. Using uninitialized variables, etc.

You do realize he's doing that for illustrative purposes, right?

Re:Modern C, Second Edition by torstenvl on Thursday September 19, 2019 @11:02AM (#21016829)
Yes. 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.htm... https://linguistics.stackexchange.com/questions/338/meaning-... 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.

Re:Modern C, Second Edition by ndesaulniers on Thursday September 19, 2019 @12:41AM (#21013352)
> Takeaway 1.5.5.1 All variables should be initialized.

pg 59

Re:Modern C, Second Edition by tym0 on Wednesday September 18, 2019 @01:55PM (#21008038)
What book would you recommend as an alternative?
Re:Modern C, Second Edition by AlexeyBrin on Wednesday September 18, 2019 @02:09PM (#21008219)
C Programming: A Modern Approach, 2nd Edition by King is a good beginner book.

21st Century C by Ben Kelemens is also a good book.

Re:Modern C, Second Edition by learc83 on Wednesday September 18, 2019 @02:17PM (#21008311)
> 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.

Re:Modern C, Second Edition by afroisalreadyin on Wednesday September 18, 2019 @02:59PM (#21008741)
I 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.
Re:Modern C, Second Edition by feanaro on Thursday September 19, 2019 @02:27AM (#21013814)
Huh? 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?
Re:Modern C, Second Edition by flukus on Wednesday September 18, 2019 @08:20PM (#21011957)
Thirded, 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), 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).
Re:Modern C, Second Edition by RhysU on Thursday September 19, 2019 @08:15AM (#21015426)
Glad it has been of use!
Re:Modern C, Second Edition by armitron on Thursday September 19, 2019 @01:22AM (#21013516)
Read 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.
Re:Modern C, Second Edition by psibi on Thursday September 19, 2019 @02:17AM (#21013766)
For others, this is the review that the OP seems to be speaking about: https://www.amazon.com/gp/customer-reviews/R3IQKSK19FIEI5?re...
Re:Modern C, Second Edition by kimown on Wednesday September 18, 2019 @09:35PM (#21012375)
An Introduction to C & GUI Programming - Simon Lon is also good for beginners, especially it's easy understand content and beautiful typographic style.
Re:Modern C, Second Edition by Apocryphon on Wednesday September 18, 2019 @03:12PM (#21008865)
How about Zed Shaw's Learn C the Hard Way?
Re:Modern C, Second Edition by saagarjha on Wednesday September 18, 2019 @06:53PM (#21011311)
I've only skimmed the book, but I wouldn't recommend it. The author has a tendency to be snarky and come up with "fixes" for "mistakes" that "old" C programmers make, except he does so in a way that is at odds with the fundamental design of C constructs and does not really show a correct understanding of undefined behavior.
Re:Modern C, Second Edition by braindeath on Wednesday September 18, 2019 @09:59PM (#21012508)
I vaguely recall the whole fallout where it was revealed he clearly did not understand undefined behavior, and I believe he did walk back and accept his misunderstanding.

That said, yes it is damned annoying to have someone that doesn't understand the intricate details of the language poop all over that community and act as if "well i've contributed lots of code in C, why listen to a bunch of language lawyers, that isn't important anyway" as if the two are mutually exclusive. There are some of us that have been using C for years for actual work and are also intricately familiar with the prickly details of the standard. Those are the people that you should be looking for C books. Zed Shaw consistently shows he would rather hear the sound of his own voice and diminish things that are uninteresting to him rather than put in that work to become an expert on all facets of the topic he is claiming expertise.

https://what.thedailywtf.com/topic/16422/zed-shaw-gets-schoo...

Re:Modern C, Second Edition by ScottFree on Wednesday September 18, 2019 @03:57PM (#21009396)
I 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.

Re:Modern C, Second Edition by tom_mellior on Thursday September 19, 2019 @05:18AM (#21014585)
Wait 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?
Re:Modern C, Second Edition by ScottFree on Thursday September 19, 2019 @06:10AM (#21014850)
Like 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.

Re:Modern C, Second Edition by tom_mellior on Thursday September 19, 2019 @07:45AM (#21015288)
> 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?

Re:Modern C, Second Edition by ScottFree on Thursday September 19, 2019 @08:03AM (#21015369)
I'm not interested in continuing this line of conversation. Read the book if you want to know more.
Re:Modern C, Second Edition by tom_mellior on Thursday September 19, 2019 @05:17AM (#21014582)
Here's an old critique, but based on everything I've ever read from or about Zed Shaw, I trust that it's still valid: http://hentenaar.com/dont-learn-c-the-wrong-way
Re:Modern C, Second Edition by whydoyoucare on Wednesday September 18, 2019 @03:50PM (#21009298)
The 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-Kernig...

[2] https://www.eskimo.com/~scs/cclass/notes/top.html

Re:Modern C, Second Edition by boring_twenties on Wednesday September 18, 2019 @09:31PM (#21012352)
No doubt K&R is second to none, but it only covers C89. Since then we have 99, 11 and apparently now 17 too?
Re:Modern C, Second Edition by whydoyoucare on Thursday September 19, 2019 @11:54AM (#21017395)
A 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! :-)

Re:Modern C, Second Edition by jacobkg on Wednesday September 18, 2019 @02:04PM (#21008166)
I 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_bg...

Re:Modern C, Second Edition by ndesaulniers on Thursday September 19, 2019 @12:36AM (#21013336)
My two favorite C books are:

Head First C by Griffiths and Griffiths

and

Expert C Programming: Deep C Secrets by van der Linden

Re:Modern C, Second Edition by nineteen999 on Thursday September 19, 2019 @04:43AM (#21014458)
Love 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.