Table of Contents
回复内容:
Home Backend Development PHP Tutorial Python 是否是下一个 PHP?为什么?

Python 是否是下一个 PHP?为什么?

Jun 17, 2016 am 08:30 AM
php python rails

前几天和一个看好 Python 的 Rails 开发者聊天,他看好 Python 的原因就是 PHP 统治今天的网络应用开发。而 Python 很像下一个 PHP 。

回复内容:

python能,为什么node.js不能,为什么go不能 『下一个 PHP』如何定义?是指流行程度么?如果是的话,我觉得 Python 不会像 PHP 那样流行。根本原因在与部署难易程度。

PHP 从语言层面上讲几乎是一无是处,具体实现的质量也乏善可陈,但它胜在最要命的部署上:没有任何其他语言有像 PHP 一样适合大规模部署的方式。基本上装好 Apache/mod_php 之后,PHP 应用的部署就简化为了复制文件。即便是考虑到性能原因等采用 nginx/FastCGI 等替代方式,额外的工作也只是在于最初配置。一旦配置完成,之后的部署都是文件复制。服务器重启后通常会自动启动 apache/nginx,fastcgi manager 负责启动 php-cgi 进程等,而 PHP 应用基于文件的调用方式并不需要操心更多的维护。这对于如 Dreamhost 之类的平台来说至关重要:他们通常要一台服务器处理成千上万的低流量用户,而且这些用户没有 root 权限去运行其他进程。PHP 脚本的生命周期很短,没有常驻进程,每次调用之后就被终止,对于应用作者的要求更低,不用太多的考虑资源管理问题。

这和 Python 之流的部署有天壤之别:大部分 Python 的网络应用如 Django, Tornado 等都需要单独的常驻进程(Apache/mod_python 似乎是个杯具)。这些进程需要额外的维护工作以管理其启动、停止,也需要额外的监控进程处理意外退出后的重启。这需要用户对系统有更深入的了解。常驻进程需要占用系统内存,通常不可能在一台服务器上运行成百上千个应用,对于 Dreamhost 这样的服务提供商来说不适合用来处理诸如 WordPress 博客之类的简单应用。常驻进程也要求作者对系统资源的管理、垃圾回收机制等有更深入的了解以避免内存泄露、资源占用过度等问题。现在 Python 网络应用部署最简单的应该是 App Engine,采用了类似 PHP 的生命周期(请求处理 30 秒限制,超时被终止,无法运行常驻进程),极大简化了管理难度,但是国内无法访问…

所以从流行程度上讲,Python 不会超过 PHP,因为数量庞大的服务提供商无法用 Python 支撑现有的用户规模。但是这个流行程度对于创业公司、专业人士来说没有什么意义。很多核心的网络应用不适合用 PHP 的短暂请求处理机制实现(比如准实时 push 提醒、网页即时聊天等),而更加适合由常驻进程来处理。这些才是 Python,Ruby 等语言实现发挥其能量的地方。 Python就是Python,为什么要是下一个PHP? Python部署成问题?Python的Web应用只在虚拟主机里部署成问题,其它平台都好好的。

现在啥都缺,就不缺主机,谁还用廉价的虚拟主机? 我并不认为python可以代替php,至少目前来说还完全不可能。
原因如下:php仍然在与时俱进,同时phper和php相关程序的数量和质量仍在不断地扩大和提高。重要的一点既是,php仍然在不断维护和更新,语言各个方面在不断地提高和改善,在这个时代,被淘汰的,一直都是不与时俱进和反人类的产物 Python能干很多事情,比如数学计算、2D/3D图形处理,最近几年有很多有想法的人把Python用到科学研究、数学计算上,建立了很多科学工具、数学库,期望Python有朝一日能够像Matlab、Octave、SAGE、SciLab那样变成强大丰富的计算环境。而在Blender、GIMP等软件的背后,Python图形处理脚本已经在发挥越来越大的作用。如果你看过Blender基金会制作的三部开源动画影片,你甚至还能预期不远的未来,Python终将有一天能够进军好莱坞,成为数字电影制作的一种工具。 不同语言有不同的优势,各自擅长的领域也不同,就正如PHP对开发长时间机制的程序支持的就不是那么好,可以说就是不擅长,但是对WEB开发,快速敏捷的特别在PHP身上又体现得淋漓尽致。然而Python可以说更加强大,不单单可以做WEB开发,还可以支持开发后台数据监控,网页抓取等等长耗时应用,以及数据分析,数学计算等等高端应用。可以说各自有各自的优势,开发当中选择合适的语言就可以了,讨论谁替代谁,一点意义都没有。 apache不死,php不倒,就这么简单。 python的强大之处在于语言的简洁与优雅, 以及它强大的表达能力. hacker们愿意使用python来作为他们表达思维的方式.
在web开发上面, 正如上面Rio所言, python部署成问题, 但是对于商业网站而言, 自己处理一台vps不成问题. 而python的通用性, 能保证完成各种非常规的应用.
简单地说, 如果你只是需要web1.0的内容展示网站, 考虑php, web2.0, 可以考虑python, 以及RoR. 就python这个版本迭代速度和向前兼容性,怎么可能。。。
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 and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

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.

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.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

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.

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 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.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

See all articles