4 ms·
This seems to mostly be an argument that implicit conversions are harmful. I think that's generally agreed to be true, most newer programming languages require
by thurn 4y ago
This seems to mostly be an argument that implicit conversions are harmful. I think that's generally agreed to be true, most newer programming languages require all type conversions to be explicit.
- foxhill 4y agoindeed - implicit conversions are the underlying cause of bugs in most of the issues i get tasked with fixing. i think it would be sensible to add unsigned, and disallow implicit conversion (definitely at least narrowing conversions). but java is a distant world to me.
- curiousmindz 4y agoI would think that "lossless" implicit conversion are ok. Right? For example, implicit conversion from a 32bit signed integer into a 64bit signed integer.
- Gibbon1 4y agoI write a lot of firmware in C. I find it's implicit conversions to be broken and tediously annoying at this point. I think it's impossible problem because you can't capture semantics of what the programmer is trying to do without extra input. I suspect part of the problem is conversions between types is complex and annoying to implement in a compiled language. With the added bonus that's only something the end users care about not the compiler writer. Hence in the wild this stuff tends to be broken or inadequate. Like in C it's way broken. In Java it's way inadequate.
- account42 4y agoThankfully, modern C and C++ compilers have -Wconversion or equivalent flags so you can require explicit conversions.