On 1/10/2019 6:12 PM, Jorgen Grahn wrote:
> On Tue, 2019-01-08, Manfred wrote:
>> On 1/7/2019 11:44 PM, Jorgen Grahn wrote:
>>> On Sat, 2019-01-05, Unto Sten wrote:
> ...
>>>> I do not mean to be trolling, but I would like
>>>> to take the time learn C++ properly, since
>>>> incorrect C++ usage seems to me as dangerous as
>>>> incorrect usage of C. So many chances to create
>>>> nasty bugs when falling victim to undefined behaviour
>>>> and so on.
>>>
>>> Maybe I'm lazy, but from my point of view you can read the 3rd edition
>>> and learn to write good C++. IMO, the line between old and crufty C++
>>> and modern C++ is C++98, when the standard library containers appeared
>>> and (years later) people started using them properly.
>>
>> This sounds a bit simplistic, I think. If C++98 was a major
>> breakthrough, C++11 was somewhat of a major revision too.
>
> It's all rather subjective, but to me C++11 isn't /that/ big of a deal
> since it didn't fundamentally change my designs. And regarding the
> OP's "incorrect C++", my pre-C++11 code isn't suddenly incorrect, or
> even archaic.
One of the greatest features of C++ is its reliability, in the sense of
backward compatibility guarantee, which makes C++ code valid for a long
time - which makes it suitable for serious applications.
Still today, or even after C++20, you can write C-like or "C with
classes" C++ code (I mean it is possible, not that you actually do) and
rely that it will produce correct executables.
But even if C++11 did not let into obsolescence the billions of lines of
existing C++ code, still it introduced changes that I (and many others)
consider relevant enough to put the language into a new perspective.
Bjarne himself said it can almost be seen as an entirely new language.
From this point of view, the fact that "C with classes" code still is
valid C++ code is even more impressive, but does not change the fact.
Some examples: constexpr, traits and type support (enable_if), function
objects (including lambdas), move semantics, variadic templates,
standardized smart pointers ad so forth do place the language into a new
perspective, which is best learnt from start than caught up afterwards.
>
>> So, if one wishes to catch up today, I would recommend the 4th edition
>> to start with.
>
> I agree. But at the same time, people should not avoid C++ because
> it seems to be undergoing drastic changes.
Not at all. As I said, one of the greatest values of C++ is your code
will keep running for a very long time.
I, like many others, have quite some code from the '90s which is still
recompiled and run today.
By the way, Bjarne is aware of the risk of too much growth too - look
for "remember the Wasa"
>
> ...
>>> I do use C++11 features (auto, ranged-for, uniform initializers,
>>> override, some of the library additions ...)
>
> I should have mentioned lambdas here, too. They are fairly easy to
> understand, and make <algorithm> more useful in practice, among other
> things.
Good point that you mention "easy to understand" features. I think the
most effective improvements in C++ are those that even when opening wide
new perspectives, still are essential and thus easy to grasp. This adds
to their effectiveness.
>
> /Jorgen
>