r/cpp • u/zero0_one1 • Jul 29 '19
Is auto-conversion of C++ code to a simpler, modern, and not backwards-compatible version possible?
I know that this kind of speculation doesn't go well here but could an automatic conversion of C/C++ code to a new language that's pretty close to modern C++ but with fixes (e.g. initialization syntax) and the bad parts removed (e.g. implicit conversions) ever be possible? A conversion to Rust or D would be harder. If it's possible, we could have a language with lesser cognitive load, able to use most legacy libraries and with the good and familiar features of C++ left intact. The performance might be somewhat worse - e.g. because memory initialization after allocations is desired. However, such a language wouldn't require as much work as completely new languages because it could just copy new features from C++.
4
u/SkoomaDentist Antimodern C++, Embedded, Audio Jul 29 '19
Consider the case of simple
float f2 = 1.3 * f1;The compiler cannot optimize that since1.3f * f1may differ from1.3 * f1(1.3 is not exactly representable in either float or double):