Lurker News
Do you have some good advice or know any useful resources to learn in a proper way how to code in C++? For the context, I know some C, but C++ seems a different kind of beast, and it's easy to get lost in the huge variety of features and libraries it offers.

Comments (173) 47 threads

Earlier comments
AstralStorm1 reply#
Already outdated by 6+ years though.
tolger#
What would you say are important features missing in C++11 that are in the current standard? I ask because I'm trying to get back into C++ development after many years and even C++11 seems like a new language to me.
bogomipz1 reply#
I have a question on this topic which is - is it possible or practical to only learn "modern" C++?

Isn't it necessary to be able to understand pre-modern C++ in legacy code bases or to work alongside a co-worker who might code using an older style? Or even to be able to understand documentation and texts about C++ from an earlier era?

DoofusOfDeath1 reply#
I share your concern. Even if one isn't (knowingly) dealing with older C++ code, all of the language rules apply to every line of C++ being compiled.

Just one typo, or misguided use of syntax, and a person might be using some "older" revision of the language without knowing it. And I'm not aware of any tool that will warn the programmer that he/she has done that.
So I'm concerned that programmers schooled only in "modern" C++ will fail to understand that this has occurred, and will either (a) get error messages that don't understand, or (b) get program behavior that they don't anticipate.
I'm curious if people have found this to be a problem in practice.

bogomipz1 reply#
>"I'm curious if people have found this to be a problem in practice."

Same. And I think you articulated the specific concerns I have about just learning the "modern" version.
It would certainly lower the barrier to entry in learning C++ if this was an unfounded concern.
C++ has some 35 year of history and changes at this point. This point alone adds(for me anyway) to the perceived cognitive load of learning it. C also has a similar length of history but it is a much smaller language.

oblio2 replies#
> It would certainly lower the barrier to entry in learning C++ if this was an unfounded concern.

If the Javascript community, which is as fragmented as C++, if not more, could introduce "strict" mode and enforce it basically everywhere, then maybe C++ could do the same thing.
Have C++20 recommend a certain subset of C++, have C++24 warn as deprecated features not in this subset, have C++30 error out on everything outside this subset, unless the compiler is set to compatibility mode and finally have C++40 refuse to compile the old code.

Continue this thread — 2 replies

GreyZephyr4 replies#
Piggybacking of this post, if anyone has any similar resources for best practices in modern C I'd be interested. There don't seem to be any moocs that go beyond introductory material and K&R obviously doesn't cover modern tools and methods.
modernclearning#
“C Interfaces and Implementations” by David R. Hanson is what I used when I had a similar concern a few years ago. It’s from 1997, so no, it doesn’t cover the newest C standards, which I understand is your main concern. Though C11 didn’t add too much semantically, for what it’s worth. That said, the book provides great design patterns for writing C in an object-oriented sort of manner, more idiomatic to OOP.

Peter Hintjens was writing “Scalable C” a couple years ago, but recently died, and never got very far unfortunately.

isaachier#
My biggest question would be what modern means to you? Does it mean the style of the newest popular C project? The newest standard (C11)? And what devices are you using C for? I'd assume a standard POSIX environment, but you can't be sure with C.
jxub#
21st Century C is a really good book for writing C11. There is a .pdf of it in Google.

Load more comments