|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> wrote:
> http://metamatix.org/~ocaml/price-of-abstraction.html
> Very artificial benchmark to prove a point, methinks, but it's basically
> supporting what Warp says. :-)
C++ has indeed always been designed for number-crunching in mind, and
abstraction has always been added with the condition that it should not
have a significant hit to performance (or, at least, it should be possible
to create a compiler which can internally optimize away most of the overhead
caused by abstraction).
That's precisely one of the reasons why I like C++'s design (even though
I'm also aware of its flaws in other respects). Given my line of work, it
makes me appreciate it even more. (I have to create quite often programs
which are quite number-crunching-heavy, and C++ allows me to easily do that
while still having a good level of abstraction. In other words, I don't have
to resort to such hardware-level coding as would be necessary with C.)
Of course this doesn't mean that all possible C++ programs are always
automatically superfast. There are many situations where, if you don't know
what you are doing, you are going to end up with rather suboptimal solutions,
even if your algorithms are ok. (OTOH this is not really a problem exclusive
to C++, as C and many other "low-level" languages will have the exact same
problems.)
(Btw, about the C++ program in that webpage: I think that if he had told
gcc to generate SSE code rather than FPU code, he would have got the desired
rounding without having to resort to inline asm...)
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |