Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have a question on this topic which is - is it possible or practical to only learn "modern" C++?

Isn't it necessary to be able to understand pre-modern C++ in legacy code bases or to work alongside a co-worker who might code using an older style? Or even to be able to understand documentation and texts about C++ from an earlier era?




I share your concern. Even if one isn't (knowingly) dealing with older C++ code, all of the language rules apply to every line of C++ being compiled.

Just one typo, or misguided use of syntax, and a person might be using some "older" revision of the language without knowing it. And I'm not aware of any tool that will warn the programmer that he/she has done that.

So I'm concerned that programmers schooled only in "modern" C++ will fail to understand that this has occurred, and will either (a) get error messages that don't understand, or (b) get program behavior that they don't anticipate.

I'm curious if people have found this to be a problem in practice.


>"I'm curious if people have found this to be a problem in practice."

Same. And I think you articulated the specific concerns I have about just learning the "modern" version.

It would certainly lower the barrier to entry in learning C++ if this was an unfounded concern.

C++ has some 35 year of history and changes at this point. This point alone adds(for me anyway) to the perceived cognitive load of learning it. C also has a similar length of history but it is a much smaller language.


> It would certainly lower the barrier to entry in learning C++ if this was an unfounded concern.

If the Javascript community, which is as fragmented as C++, if not more, could introduce "strict" mode and enforce it basically everywhere, then maybe C++ could do the same thing.

Have C++20 recommend a certain subset of C++, have C++24 warn as deprecated features not in this subset, have C++30 error out on everything outside this subset, unless the compiler is set to compatibility mode and finally have C++40 refuse to compile the old code.


I'll take your word for it regarding JS, but I was thinking along the same lines w.r.t. C++ deprecation.

Alternatively, one could take a page from CMake's playbook with "policies" [0].

[0] https://cmake.org/cmake/help/v3.7/manual/cmake-policies.7.ht...


ECMAScript 6 modules are in strict mode only: https://stackoverflow.com/a/31685340/1320143

I think C++ is getting modules, maybe they could do the same thing?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: