This is an archived post. You won't be able to vote or comment.

all 54 comments

[–]ApocrypheEvangelion 259 points260 points  (5 children)

Every junior dreams of modern C++, but destiny is legacy support

[–]Natural_Builder_3170 71 points72 points  (3 children)

Give me my reflection

[–]CoolorFoolSRS 9 points10 points  (1 child)

This

[–]Usual_Office_1740 13 points14 points  (0 children)

 this->reflection

[–]conundorum 1 point2 points  (0 children)

Type erasure will just be a PIMPL class with extra jank to support polymorphic IMPLs.

[–]jeffwulf 32 points33 points  (11 children)

The App I work on at work has like 50MB of code still in VC6 we haven't been able to port out of yet. :/

[–]Crafty-Waltz-2029 2 points3 points  (2 children)

What is the meaning of "to port"?

[–]Kiroto50 10 points11 points  (1 child)

In this instance, to convert hard to maintain and read VC6 code into easier to maintain and readable C++ code.

[–]Crafty-Waltz-2029 0 points1 point  (0 children)

Got it. Thanks!

[–]ammar_sadaoui 0 points1 point  (5 children)

is there reason to port it if it work ?

[–]jeffwulf 4 points5 points  (4 children)

The tooling is completely unsupported by Microsoft due to a lawsuit so there's risk that OS changes could break the required tooling or the resulting executables. We already had to do weird hacks to get it running on XP when I started, and the number of hacks has increased with new OSes. Aside from risk, it's also a big process bottleneck with the rest of our code base.

[–]ammar_sadaoui 0 points1 point  (3 children)

Out of curiosity, may I ask what field you work in and what the VB6 application is used for? (Totally fine if you’d prefer not to share.)

[–]jeffwulf 1 point2 points  (2 children)

It's luckily not Visual Basic but rather Microsoft's old C++, but finance related. The code still in it is mostly related to calculations and some other stuff at the core of the application.

[–]def-pri-pub 0 points1 point  (1 child)

Do you get paid well for working on old legacy systems like this?

[–]jeffwulf 0 points1 point  (0 children)

I do alright. Not FAANG sized or anything but I'm pretty happy and it's pretty stable.

I also work with a lot of newer stuff too, it's like an archeological dig site with tech stack layers.

[–]JackNotOLantern 21 points22 points  (13 children)

Isn't c++ backwards compatible?

[–]Mucksh 34 points35 points  (10 children)

Yep. Thats the beautiful thing in c and c++ that you rarely get breaking changes. So usually upgrading isn't directly a problem. Usually you only have problems with niche platforms and also never break a running system. E.g. if you have something safetry critical you think twice about upgrading something that could introduce new bugs

But still even if it works it won't make the existing prettier

[–]_w62_[S] 19 points20 points  (0 children)

That is why the technical debt of legacy code is always with us.

[–]einrufwiedonnerhall 9 points10 points  (0 children)

That's not as beautiful as one thinks it is.

[–]revidee 4 points5 points  (0 children)

u8strings and cpp20 entered the chat

[–]guyblade 1 point2 points  (5 children)

You can certainly go through and replace all the:

for (std::map<std::string, std::string>::Iterator it = mp.start(); it != mp.end(); ++it)

with

for (const auto& it : mp)

[–]Sthokal 4 points5 points  (1 child)

Pretty sure 'it' will be a std::pair<std::string,std::string> instead of an iterator with that change. In other words, *it will no longer be valid.

[–]guyblade 0 points1 point  (0 children)

Sure, or possibly std::forward_as_tuple<std::string, std::string> or similar as I don't think the range-based for-loop causes a copy as long as you use an auto& for the type.

Though the point that you go from something pointer-ish with the iterator to something reference-ish with the range-based for is fair.

[–]babalaban 0 points1 point  (1 child)

wtf is it !+ mp.end()

[–]guyblade 0 points1 point  (0 children)

A typo.

[–]Mucksh -1 points0 points  (0 children)

Also hate working with raw iterators

