search
HomeBackend DevelopmentPHP TutorialWeb 开发中,Python 和 PHP 哪个有优势?为什么?

对非工程师而言,如何简明扼要的向其解释选择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
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 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.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 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.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 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.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

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

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)