Re:What If C++ Abandoned Backward Compatibility?
by snovv_crash on Sunday March 29, 2020 @02:51PM
(#22721494)
To be fair to the C++ version, you need to give as many guarantees from your code as C++ does from compiling. To me, in this case this is mainly the output formatting. Python won't tell you until runtime that you have a malformatted string, so add in some unit tests to make sure your string formatting won't crash, and you'll be at a similar number of lines of code as the C++ or Rust version.
[ Parent
| on HN ]
Re:What If C++ Abandoned Backward Compatibility?
by joshuamorton on Sunday March 29, 2020 @05:48PM
(#22723076)
> Python won't tell you until runtime that you have a malformatted string
Neither will C++, as far as I know, or do you mean that the compiler will validate the formatting of the string literal (python has linters that will validate this too!).
Hell, even with statically verifiable types, the python is shorter.
Re:What If C++ Abandoned Backward Compatibility?
by jcelerier on Monday March 30, 2020 @03:48AM
(#22726026)
> Neither will C++, as far as I know, or do you mean that the compiler will validate the formatting of the string literal.
With iostreams there are no format strings so there is nothing to validate. Libraries such as https://github.com/fmtlib/fmt are allow to do compile-time parsing of the string though.