On Sat, Apr 19, 2008 at 7:08 AM, Per Jessen <per@xxxxxxxxxxxx> 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. umm, so whats going on here is the implicit component of the statement that incorporates relative or absolute performance. in terms of relative performance the statement is accurate; in terms of absolute performance, its quite inaccurate. > 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. right, relative to the performance of said language. > 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. algorithms can have external dependencies. imagine a soap call in php. imagine the call running on a windows / bsd / linux system. imagine the call running on different networks. imagine the algorithm running on a machine w/ lots of other apps running on it concurrently leaving resources at a minimum and again it running on a powerful system dedicated to the php-enabled web server. although the algorithm will run unaltered on all these platforms the performance may, and likely will vary due to the underlying network stack, OS, bandwidth of the Internet connection from and to the service provider, etc. so anyway; what you are talking about here is relative performance. the same algorithm will have the same complexity (relative bounds) despite the language its implemented in. however, in terms of absolute performance languages will have different performances. the main reason php is slower than c is because its interpreted, duh. thats why a O(n) algorithm in php will run slower than the same O(n) algorithm in c. thats what the great computer language shootout is all about. maybe you should take a look ;) for example heres c vs. php; http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=gcc&lang2=php its quite clear that c outperforms php on every algorithm. you can click the links on each test to see the implementation of each algorithm in a given language. and if you think you can improve the performance of a given algorithm in a given language, then you can submit your code and see if it actually runs faster. thats what the game part is :D and actually as a complete side note c++ is actually topping c these days. -nathan