19

Not about favorite language but about why PHP is not my favorite language.

I recently launched a web shop built on Prestashop. I found that some product pages are so god damn slow, like taking 50 fuckin' seconds to load. So I started investigating and analyzing the problem. Turns out that for some products we have so many different combinations that it results in a cartesian product totalling about 75K of unique combinations.

Prestashop did a real bad job coding the product controller because for every combination they fetch additional data. So that results in 75K queries being executed for just 1 product detail page. Crazy, even more when you know that the query that loads all these combinations, before iterating through them, takes 7 fuckin' seconds to execute on my dev machine which is a very very fast high end machine.

That said I analyzed the query and now I broke the query down into 3 smaller queries that execute in a much faster 400 ms (in total!) fetching the exact same data.

So what does this have to do with PHP? As PHP is also OO why the fuck would you always put stuff in these god damn associative arrays, that in turn contain associative arrays that contain more arrays containing even more arrays of arrays.

Yes I could do the same in C# and other languages as well but I have never ever encountered that in other languages but always seem to find this in PHP. That's why I hate PHP. Not because of the language but all those fucking retarded assholes putting everything in arrays. Nothing OO about that.

Comments
  • 5
    I'm a php developer but I like your rant. I agree that php's greatest stigma is that it has a huge community, but most of those developers don't think about what might go on under the hood. What impact certain choices can have. What design patterns to use, and what anti patterns to avoid. I always think that it's the author that defines the beauty of a language, not the language itself. Too bad there are so much bad authors in the php community. What also isn't helping is that much, large php driven projects (wordpress, Magento 1) are so badly programmed, that it defines the overall image of what php is and can do.
  • 0
    @kanduvisla thanks for your reply. I do some PHP work now and then and I do like to do things right, so when I code PHP, I may lack some PHP knowledge here and there but I'll always do things OO, unless the rest of the codebase is such a mess that it would diverge too much from the rest. Honestly it makes me feel sad to see how many PHP devs make such a mess out if it because it can be done in a proper way and then PHP is as good as any other language if it fits your needs.
Add Comment