Table of Contents
回复内容:
Home Backend Development PHP Tutorial Web 开发中,Python 和 PHP 哪个有优势?为什么?

Web 开发中,Python 和 PHP 哪个有优势?为什么?

Jun 17, 2016 am 08:30 AM
php python

对非工程师而言,如何简明扼要的向其解释选择python而非php?

比如PM讨论中问起,比如老板开会忽然问起,比如同组成员需要偶尔读一下代码的问起

回复内容:

所谓胶水语言不是盖的,当你有一些比较奇葩的类包要调用时你就知道Python的好了。在做一个分享基因数据的服务器,里面要随机读取一些很奇葩的基因文件,刚好Python有个包可以实现这个功能。用Python的感觉就是你什么都能解决。学习曲线来说PHP也不是说完爆Python,到最后你还是要用到框架。 《社交网络》里,当划船那俩双胞胎兄弟还在深思熟虑、琢磨着到底该怎么实现自己那激动人心的宏伟目标时,扎克伯格用两星期的时间就真正把这个社交平台给实现了。

所以我的推荐是:你应该继续讨论、琢磨下去。
非常不推荐的是,哪个上手快,哪个更容易快速开发、快速实现,眼光一定要放长远,那个..我们再开个会讨论讨论怎么样? 快速开发选php,要做大选python php环境好部署
python比较难
语言难度上,都差不多 Python的代码风格简洁易懂易于维护,而PHP代码量一多起来就混乱了

个人感觉易于维护是关键。因为现在软件开发的成本主要都在维护上面。 相比 PHP,Python 可以非常自然的扩展到队列(RabbitMQ)、后台处理系统(基于 Celery)、数据挖掘(SciPy、NumPy)、文本处理(NLTK)、系统部署(Fabric)、监控(Supervisord)等所有方面,而 PHP 只能做网页前台。 要看需求是重展现还是重业务逻辑,重展现就php,重业务逻辑就python 可以直接让他们读比较简单的python代码,和php代码,对比出前者更接近自然语言。
比如
python: var is not None
php: $var !== null

保罗•格雷厄姆在《黑客与画家》中极力推崇lisp的一个理由是,它可以用比其他常用语言更少的代码实现相同的功能。于是你可以比竞争对手更快地推出新功能,并且减少代码中潜在的bug。对于互联网这个行业来说,快速是很重要的一件事。如果是小公司或创业团队就更重要了。

python也有同样的优势。而它从语法上来说又比php,lisp容易学。

坏处可能是用它的程序员少,招它公司少。可这又有什么要紧呢?



ps:对于你们老板的问题,你可以说,我去知乎上问了下,人家告诉我知乎是用python写的 主要还得看是哪方面
  1. 吐槽 PHP $ 实在不能算借口,我都是用左 alt 映射到 $ 的,或者右 windows 键,没人强迫你每次都要按 shift+4。
  2. PHP 丰富的中文资料这点无可置疑, Python 大部分都是英文的,不过学一下英语没什么难的。
  3. PHP 更贴近前台,但这并不意味着它不能做后台处理。
  4. 做网站还是 PHP 用起来比较顺手,不论是模板引擎还是各种框架 (个人观点)。
  5. Python 最让我印象深刻的还是字符串和数组切片,实在是很方便。
  6. Python 应用范围非常广,基本上我遇到的问题都能用 Python 来解决,而且代码量也远比 PHP 要少。
  7. Python 的命名空间和库的导入做比PHP好,而 PHP 你经常能见到很长的函数名,一般都是以模块名开头的,比如 “mb_” 。
  8. 个人觉得 PHP 在数据库查询和执行效率方面是要优于 Python 的。(百万级的数据量测试过)。
  9. Python2 到 Python3 很容易过渡,中小型的项目只要花点时间就可以了。
  10. 既然 PHP 和 Python 各有优势与短处,为什么不能一起用?

//最后吐槽一下,用 PHP 写爬虫遇到 Cookie 和登录的表示无能为力。
以上仅为个人观点,看一下就好。
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.

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.

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.

How to run programs in terminal vscode How to run programs in terminal vscode Apr 15, 2025 pm 06:42 PM

In VS Code, you can run the program in the terminal through the following steps: Prepare the code and open the integrated terminal to ensure that the code directory is consistent with the terminal working directory. Select the run command according to the programming language (such as Python's python your_file_name.py) to check whether it runs successfully and resolve errors. Use the debugger to improve debugging efficiency.

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

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.

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

See all articles