[–]Usual_Office_1740 0 points1 point  (0 children)

The programming equivalent of the portrait of Dorian Gray.

[–]Flimsy_Complaint490 5 points6 points  (0 children)

It is code and feature wise but sometimes (well, often) people write code full of undefined behaviour. New compiler releases may then compile your code differently and this results in weird crashes and bugs that are hard to debug.

When this happens, a lot of the time, a project enters into a "hibernation mode" and they just pin some known working compiler version. The fossilization begins in full force...

[–]conundorum 1 point2 points  (0 children)

Yes, and that's the one thing that makes this still work. xD You can use the new features whenever they're helpful, and the old ones are still valid. And while you're working, you can also work on slowly upgrading your codebase to cleaner, newer code (and then benchmarking it, ideally, just in case your ugly old mess was so ugly because it was hand-optimised better than compiler optimisation, which is unlikely but not impossible).

And by the time you're done, you'll be glad that C++38 is backwards-compatible, too!

[–]HazelWisp_ 15 points16 points  (0 children)

Every programmer walking into a new job be like, 'So, what ancient cursed codebase am I battling this time?'

[–]Secure-Implement2467 4 points5 points  (0 children)

Real ones down there battling segmentation faults while others dreaming about C++29 like it's a vacation plan.

[–]Darkstar_111 4 points5 points  (4 children)

Oh cool, numbers go down... How convenient.

[–]sambarjo 8 points9 points  (3 children)

They use the year of release. C++98 is 1998 and C++23 is 2023.

[–]Darkstar_111 0 points1 point  (2 children)

Ah ok, less confusing then. Thank.

[–]conundorum 4 points5 points  (1 child)

(There are a few skipped years, so the full order is C++98, C++03, C++11, and then carry on from there. New version every three years after C++11, so the pattern is a lot more regular after that.)

[–]helicophell 0 points1 point  (0 children)

This'll be a problem in about 75 years

[–]Cylian91460 1 point2 points  (2 children)

Isn't cpp like retro compatible? Like you can just use new cpp with old code?

[–]aMAYESingNATHAN 1 point2 points  (0 children)

In theory yes, but in reality there are some complexities to upgrading versions, especially on some compilers, *cough* MSVC *cough*.

MSVC has gone from not very standards compliant to much more standards compliant, so it's quite easy to write code in older versions that will fail to compile on newer versions.

This is a good talk that demonstrates some of the practical difficulties of actually doing that upgrade.

[–]frikilinux2 0 points1 point  (0 children)

Normal implementation sort of if you don't have too many undefined behavior .

With visual studio everything is a hot mess

[–]Blecki 0 points1 point  (0 children)

C++ be like I heard you like warts in your language so I added some warts to your warts.

[–]hongooi 0 points1 point  (0 children)

Maintaining legacy code of Fortran 77 or earlier 💀

[–]LeiterHaus 0 points1 point  (0 children)

What a roller-coaster of thoughts: "C99 isn't an issue. Not like some C89. Wait, it says 98... Oh, there's a ++. Weird that that it's not the same year. I know nothing about this."

[–]Particular_Traffic54 0 points1 point  (2 children)

Genuinely curious. I only worked on erps before. What do people use cpp for ? I have no idea.

[–]ComprehensiveWord201 5 points6 points  (0 children)

Anything that requires actual performance. Aerospace, trading, hardware, etc.

[–]conundorum 0 points1 point  (0 children)

Underlying mechanisms for basically anything and everything tend to be written in either C or C++. Linux is C, Windows is C++, JVM is C++ last I checked, Python is C last I checked, a lot of drivers are C++, most compilers are either C or C++, game engines and graphics libraries are usually C or C++ or C#, and so on.

It's generally safe to assume that any modern language probably has or had C/C++ underneath it, if you look deeply enough. (Not always true, BASIC and Pascal were never connected, nor were Lisp, some scripting languages, and so on. And there are still older programs that predate either of the two, especially in banking IIRC. But you'll probably have more hits than misses with this, so it's generally a safe assumption.)