Home > Backend Development > PHP Tutorial > What is the difference between PHP framework and Ruby/Python framework_PHP tutorial

What is the difference between PHP framework and Ruby/Python framework_PHP tutorial

WBOY
Release: 2016-07-13 10:33:51
Original
929 people have browsed it

PHP: After each HTTP request comes, initialize all resources (such as creating database links, loading system class libraries, creating caches, etc.), and release all resources after processing.

Python/Ruby: Initialize resources when starting for the first time, and subsequent requests do not need to initialize resources again.

The difference in mechanism between PHP and Python/Ruby is:

  1. It is extremely difficult for PHP to have serious memory leaks. No matter how bad your code is, all resources will be released as soon as each request is executed. Python/Ruby needs to rely on GC to reclaim memory, so if you are not careful, there will still be a memory leak problem that cannot be released by GC.
  2. PHP must initialize resources for every request, which is very expensive. So although the PHP parser itself runs extremely fast, once a complex PHP framework is used, the entire framework needs to be initialized every time a request is made, and the performance drops dramatically. The result of using a very complex PHP framework It's just that the overall performance is far behind Ruby. This is one of the reasons why the PHP community has not been very inclined to use frameworks for so many years.
  3. Due to PHP’s mechanism of initializing resources per request, it is also very difficult for PHP to add advanced cross-request features. This is a big limitation of PHP itself, but conversely, it is this limitation that makes PHP always Keep it to a relatively simple web language, and this is the reason why PHP has become the first web programming language on the Internet, so it is not necessarily bad.

In short, the differences between PHP and Ruby are still very big, and it is not suitable to compare them together. In fact, the comparison should be between Ruby and Python.

So I think that after PHP followed the trend of Rails's framework approach, it actually led PHP down a wrong path, so it is better to say that Rails is misleading the development of PHP. By the way: DHH used PHP before writing basecamp, and he also wrote a rapid development framework for PHP. After he switched to ruby, he also transplanted the PHP framework he wrote. This framework is actually The above is the original prototype of Rails. So why didn't DHH make Rails directly based on PHP? Did it have to switch to ruby ​​before releasing rails? If you look at the operating mechanism of PHP, you will know that it is not a bright path for PHP to build a complex web development framework.

Whether to choose PHP or PHP Framework should be based on whether it meets your application: Determine in advance whether the performance indicators of the framework meet your application. During testing, you may have to switch on and off various caching technologies, and you may have to Mock up your application design architecture, and then decide on appropriate and appropriate framework adoption. Some people are used to comparing which language or framework is good or bad apart from the application. I think this often makes things reach a deadlock. Without facing the problem, there is no way to talk about the solution to the problem. Technical solutions are all aimed at the development of a certain application. Isn't it?

Rasmus, the father of PHP, also made it clear that he does not like PHP framework. (Rasmus: "I don't like frameworks. PHP frameworks are ridiculous slow".) This is what Rasmus mentioned in a speech: Simple is Hard .

For a language like PHP, where "each request is a complete life cycle", it pursues simplicity and anti-framework. Large-scale PHP Internet applications will use Java/C++ to write middleware in the background to complete complex business logic processing. It is not the responsibility of PHP to make PHP into a framework. (Drupal was mentioned, but it is positioned as a product rather than a framework, so I won’t repeat it here.)

From a product perspective, Python’s CMS plone is the best, with very powerful functions, easy secondary development, and no performance issues with Drupal. Shanghai Runpu has used plone to develop several commercial projects, including some systems like Shanghai Airlines.

But the problem is: even in the Python community, the highly productized zope/plone is gradually no longer mainstream, and the mainstream technology has gone to django. So I think it's hard to say how promising something like drupal, which is anti-PHP, can be.

When designing frameworks, you should pay attention to development costs. Integration is a good thing, but the waste of resources and development inconvenience caused by too much integration are the reasons why some frameworks even lead to death during the development process. Simplify the framework and match it with plug-ins. The development method is the real productization of the framework. The beauty of simplicity is beauty, but many framework designers also realize that it is really difficult to make the framework simple.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/752382.htmlTechArticlePHP: After each HTTP request comes, initialize all resources (such as creating database links, loading system class libraries, creating cache, etc.), after processing is completed, all resources are released. Python/...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template