4 ms·
This is the reason that alternative general purpose languages are popular - just because you can write it in C++ doesn't mean you should :)
by cesaref 6y ago
This is the reason that alternative general purpose languages are popular - just because you can write it in C++ doesn't mean you should :)
- Someone 6y agoBut it also doesn’t mean you should not. Sometimes, the technique of returning a promise (“here’s something that can be converted to what you asked for, even though you didn’t tell yet exactly what you want”) is very useful. A simple example is multiply-add. For your own types, you can have the compiler translate a = b * c + d; into a = multiply_add(b, c, d); that means you can use familiar notation and yet use faster/more accurate composite functions. Stroustrup, in “the C++ Programming Language”, states he has seen a speed up of a factor of 30 using this ‘trick’ on matrix code. He also advices against going over the top on it, though, so he agrees with “you can doesn’t imply you should”.
- cesaref 6y agoYeah, agreed, there's a time and a place for this stuff. The art of programming is knowing when to break the rules, similar to most artistic pursuits.