Wondering about PEAR standards
As we know, PHP is a large web based programming language. One thing I have understood while working on this beautiful language for a few years now, is, PHP is quite a stable architechture. PHP has this excellent advantage of being a server side language developed by a community of thousands of developers around the world. It is a great thing that PHP is run on a client server architechture, and that it can cater to thousands of requests simultaneously and taking a very little toll on the server. But with its biggest advantage is also its biggest drawback. With the traffic growing on the internet, the need for fast loading scripts has become a necessity. It has become really important for your script to run fast, and run thousands of instance of the same script simultaneously. So, what does this mean?
Well consider this example
if ($name == “John Doe”) {
$age = 24;
}
and now this one
if ($name == “John Doe”) {
$age = 24;
}
In all respects, you would find the 2 codes very similar. But there is a difference! The second code has a tab instead of 4 spaces here. So, over all, there is a saving of 3 bytes as far as the indenting is concerned. So, how does it matter? Well its just 3 bytes that you save. This is a common approach of any programmer. Well but consider the architecture you are working on! Consider your script has 15 such if loops. So,
15 loops x 3 bytes = 45 bytes of over load.
Say your site has 100,000 visitors (many sites have such scenarios, though it is a dream!), it means
45 x 100,000 = 4,500,000 bytes (Almost 4.5 GB!) of extra memory required.
So, does this really make sense. I agree that code redability is a factor that is very important, but we must not forget that PHP scripts are meant to run on an architechture, where it has to be very precise as far as the memory used is concerned. I have been readign through the PEAR coding standards. It has been a fascinating thing, but the reading has sparked a thought in my mind. Just understand, an extra byte of memory usage, in long run can mean a hell lot! I agree that we should have a standard in any thing, but the standard should be such that it helps the development, but not at the cost of the running! Hope this has been an intriguing thing for you! See ya soon! Adios!
i found you by link from the Directory Listing Script from Ash.. Nice to read your blog ^.^