Re: PHP console script vs C/C++/C#

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2008-04-19 at 13:08 +0200, Per Jessen wrote:
> Nathan Nobbe wrote:
> 
> > On Fri, Apr 18, 2008 at 11:25 AM, Nick Stinemates
> > <nick@xxxxxxxxxxxxxx> wrote:
> > 
> >> I don't think there was a single place where I said PHP was faster
> >> than C, nor did I imply it.
> > 
> >> > Depends. Shitty algorithms are shitty, regardless of language
> >> > implementation.
> > 
> > implies that the same algorithm in different languages will not
> > perform differently.  thats innacurate. 
> 
> No, that is actually a very accurate statement.  An algorithm will
> perform equally well regardless of the language chosen.  How well the
> actual implementation performs overall is a separate issue.  The
> performance or rather efficiency of an algorithm is usually expressed
> in the big-O notation, e.g.  O(n), O(log(n)) etc.  
> 
> A linear search is O(n), a quick sort is O(nlog(n)) (on average)  - both
> perform equally bad or equally well regardless of which language you
> choose to implement them in.
> 
> > the same algorithm w/o external dependencies, such as db calls, or
> > calls to remote systems will run faster in java / c / c++ and others
> > than it will in php. 
> 
> An algorithm doesn't have external dependencies - but implementations
> might. 

You are correct about asymptotic bounds on algorithms; however,
languages can still have a constant multiplier affect on an algorithm.
Consider a rendering algorithm in language L.x that when given an input
I.c takes 5 days to complete... now take language L.y tha happens to
incurr a constant multiplier penalty of 4. Now giving the input I.c to
L.y we find that it takes 20 days to complete. Same algorithm, same
asymptotic bound, but a significant difference in competitiveness.
Asymptotic bounds (Big Oh) are useful, but their applicability isn't
always universal. Some algorithms that are asymptotically inferior
actually perform better on small input sets than their asymptotic
superiors... I don't recall for certain, but bubblesort might be one
such example.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux