Overclock.net - An Overclocking Community - View Single Post - Python or PHP
Thread: Python or PHP
View Single Post
post #51 of (permalink) Old 07-31-2013, 08:06 PM
hajile
New to Overclock.net
 
hajile's Avatar
 
Join Date: Jun 2008
Location: United States
Posts: 1,593
Rep: 278 (Unique: 214)
Quote:
Originally Posted by poroboszcz View Post


Ok, so that may somewhat explain PHP's popularity for small to mid-sized projects, but it's also being used by most of the major websites like Facebook, Yahoo, Wordpress, Wikipedia, Apple, Flickr and many more. They clearly have the resources to use whatever technologies they want. Python, while being used by Google and Youtube, is still much less popular.

The problem with most of those projects is inertia. They started when PHP was the thing and most frameworks were poor quality or non-existent (in the case of yahoo, wikipedia and apple) or were started by people without the industry experience to know that better languages and frameworks (wordpress and facebook in your example).
 For these companies, rewriting millions of lines of code isn't possible (in the case of Facebook, it was easier to write several million lines of code for a new PHP interpreter than it was to recode in a better, faster language).

 

A note on hip-hop (Facebook's php VM). It's very close to an attempt at making V8 for PHP (last time I looked, which was a while ago). PHP's type coercion and lack of real data structures matches very closely to javascript and is the antithesis of good performance. Hip-hop attempts to map these pseudo-structures into real, computer-usable structures and then JIT optimizations. For example, "arrays" in PHP can have any combination of strings, integers, and floats. To anyone who understands low-level datatypes it is apparent both that these types are different and that one of them (strings) isn't actually a type (for those who don't know, they're arrays of characters where the characters are simply unsigned integers with a specific coded interpretation). In order for V8 (or hip-hop) to make any real arrays from the data, it must be of the same basic type which can then be converted to a real array. Since this limitation doesn't exist in PHP, the programmers must be taught that this is what must be done and then must ALWAYS adhere to this (additionally, they must ensure that the arrays NEVER accidentally add data of the wrong type). ASM.js is a Firefox example where even more freedom is given up and even more convention must be established for greater performance. There's no free lunch in programming.

hajile is offline