News for hackers. Stuff that matters.
Re:C++ by Example by pjmlp on Thursday September 22, 2022 @11:41AM (#32940487)
The problem is that many keep teaching C++ with code that a C compiler won't have any issues with.

That is why Bjarne keeps doing those advocacy talks about best practices.

Re:C++ by Example by mk89 on Thursday September 22, 2022 @03:36PM (#32943647)
Related to this, maybe: an issue I had was also the fact that online many of the help pages are really outdated.

I can't forget an old accepted "much voted" answer I saw on stackoverflow which claimed that raw pointers should be owning resources, because that's how the language always did.

I think the answer was dated like 2008 or so, can't find the reference anymore. That's when I started to pay a lot more attention to the published date whenever I search for help and I stumble upon a very old article. If only we could get rid of old resources written before maybe 2018-2019 and only select those that are still "modern", that'd be already a great step forward.

Luckily we have this now [0].

They should invest more in tools like the GSL extension at least as a clang warning which really helps, and things like that. That's how I believe Java was also able to modernize. You can write pretty crappy Java too, but tools like findBugs or checkstyle do help, so why not!

[0]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines...

Re:C++ by Example by pjmlp on Thursday September 22, 2022 @04:00PM (#32943910)
That is what using VC++ with integrated support for Core Guidelines feels like, naturally that is a minority.

https://learn.microsoft.com/en-us/events/pure-virtual-cpp-20...

Re:C++ by Example by mk89 on Thursday September 22, 2022 @04:15PM (#32944049)
Yeah, I kind of envy that.

Although with Clang-tidy I sometimes see GSL warnings: https://clang.llvm.org/extra/clang-tidy/ which is pretty cool - I wonder how up-to-date that is compared to the GSL extension.

The more you invest in this kind of automated tools, the earlier you catch such bugs. Sure, sometimes it's "false positives, I know what I am doing", but you cut maybe a good > 90% of crap that comes from just writing old-style code.

Re:C++ by Example by ModernMech on Thursday September 22, 2022 @02:57PM (#32943135)
The real problem as I see it is that people think the path to safe C++ is to tell everyone "you're holding it wrong" (just use modern C++), when it fact being able to hold it wrong is regarded as a feature (C++ maintains backward compatibility) by the C++ community.
Re:C++ by Example by pjmlp on Thursday September 22, 2022 @03:56PM (#32943868)
By C expats on C++ country.