Table of Contents
Reply content:
Home Backend Development PHP Tutorial Why hasn't PHP replaced Python?

Why hasn't PHP replaced Python?

Jul 20, 2016 pm 12:01 PM
cli gtk php python web

PHP can also run in cli mode, and there are also many libraries and extensions. Web development is not a problem. Desktop applications can also be developed with libraries such as gtk. Why hasn't it replaced Python? Their syntax also pursues simplicity and quick start. Use development Efficiency is replaced by operating efficiency. Many places are similar. Moreover, various training institutions now teach PHP more than Python. I always feel that there are many more people using PHP than Python.

Reply content:

I don't see how similar they are.

PHP is weakly typed; Python is strongly typed.

PHP is mainly for Web; Python is mainly for general purpose.

PHP had confusing naming and incomplete feature support (Unicode, namespace) in its early days; Python is much better than it.

PHP extensions focused on web development. Are there any reptiles? Is there any scientific calculation? Is there big data? Even process control cannot be done well.

PHP syntax is becoming more and more complex (like C++, features are constantly being added); Python is relatively clean.

PHP doesn’t even have a decent interactive shell (I found one, written in Python); Python not only supports interactive shells natively, but also has various useful ones such as ipython, bpython, ptpython, etc. things, as well as notebooks focusing on data analysis.

PHP couldn’t even handle SQL escaping before, right? When I first met Python, it was already DB API 2.0. If used correctly, there is no need to worry about SQL injection.

PHP is like a bunch of dollars; Python is more like ordinary text.

....

PS: Why only talk about the shortcomings of PHP and the advantages of Python? Because my answer is "Why hasn't PHP replaced Python", not "Why hasn't Python replaced PHP"! PHP has never thought of replacing Python. If someone shouts this, it is probably the training institution who wantonly exaggerates PHP to fool you!

I used to try to use PHP to solve all problems, such as writing daemons, packaging desktop software, writing cli tools, etc., but it turned out to be in vain. PHP is not suitable for doing these at all. It’s not that it can’t be done. It is a Turing-equivalent language, but other languages ​​can do better.

When writing daemons in PHP, it is easy to encounter situations where the CPU will surge to 100%. Later, I also encountered people who wrote daemons in PHP and also surged to 100%, and they even shocked themselves. Possible causes are not adding a timeout setting (stream_set_timeout), not destroying the expanding variables in time, opening a new database connection without closing it every time, etc.

Later on, I never used PHP to write daemons again, because the script feature of PHP is to automatically release all resources after each request is completed, so I didn’t think about resource release, timeout and other issues when writing. I got used to it. This method cannot be used to write daemons at all, nor is it suitable for writing desktop software. Strictly speaking, this is not a problem with PHP itself, but PHP will spoil you and abuse resources without releasing them.

In addition, I am confused about the fact that php has an ugly shell, php -a, but it only needs to be echoed every time to come out. You can also run php code directly, such as: php -r 'echo time(); ', -r means run, there is no need to add
The only thing I know about PHP is the phrase “the best language”, but for Python I hear mostly about “suitable for novices” and “suitable for mathematical research” "Wait, first of all the reputation will go up.

Also, where can you find so many underwear in PHP using PHP? PHP is mainly on the web, and most web sites are PHP.
Python is mainly based on the command line, so you can see that many operation and maintenance tools are written in Python. Things in the world are not substitutes for each other or compete with each other. Each language has its own advantages and irreplaceable value. PHP and JAVA can be combined to develop enterprise-level projects, so what reason is there to exclude the command line? What about Python? The right one is the best. It's like asking who to replace mall.
It’s not about who replaces the other, but each has its own space for survival.
php was once considered a sunset language. Later, various frameworks became popular, making the technical requirements for developing a product lower and lower.
In terms of community activity, there is no obvious strength or weakness between the two. Why didn’t the pistol replace the rifle?
Because the functions are different and the scenarios are inconsistent.
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Is the vscode extension malicious? Is the vscode extension malicious? Apr 15, 2025 pm 07:57 PM

VS Code extensions pose malicious risks, such as hiding malicious code, exploiting vulnerabilities, and masturbating as legitimate extensions. Methods to identify malicious extensions include: checking publishers, reading comments, checking code, and installing with caution. Security measures also include: security awareness, good habits, regular updates and antivirus software.

PHP and the Web: Exploring its Long-Term Impact PHP and the Web: Exploring its Long-Term Impact Apr 16, 2025 am 12:17 AM

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

Can visual studio code be used in python Can visual studio code be used in python Apr 15, 2025 pm 08:18 PM

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Golang vs. Python: Concurrency and Multithreading Golang vs. Python: Concurrency and Multithreading Apr 17, 2025 am 12:20 AM

Golang is more suitable for high concurrency tasks, while Python has more advantages in flexibility. 1.Golang efficiently handles concurrency through goroutine and channel. 2. Python relies on threading and asyncio, which is affected by GIL, but provides multiple concurrency methods. The choice should be based on specific needs.

See all articles