Sujet : Re: C and C++, promotion, stabilization, migration (was: Re: New VSI post on Youtube)
De : seaohveh (at) *nospam* hoffmanlabs.invalid (Stephen Hoffman)
Groupes : comp.os.vmsDate : 19. Aug 2024, 21:05:59
Autres entêtes
Organisation : HoffmanLabs LLC
Message-ID : <va08j7$30gmu$1@dont-email.me>
References : 1 2
User-Agent : Unison/2.2
On 2024-08-19 18:56:53 +0000, chrisq said:
On 8/15/24 13:34, Simon Clubley wrote:
That works great until you need to interface to the OS unfortunately.
BTW, I've been writing my own code with explicit sizing for many years.
To extend this, I also know the difference between signed and unsigned variables and I have a default-unsigned approach unless I absolutely _need_ a signed variable.
Unfortunately, a lot of the material out there doesn't seem to understand that designing a program is about modelling a real-world problem and that it isn't OK to just use a signed integer to store an unsigned value.
Unfortunately a lot of apps are implemented in C or C++ when they probably shouldn't, too.
Package management is another area where C, C++, and OpenVMS itself all get into trouble.
Same for concurrency, strings, and various other topics.
Absolutely, must have come from an assembler background, where the use of signed branches and arithmetic, can get you into serious trouble.
The standard C library, of course, tends to use signed variables for everything, a gross error that has never been fixed...
The C compiler promotes unsigned to signed, as well. And this promotion "fun" includes uint*_t variables quite possibly getting promoted to signed.
q.v.: C11 6.3.1.1: "If an int can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions."
Also q.v.: C11 6.3.18: "Usual arithmetic conversions"
strings and character encoding are more "fun":
https://thephd.dev/the-c-c++-rust-string-text-encoding-api-landscapeapropos of nothing, OpenVMS has a whole pile of tooling to avoid changing constants:
https://devblogs.microsoft.com/cppblog/how-we-used-cpp20-to-eliminate-an-entire-class-of-runtime-bugs/ Porting is hard:
https://github.com/ziglang/zig/pull/13560 (And sometimes creative.)
And if you're coexisting with C and C++ (incrementally or otherwise):
https://kristoff.it/blog/maintain-it-with-zig/And if you're deep into C++, the following might interest (Apache 2.0):
https://github.com/abseil/abseil-cppSwift as a replacement for issues with C and C++ (and deterministic testing, and cross-language optimization):
https://www.youtube.com/watch?v=ZQc9-seU-5kThis won't be happening anytime soon if ever of course, as VSI has beyond more than enough work in their pending queue.
-- Pure Personal Opinion | HoffmanLabs LLC