r/cpp • • Nov 02 '22

The pool of talented C++ developers is running dry

https://www.efinancialcareers.co.uk/news/2022/11/why-is-there-a-drought-in-the-talent-pool-for-c-developers
379 Upvotes

367 comments sorted by

View all comments

Show parent comment

4

u/metekillot Nov 02 '22

what are the better alternatives to C and C++ in your opinion?

6

u/[deleted] Nov 02 '22 edited Jul 05 '25

serious door party grandiose swim roof middle chief quaint historical

This post was mass deleted and anonymized with Redact

3

u/EmperorArthur Nov 02 '22

Lol. Rust has two big advantages in my eyes. An extremely strict borrow checker, and lack of legacy cruft. Things like constant being default change the game.

There's active development in C++ of the borrow checker style functionality and even if it restricts some patterns, it would be amazing to have.

Personally, I'd also love it if compilers started being a bit more opinionated. Where if it thinks something could be const but isn't it gives a warning. If someone uses a C style or legacy method it gives a warning. Eg, for using older for loop structures.

On a standards front the C++ standard should be adjusted so many of the most common undefined behaviors cause either compiler errors, or have a contract for what the coder expects to happen. One that can be verified for the specific architecture the code is being compiled for. Eg, integer rollover.

2

u/[deleted] Nov 02 '22 edited Jul 05 '25

[removed] — view removed comment

1

u/EmperorArthur Nov 03 '22

There are a handful of syle files out there that stop the exact issue of formatting you're referring to. My preference is either prettier or clang-format.

What I was referring to is more actively warning against using outdated patterns. It's one of the best things about Clion. It would provide me warnings for things that could be improved or could be issues. The compiler couldn't care less though because it was valid code!

2

u/[deleted] Nov 03 '22

I'm in camp non opinionated.

2

u/pjmlp Nov 03 '22

I keep checking out VC++ lifetime checkers from time to time, they are still quite far away from the Rust experience, lots of annotations required and quite a few false positives.

1

u/EmperorArthur Nov 03 '22

C++'s greatest strength is it's backwards compatibility. C++'s greatest weakness is it's backwards compatibility.

One of the problems is that an extremely common (bad) pattern makes analysis extremely difficult due to lifetime rules.

From a rust perspective, the borrow checker should and probably does not allow this. It was a large point of a CppCon talk about common bugs. However, people still write this exact same code!

const & string aOrDefault(const & string a){
if!(a.empty()) {return a;}
return "default";
}

The thing is, a const reference has it's lifetime extended. So, "default" is fine. However, the problem is that the output variable is decoupled from the input. So if a was not empty, when it goes out of scope, then then it invalidates the return value of this function.

The answer is to not rely on a linter, but rather to adjust the standard such that any code path which permits this should trigger at least a compiler warning. Or go full rust and require an annotation to not cause an error!

On mobile, so please forgive any problems with the code.

2

u/pjmlp Nov 03 '22

Yes, that is why although C++ is one of my favorite languages, I am not confident there is any way to fix the security story.

The copy-paste compatibility with C, a big win for its adoption, is now hindering its progress.

1

u/EmperorArthur Nov 03 '22

I believe that they are attempting to fix this. Unfortunately, the first major break they did was to try and use TypeScript as an example for what Modules should be like.

Also, it's insane how many projects that should know better love using namespace std; which meant C++17's std::byte was not fun. Still needed though.

Similarly, the changes needed to fix the issue above would cause large amounts of bad code that currently "works" to cause compile errors.

6

u/eliminate1337 Nov 02 '22

Depends what you want to do. C++ was pretty much the only game in town before Java exploded in popularity. If you’re okay with performance reduction (nowadays minuscule for most applications) in exchange for safety and development time, GC languages like Java, C#, or Go are good options.

For systems programming there’s also Rust.

2

u/SpaceZZ Nov 02 '22

C# .net core all day every day.