3 ms·
Is C11 a plus though? It has features strongly diverging from C++ (e.g. struct initializers), and may only add confusion.
by ansgri 9y ago
Is C11 a plus though? It has features strongly diverging from C++ (e.g. struct initializers), and may only add confusion.
- bstamour 9y agoThe languages, idioms, and ecosystems are different enough that I don't see that as a problem. They should be treated like two different languages. You wouldn't read a C book and expect to understand the conventions of C#. Neither should you for C++.
- ansgri 9y agoThe problem is, C-only codebases are pretty rare, even established ones adopt C++ (e.g. Darktable, which has a rather advanced C-only object system for UI and plugins). Especially in 'hot' topics like AI, where there may be place for pure C, but actually you'd more often use some low-level subset, like C with templates (very useful in writing image processing libraries). And no, I don't think it's reasonable to learn the modern C++ straight away, skipping C part: its abstractions are very leaky, you need to understand underlying resource management and type system. If you don't plan to learn C++ later, okay, do use a modern version, but if this is a possibility, better start either in completely different language with more clear semantics (pascal was great, maybe some Go or Rust are good now), or the pure subset, which wouldn't add to later confusion but would allow to use more advanced abstractions as needed. From my experience teaching software engineering to high school students which already passes their algorithms & programming courses, small differences in practices and/or semantics (svn commit vs git commit) is what kills learning progress.
- gdwatson 9y agoFlexible array members, designated initializers, compound literals, anonymous structs and unions, and many of the library features are pretty great. They more than pull their weight. I am glad the C11 committee put more weight on implementibility for C++ compilers than C99 did. Variable-length arrays in particular feel like the C99 committee decided to poke the C++ committee in the eye with a stick. (Given how the C++ world treated C at the time, though, I understand the temptation.) That said, if being compilable as C++ were a hard requirement for C features the world would be a poorer place.
- pjmlp 9y agoThankfully all the silly ideas in C99 regarding security weren't adopted by C++ and became optional in C11. Meaning VLAs that can blow the stack and memory related functions that still track pointer and size in disjoint variables.