Re:C++ on Embedded Systems
by KKKKkkkk1 on Tuesday February 21, 2017 @12:00AM
(#13693404)
There is a tax that you pay by introducing C++, and that is chasing down things like inadvertent copy constructor/assignment operator calls, automatic memory allocs, and heavy-weight operator overloads, all of which are an inexhaustible source of untraceable performance bugs. In other words, C++ as a language is right at the sweet spot where it does not guarantee safety, while at the same time making performance unpredictable.
[ Parent
| on HN ]
I never understood why people argue that operator overload is a bad thing. In a language that doesn't support it, you're going to have a function "T add(T, T)" which is pretty much the same, and can do anything. Overloading "T operator+(T, T)" is mostly syntactic sugar.
> inadvertent copy constructor/assignment operator calls
This is much less of a problem (and much more controllable!) now that we have move semantics.
> automatic memory allocs
It's hard to accidentally allocate memory if you don't have a system allocator hooked up.
> heavy-weight operator overloads
No more heavy-weight than a standard function call, and usually inlined at that.