r/cpp • u/peppedx • Nov 22 '18
C++98 is back!
Hi all,
After 5 years I find myself back into the realm of C++98 and classic CMake, and everything seems quite strange now that i got used to some modern-ish habits!
Do you know any list or resource for libraries C++98 compatible (like Catch 1.2 for example).
G.
43
18
u/emdeka87 Nov 22 '18
Let me guess: giant legacy code and management refusing to let modernization happen?
9
u/Xeverous https://xeverous.github.io Nov 23 '18
Should submit a resignation from job paper. No, papirus, since paper is too modern.
2
u/F54280 Nov 26 '18
management refusing to let modernization happen?
If there is any value in the codebase, management should let the modernization happen, or they won't be able to find anyone of value to work on it in a few years.
3
13
u/NotAYakk Nov 23 '18
I'd be thinking about your next job. Not in the way of "quit right now", but rather does this job help you get your next one.
If you are working with a technology with growing demand, then skills you pick up now help you get your next job.
If you are working with a technology with shrinking demand, then skills you pick up now don't help you get your next job nearly as much.
If you are working in C++98, that is the second category. Now, such a job can be a good one, but factor in the fact that you are developing expertise in obsolete skills in your renumeration.
Imagine if your salary is (Base Competency + K * Skills from Experience), and that Skills from Experience is roughly "years of learning useful skills" (not of employment, actually learning stuff). So if you spend 5 years doing something obsolete, you'll get K*5 less money in ... every job until the end of your career.
Suppose K is something modest, like 1000$. And you have 30 years left in your career. Then spending 5 years doing obsolete tech could cost you 150,000$.
Are they paying you a large premium to work on obsolete tech compared to what you could earn elsewhere? Are you learning something else useful, like work processes or the like? If no to both, bail. Otherwise, learn what you can and keep an eye on how much of a premium they are paying you to work on obsolete tech.
9
u/david_sankel Nov 23 '18 edited Nov 23 '18
I want to second the suggestions for using Boost. The older Boost libraries provide much of what C++17 offers. Boost.Assign and Boost.Foreach are also decent substitutes for list initializers and range-based for loops. I would steer clear of libraries attempting to simulate move semantics; The complexity usually isn't worth it.
Incidentally, I'm a quite surprised at all the "you should just quit" comments. Someone who would leave a job just because they have to interact with some older toolchains strikes me as bad software engineering material. There are many perfectly legitimate reasons to interact with older compilers, especially if one is working on lower-level libraries that have gigantic client bases.
7
u/Dragdu Nov 23 '18
Assuming you are down to C++98 and not like C++-lol-you-have-to-use-VS6, any of the Catch 1.x will work for you.
-----
also condolences
5
u/malkia Nov 22 '18
Good luck with that :) - But I'm sure there must be plenty of embedded, game development (especially console), etc. libs that would be geared towards more C++98 (not because modern console compilers do not support modern C++, but simply because of the reactions to new modern C++).
Qt must be still C++98 (or available for compilation this way), maybe EASTL (haven't checked recently) - e.g. not sure what you are looking for... And there are still plenty of good "C" libs, or if your case allows libs written in modern C++, yet providing C interface (llvm, zmq, etc.)
9
u/jcelerier ossia score Nov 23 '18
Qt has been requiring c++11 for a few versions actually
2
8
u/bizwig Nov 22 '18
I never understood the bad reactions. Makes zero sense to me. Even game developers should appreciate move semantics, mandatory copy elision, some of the new containers, ranged for, structured bindings, fold expressions, type safe variadics, etc.
3
u/BoarsLair Game Developer Nov 23 '18
Oh, we do. Just about every game development studio I've recently contracted with has embraced modern C++, at least to the extent their code base allows them to. There's very little reason not to, as C++ remains backwards compatible even with decades-old code. But we still generally don't use exceptions or RTTI. RTTI in particular goes against the grain of C++ features by imposing a cost even for an unused feature. Exceptions used to be the same way, although with the advent of 64-bit architectures and zero-overhead exceptions, it's mostly about inertia these days, I think.
As for not using the STL, this mostly happened at a time when the STL libraries that shipped with the compilers were not nearly at the level of quality they are today. Some development houses lived with it, some used third-party STL libraries, and some wrote their own container libraries. I've worked at various places that have done each of these.
These days, there's less reason to avoid using the STL libraries. They're broadly available, more stable, and you can make them perform much better with custom allocators.
2
u/malkia Nov 23 '18
I do understand them. It's not that they are not good, but first they have to be battle tested - for example first uses of anonymous callbacks and their hidden allocation costs were detriment to their acceptance, but later other options were found.
STL in general is hard to get acceptance in shipping code (consoles), simply because a sense of lost control is seen. I (work on the toolside) used it heavily, and depend on it - there is penalty for doing so (both memory and cpu), but it eases the process, and instills safe programming - e.g. I'd rather use std::string, even with it's performance downsides over plain old char buf[SOME_MAGIC]; - but then I can clearly see why the latter would be preferred on consoles, or embedded devices. It's just the way it is. And there is still no yet constexpr's std::string literal available!
4
u/STL MSVC STL Dev Nov 24 '18
string_viewliterals are constexpr, though.2
u/malkia Nov 24 '18
We try to use them (game tools code) more and more, but not sure about general acceptance from game teams (might be seen as a bit more than just a pointer, since it's two 64-bit numbers, rather than just one (and might see this as even too much, and keep it as short index to a table)).
9
4
u/imgarfield Nov 23 '18
I have participated in few projects from time to time since C++11 that were C++98. It is surprising how knowing C++11 make you write better C++98 code!
1
u/kalmoc Nov 22 '18
It's the code base actually incompatible with c++11 or are you just not allowed to use the functionality or do you have top deal with sich outdated tools?
2
3
2
u/xeveri Nov 23 '18
I actually prefer C++98, I find it easier to understand. My coding style might also be antiquated. My advice, instead of dreading it, try to enjoy yourself. It’s not that horrible!
1
u/F54280 Nov 26 '18
Why?
I mean, why are you stuck with C++98? Can't the codebase be slowly ported to C++17 ?
Like, first making sure it compiles and run with C++17, then start migrating the codebase, each time you have to implement something new. Unless this is pure maintenance with zero future, it is mandatory for whomever manages that codebase to make it evolve, or it will just die.
9
u/Pragmatician Nov 22 '18
Boo(st)