Chad Perrin wrote:
On Fri, Jul 28, 2006 at 06:39:12PM +0200, Jens Frank wrote:
[...]
We actually do this. The diff engine exists as a PHP plugin written in C (or C++, which is nearly the same).
. . . aside from the fact that it often exhibits an at least arithmetic increase in execution time as compared with straight C.
Sorry, minor, largely pointless quibble. There's a bit of a language execution time debate going on somewhere else that has absorbed me recently. The subject is sorta stuck in my head at the moment.
Through my aborted PhD, I have a couple of years experience writing highly efficient C++ programs. The aforementioned wikidiff2 extension does no memory allocation during the computational phase, instead of substring operations it passes around start and end iterators. There are no virtual functions. The only remaining performance hit is the need to pass "this" pointers and dereference them, although that's a feature of structured C programming as well, and provides a great deal of flexibility. The performance penalty can be controlled through the extensive use of inline functions.
There are certain programming styles which are popular in C++, which do produce a significant performance hit. That's not an issue when your main goal is to produce high-performance code -- in that case you can easily avoid the pitfalls, and the remaining optimisation issues are largely the same as in C.
-- Tim Starling