Nov 27, 2016

The author provides the book as a free to download pdf at http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

Jul 28, 2016

I'd recommend Ben Klemens' excellent book "21st Century C - Tips from the New School" [0]. This book teaches you modern C techniques and, most importantly, the tooling that modern C programmers use (git, autotools, valgrind, etc.) It also covers commonly used libraries to help you from reinventing the wheel (GLib, POSIX standard, SQLite, libxml, & cURL.)

As mentioned in another post, David Hanson's "C Interfaces and Implementations - Techniques for Creating Reusable Software" [1] is a great book, stressing the design of good APIs. This book in particular might help you in your goal to become a better engineer.

On the free side, there's an excellent PDF by Jens Gustedt, "Modern C" [2]. I've not read the whole thing but it seems like an in-depth look at C11.

John Regehr's blog "Embedded in Academia" [3] is a good resource for C programming. You'll learn a lot about weird edge cases and undefined behavior. He also has a recent post about teaching C, with suggestions for resources [4].

[0] https://www.amazon.com/21st-Century-Tips-New-School/dp/14919...

[1] https://www.amazon.com/Interfaces-Implementations-Techniques...

[2] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

[3] http://blog.regehr.org/

[4] http://blog.regehr.org/archives/1393

Jul 19, 2016

Does any language have as a feature blocks that you must pass variables to? I tend to prefer larger functions but agree with your point. If I ever write (or extend) a language I am going include huge numbers of ways to make assertions or explicit limitations of various forms.

I like Jens Gustedt's proposal for annonymous functions in C (at the end of Modern C[1]) by extending the syntax for compound literals. That would in a way give parameterized blocks, except that what you pass would be at the end (although if you name the parameters the same as what you pass it should work).

I think the main point is that it is helpful to be able to easily follow all the code that executes from point A to point B (at least up to the point of whatever portability layer you use). If you can reasonably structure it so that you just need to hit page down to read that code (without duplicated code) then that will often be easier to read IMO. I don't find one or two levels of function calls to be hard to follow, but after that it quickly gets more difficult. I suspect preferences here may to some extent be influenced by how good your short term memory is (and how good your IDE is). But I suspect there are also significant differences in how often different programmers try to step through code.

[1] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

May 01, 2016

> thoughts ?

well, there is a 'ModernC' book by Jens Gustedt of INRIA available here: http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

which might suit your fancy ?

Apr 25, 2016

Since it has yet to be mentioned yet, I'll suggest Modern C by Jens Gustadt [1]. The book itself starts from basics and works up, but I found it to be much more reliable and filled with more practical advice than the common K&R recommendation. Section / Level 4 is not quite in it's final form yet; however the book is mostly complete and gives a lot to think about. I suggest working through it, even if you skip the first few levels because of your base knowledge.

[1] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

Mar 06, 2016

Here's a 2011 guide to modern C: [1] Discussed on YC last year.[2]

The 1970s string functions, such as "strcpy", that don't have a destination length were deprecated years ago, but they've never been removed from libraries. Microsoft's C compiler has warned about this for a decade.[3] This is one of the major causes of buffer overflows in C, and a large number of exploits involve it.. There's a CERT advisory from Homeland Security about "strcpy".[4] Seeing a "strcpy" in new code is a big red flag. If you see that in an interview, don't hire that programmer. They're dangerous.

Since C99, you've been able to write

    for (int i = 0; i < 10; ++i) ...
in C code, and that was in C++ from the early years. The trend in programming is strongly towards declaring and initializing variables at the same time. Remember, in C, local variables declared but not initialized have junk values until assigned. The "all variables declared at the top of a function" style is obsolete. Pointer variables declared without initialization are especially bad.

There's a long and painful history of classic C bugs, and the newer versions of C help, just a little, to avoid them.

[1] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf [2] https://news.ycombinator.com/item?id=9018247 [3] http://stackoverflow.com/questions/4012222/c-strcpy-gives-a-... [4] https://buildsecurityin.us-cert.gov/articles/knowledge/codin...

Jan 08, 2016

Modern C by Jens Gustedt: http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

It's not exactly 100% complete in the literal sense, but everything covering the language spec and usage is there. I highly suggest working through it, as the book itself is incredible for going from beginner to expert in the short span it does.