4 ms·
C++ lacks strong typing? I'm curious what the type system is missing to qualify. Or do you mean that the C-based escape hatches like casting pointers make the
by pavlov 3y ago
C++ lacks strong typing? I'm curious what the type system is missing to qualify.
Or do you mean that the C-based escape hatches like casting pointers make the type system inherently weak? You don't have to use them though...
- robertlagrant 3y agoYou don't have to make type errors either :-)
- AnimalMuppet 3y agoSure. But you have to deliberately use a cast; people rarely make deliberate type errors.
- JonChesterfield 3y agoC++ has chosen a special place in the hellscape of language design by allowing you to silence the compiler using casts, where almost anything you do with the resulting object is undefined behaviour no diagnostic required. Said UB is observationally indistinguishable from miscompilation under some toolchains under some optimisation controls. It also has various bolt on weirdness like const doesn't mean the thing won't be changed by some other pointer so you can't constant propagate based on it, unless it's written on the global, at which point attempts to mutate it anyway may succeed under the usual UB challenges. Maybe that's a "strong" type system, but you'd only define it like that if you started by taking C++ as axiomatically reasonable.