C++ vs Lisp

Dee Girl deegirl at noreply.com
Sun May 18 07:44:12 PDT 2008


janderson Wrote:
> You'd have to get Walters for the final word however I can't see why the 
> compiler would generate another function for fastgood other then to 
> speed up compiler performance for duplicate templates.  If your worried 
> about a long fastgood function being inlined, then I suggest that that 
> template has been made to long.  Also pre-premature optimisation is not 
> a good thing.  Do what works for you then optimize later.

It is not about inlining. I think this is confusion again, same made in discussion with title safer casts. It is about template instantiation. Which can affect inlining but is very different thing.

> In my experience things like using delegates over templates rarely 
> matter.  That is because the size of the rest of the code dwarfs the 
> runtime spent there.  People will run benchmarks on the specific piece 
> of code and get some impressive benchmarks but they don't try running it 
> in real world code. 

If you see 4 times faster in a function then all program will not be 4 times faster. Of course. But many programs have little core operation. For example wc has at its core reading file, character comparison and loop. If core has 4 times slower function maybe the cost is much.

> Many times optimisation works against 
> maintainability and flexibility, yet having highly flexible code is the 
> key to being able to focus optimizations on the code that matters.

General observation is correct. But phobos algorithm and compose are good but not inflexible. 

> Having said that, its nice to have these optimizations in the standard 
> libraries because I figure that with 1000's of users, someones/everyones 
> code is going to benefit from it.
> It is also true that heavy use of templates can slow down code speed 
> just as heavy use of delegates.  I think its up to the engineer to make 
> the correct judgment call, particularly after they've run the profiler.

If you have many template instantiation code is big. Big makes code slow because cache effect. But with template you can limit size because you can write slowbad to use fastgood. Then only one fastgood is instantiated. But if you start with slowbad is nothing you can do. Thank you, Dee Girl



More information about the Digitalmars-d mailing list