3 ms·
I agree with you for everything except this one statement: > First of all, and most important one, learn C++ idioms, not C. I think it would be better to lear
by microcolonel 9y ago
I agree with you for everything except this one statement:
> First of all, and most important one, learn C++ idioms, not C.
I think it would be better to learn both. C programming really has its place, and it gives you a model to understand how the sausage is really made. I know lots of C++ programmers who couldn't even begin to understand how half the things in their language work, this leads to completely needless performance loss (like using vectors for statically-sized arrays of data, which I recently replaced with a C array in a piece of game modelling software for a 20-30% improvement in runtime).
The fact that you consider this the most important one is outlandish. I think it's easily more important to teach the tradeoffs and models involved in things like unique_ptr, rather than creating a cargo cult for abstractions that turn out to be useless half the time.
C++ programmers really need to learn C, at least after their first year of blissful ignorance. Don't stop teaching C.
- pjmlp 9y agoSorry, but on this one given my comments history, I am with Kate Gregory. C style code has only one place, unsafe C++ coding for optimization purposes, only after validated through the use of a profiler. In 99% of the applications it is usually irrelevant for what the users are expecting, and there are even some nice talks at Nokia Wrocław conferences, where the presenter was able to generate better compacter code with modern C++ instead of classical C code. It was the C mentality brought into C++, back when learning C before C++ was the only path as C compilers were adding C++ support, that brought the daily CVEs we nowadays endure in such codebases.
- johannes1234321 9y agoThe previous poster wrote in his 3rd paragraph "There is a place for old C style low level features, but those should come later, after the safer concepts are already ingrained." And I agree that teaching idiomatic C++ is important and C stuff is an extension. If replacing vector with a C array gives you 20-30% my general assumption is that vector was used wrongly and there were too many copies happening and passing a pointer around avoided them. And yes, when teaching pure C++ students will also easily create too many copies, but that's better than all the buffer overflows, null pointer dereferences etc. happening to students of C. Such bugs cause frustration, but students need results which give satisfaction.
- smelterdemon 9y ago>using vectors for statically-sized arrays of data, which I recently replaced with a C array See the idea is you can use std::array, so you can use modern idioms (and at() for bounds checked access).
- Sean1708 9y agoI think a better way to phrase it would be "stop teaching C to people who think they're learning C++". I completely agree that doing even just a couple of weeks of plain C is an incredibly useful endeavour, but I saw the "C with classes" idiom a few too many times back when I was still doing C++.