4 ms·
> buffer overflows and underflows are literally the No. 1 cause of security problems when working with C Why don't these ancient projects just move to C++ for
by TheMonarchist 5y ago
> buffer overflows and underflows are literally the No. 1 cause of security problems when working with C
Why don't these ancient projects just move to C++ for vectors and strings,
that do the buffer handling correctly for you?
Surely they can run a C++ compiler on any workstation these days?
- oriolid 5y agoThe usual and not completely unfounded reasons are - Dependency on huge C++ runtime library and possible ABI problems. Twice so for embedded targets. - Careless use of C++ features can lead to large binaries and unexpected runtime costs. - Lack of judgement and template metaprogramming or even plain polymorphism can lead to code that's really difficult to maintain. - Bad experience with pre-C++11 versions of the language or Windows C++ APIs.
- TheMonarchist 5y ago> Dependency on huge C++ runtime library and possible ABI problems. C++ runtime is hardly huge by modern standards, and the usual resolution to ABI issues is to provide C bindings. > Careless use of C++ -- Lack of judgement -- C doesn't make you immune to any of this. What are buffer overruns if not careless use of C? Edit: Considering that I suggested moving to C++ for vectors and strings, your bringing up of TMP and polymorphism sounds like a strawman argument.
- oriolid 5y agoThere are many modern things that run software, are connected to internet even if they shouldn't be and are tiny by modern standards. Just because something runs on servers doesn't mean that it doesn't run on processors that are just enough to run a minimal version of Linux kernel. And, have you ever worked with newbie C++ developers? When it comes to bad judgement, C++ gives a lot more rope and especially rope that's C developers are not familiar with.
- TheMonarchist 5y ago> Just because something runs on servers doesn't mean that it doesn't run on processors that are just enough to run a minimal version of Linux kernel. Maybe, but it seems unreasonable to hold the world back because of those systems. > When it comes to bad judgement, C++ gives a lot more rope and especially rope that's C developers are not familiar with. I think one could just ban most of that rope to junior devs. "Don't try to roll your own classes or templates, for getting them right requires both skill and discipline." Also common guidelines ban rope that isn't needed but for implementing the superior alternatives, that are usually found in the standard library. You can still program in a procedural way and use just the low hanging fruits of the STL, that was designed for correctness above all, for Alex Stepanov made it to demonstrate his ideas of generic programming: C++ just happened to make implementing it possible.
- oriolid 5y agoYou're trying to convince the wrong person. Linus Torvalds is the one you should start from.
- pdimitar 5y agoI'd guess a lot of C projects nowadays have very conservative management (most of which might even be actual programmers) and they could operate under "it works good enough, don't you dare touch it!".