3 ms·
These kind of extremely simple loops are exactly the sort of thing where almost _any_ language can optimize things into levels of performance that approach hand
by onan_barbarian 14y ago
These kind of extremely simple loops are exactly the sort of thing where almost _any_ language can optimize things into levels of performance that approach hand-tuned asm (which itself isn't always the way to go for anything complex, but for simple codes, frequently still is).
If you actually wanted this code to go fast you'd use SSE, of course - and make a big mess of prefetches and intrinsics and so on. On a good day you might get the same result out of icc.
That being said, the guy is right - most of the time. A range of performance differences extending up to 2-5x between (say) Java and C++ (as shown on, say, the Programming Languages Shootout) shouldn't be decisive to most programmers who aren't writing code that's CPU bound.
Of course, while this argument can be made in favor of Java over C++ (not my personal taste, but still), it could be equally made for Python or Ruby over either. :-) This is especially true where the 'low performance' scripting language is just driving highly optimized math routines done over large chunks of data.