Essential differences between the runtime mechanism of PHP and Python/Ruby

Source: Internet
Author: User

There is an essential difference between the runtime mechanism of PHP and Python/RUBY: PhP initializes all resources after each HTTP Request (such as creating database links, loading system libraries, and creating caches ), after processing, release all resources. This is not like a GC script language such as Python/Ruby. Python/Ruby initializes resources at the first startup, and subsequent requests do not have to initialize resources again.

The difference between these mechanisms is:

1. php is very difficult to cause serious memory leakage.CodeThe write speed is poor. Every request is executed and all resources are released. Python/Ruby depends on GC to recycle memory. Therefore, a slight carelessness may cause memory leakage that cannot be released by GC.

2. php initializes resources for each request. This overhead is very high. Therefore, although the PHP parser itself runs extremely fast, once a complicated PHP framework is used, the performance of the entire framework needs to be initialized during each request is greatly reduced, the result of using a complicated PHP framework is that Ruby is far away from the overall performance. This is why PHPCommunityOne of the reasons why the framework has not been used for so many years is that.

3. Because PHP, a mechanism for initializing resources for each request, also makes it quite difficult for PHP to add advanced features for cross-request. This is a huge limitation of PHP itself, but on the other hand, this restriction keeps PHP in a relatively simple Web language, which makes PHP the first Web language on the Internet.Programming LanguageTherefore, it may not be good.

In short, the difference between PHP and Ruby is still very large. It is not suitable for comparison. In fact, we should compare ruby and python.

therefore, I think that the Framework practice like rails is followed by PHP, which actually leads PHP to an evil path. So it is better to say that rails is misleading php development. By the way, DHH has been using PHP before writing Basecamp, and he has also written a PHP rapid development framework. After he switched to Ruby, I have also transplanted my own PHP framework, which is actually the original prototype of rails. So why didn't DHH directly develop rails based on PHP? Do I have to use Ruby to publish rails? You can see the operating mechanism of PHP. It is not a bright path for PHP to develop complex web development frameworks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.