3 ms·
Moving a large C++ codebase to C# has helped us a lot. The legacy code had memory leaks that caused random crashes. It was also long to build, and wouldn't buil
by d--b 9y ago
Moving a large C++ codebase to C# has helped us a lot. The legacy code had memory leaks that caused random crashes. It was also long to build, and wouldn't build in 64 bit. The C# version seemlessly let us run the code in either 32 or 64 bit. C# is also a much more readable language, and has a lot of great tools for refactoring and profiling. And C#'s performance is almost as good as C++ in many areas, so all in all it's been a great move.
- amelius 9y agoI'm guessing that moving from C++ to C++ (i.e., a rewrite in the same language) would also have helped a lot.
- hvidgaard 9y agoThere is a lot of safety features in C# that are not present in C++, so a rewrite in C++ would probably have helped. However the same class of errors that was a problem in the old codebase are still present.
- d--b 9y agoActually that particular C++ was very well written. It had been written by a single very disciplined person over 3 years, following a lot of very strict conventions. So, no it was not really messy in there. But it was big and memory leaks are hard to find. The main problem is that there was some low level funky stuff happening that we didn't have a good grip on. The guy who wrote it thought it would be great to optimize the code in some ways, but clearly overdid it.
- amelius 9y ago> The guy who wrote it thought it would be great to optimize the code in some ways, but clearly overdid it. But then I suppose a rewrite would undo those optimizations and solve the problems.
- d--b 9y agoWell, that is as long as we don't introduce other leaks in the rewrite. Our team is mostly made of mathematicians and business-focused engineers, so for us C++ was somewhat inappropriate. My point is trading a little bit of performance for a lot of clarity and safety was a good move.
- deleted 9y ago[deleted]
- koyote 9y agoWe did/are doing exactly the same thing with great results in the same areas! > The guy who wrote it thought it would be great to optimize the code in some ways, but clearly overdid it. I feel that C++ is a language that entices decent developers to try and 'optimise'. We have the same issue in some of our lower level stuff including pointer arithmetic and other 'optimisations' that might have saved a couple of kb/mb of memory 20 years ago when the code was written but today only makes the code difficult to read and to modify.
- WalterGR 9y agoI'm guessing that moving from C++ to C++ (i.e., a rewrite in the same language) would also have helped a lot. I'd guess that a same-language rewrite would have helped a lot for any non-trivial project mentioned in this Ask HN.