3 ms·
> There's just something about C++ that makes a lot of > people obsess over performance to a degree that doesn't > even affect the mindset of most C hackers.
by yk 14y ago
> There's just something about C++ that makes a lot of
> people obsess over performance to a degree that doesn't
> even affect the mindset of most C hackers.
Interesting observation. My first guess is that it is a lot easier in C++ to hide a stupid bottleneck, for example an object in a function call (which will call a copy constructor). So in the experience of a C++ dev, there are low hanging fruits. On the other hand in pure C it is a lot harder to hide this type of complexity and therefore C optimizations tend to be a lot more subtle.
- dfox 14y agoIt is also often pretty evident that C++ induces people to obsess over performance bottlenecks that were relevant on 80's hardware and while doing so introduce another (often more severe) bottlenecks relevant for modern CPU's. See for example C++ developers affinity for inline functions and templates expanding to huge amounts of inlined code, another common belief is that there is profound performance difference between virtual and non-virtual methods.
- NickPollard 14y agoDo you have evidence that there is not a profound performance difference between virtual and non-virtual methods? Virtual methods require two memory lookups (the vtable address, then the function address) and hence often two cache misses, compared to non-virtual methods which can be static addresses. If you've got a (common in games) loop like: for ( ..some list of 5000 objects.. ) { object.update(); } Then those cache misses will add up. That is my experience anyway, though I'll don't have statistics to back it up