Essential differences between the operating 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
Cache, etc.), after processing, release all resources, called PHP
Interpretation of the Operating Mechanism
. This is not like a GC-based scripting language such as Python/Ruby. Python/Ruby initializes resources at the first startup and then
The request does not have to initialize the resource again.

The difference between these mechanisms is:

1. php is very difficult to cause serious memory leakage. If your code is poorly written, 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
Every time a request initializes the entire framework, the performance is very degraded. The result of using a very complicated PHP framework is that the overall performance is far removed from Ruby. That's why the PHP community has been around for so many years.
.

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.
These restrictions keep PHP in a relatively simple Web language. This is the reason why PHP became the first web programming language on the Internet, so it may not be good.

After being followed by PHP, the framework of rails actually leads PHP to a bad path, so it is better to say that rails is misleading php development. By the way
He has been using PHP before compiling Basecamp, and he has also written a PHP rapid development framework. After he switched to Ruby, he moved his PHP framework.
The framework 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
Looking at the running mechanism of PHP, we can see that PHP's complicated web development framework is not a bright path.

PS: This article is transferred from the javaeye forum.

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.