The difference between PHP and Python Ruby's operating mechanism

Source: Internet
Author: User
Tags php framework

There is an essential difference between PHP and Python/ruby: PHP is every time the HTTP request comes in, initialize all the resources (such as creating a database link, loading the System class library, creating a cache, etc.), processing finished, releasing all resources, this is not like python/ A GC-like scripting language, such as Ruby, Python/ruby is the initial startup of a resource, and subsequent requests do not have to initialize the resource again.


The difference between this mechanism is that:


1, php extremely difficult to have a serious memory leak problem, whatever your code to write more rotten, anyway, each request once executed, all the resources to release the light. While Python/ruby relies on GC to reclaim memory, there is a slight loss of memory leakage that GC cannot release.


2, PHP every request to initialize resources, this overhead is very large. So although the PHP parser itself is very fast, but once the complex PHP framework, because the need to initialize the entire framework each time the request, performance degradation is very strong, you use a very complex PHP framework result is the overall performance by Ruby far away. This is one of the reasons why the PHP community is so much coming and not inclined to use the framework.


3, because PHP this per-request initialization of resources mechanism, also caused the PHP add cross-request advanced features is quite difficult, this is a great limitation of PHP itself, but on the other hand, it is this restriction makes PHP always in a relatively simple web language, And that is why PHP is the first web programming language in the Internet, so it may not be a bad idea.


In short, the difference between PHP and Ruby is very large, not suitable for comparison, in fact, it should be compared to Ruby and Python.


So I think that the framework of the rails approach to PHP after the follow-up, in fact, the PHP with the astray, so that is more than the development of rails misleading PHP. By the way: DHH before writing Basecamp, has been PHP, and also wrote a rapid development of PHP framework, he switched to Ruby after the original PHP framework was also transplanted, the framework is actually the original rails prototype. So why didn't dhh just do rails based on PHP? Do you want to use Ruby to publish rails instead? You see PHP as a mechanism to understand that PHP is a complex web development framework is not a bright road.


The difference between PHP and Python Ruby's operating mechanism

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.