Home php教程 php手册 PHP老手谈PHP和Python的基础特性

PHP老手谈PHP和Python的基础特性

Jun 13, 2016 am 11:03 AM
php python author and Base start characteristic of

本文作者做了11年的PHP,不过最近开始投向Python阵营了。下面将对PHP和Python两种语言各自的特性进行一些描述,也许对你为项目选择合适的语言也有一定的帮助。

看PHP和Python:PHP的问题

我之所以放弃PHP,原因首先是语言。PHP实际上不是一种语言,而是一种巨大的插件结构,以一种高层的形式来展示低层的库。而大部分开发者使用的语言实际上是对C功能 (curl, mysql, gd, etc.)的包装,通常情况下它们的库展示得很简单。因而这导致了PHP的API不一致

PHP语言的第二个问题是语言的管理问题。PHP语言实际上是由委员会来设计的,而且没有人来制定任何共识性的标准。PEAR有自己的标准,PHP有自己的标准,这导致SPL classes更具Java风格,而PEAR却截然不同。

从事PHP开发11年来,我认识了很多PHP领域的专家级开发者,它们对PHP也有很多看法。除了上文提到的委员会问题以及标准混乱问题之外,由于PHP的使用范围非常广,向后的不兼容对代码造成了很大的破坏。

还要提到的一点是PHP缺乏很多现代语言的特性。现在再来说说Python:

PHP和Python:Python的优美之处

Python语言的创建方法几乎与PHP的完全相反。首先,Python是由Benevolent Dictator和Guido van Rossum领导的,语言的开发由单一的人员主导,因此它的开发、管理以及长期运营会保持很好的连续性。Guido和Python的核心开发者通过PEP创建标准,而且通过公共接口展示标准是如何创建的。而且,Guido如果想到的语言特性不够好,也不会出现在语言层中(如没有++运算符,而且比较符中没有分配)。

延续性的特点也延伸到了整个Python社区,所以你很难发现不同项目中的Python截然不同。

我最喜欢的Python的一个特点就是它的清晰。当打开Python中的一个文件的时候,我会清楚地知道里面大概有什么样子的代码,联想到很多次我被PHP的这一点搞得焦头烂额,我觉得这个特性非常有用。

总之,Python的系统级特性非常不错。

Python另外一个很棒的特性是直白性。需要namespace(命名空间)?文件的名字就是命名空间;需要模块?只需要用一个__init__.py文件代替;需要重命名功能?只需要new_func = old_func。


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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Python vs. JavaScript: Development Environments and Tools Python vs. JavaScript: Development Environments and Tools Apr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Python vs. C  : Understanding the Key Differences Python vs. C : Understanding the Key Differences Apr 21, 2025 am 12:18 AM

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Golang vs. Python: The Pros and Cons Golang vs. Python: The Pros and Cons Apr 21, 2025 am 12:17 AM

Golangisidealforbuildingscalablesystemsduetoitsefficiencyandconcurrency,whilePythonexcelsinquickscriptinganddataanalysisduetoitssimplicityandvastecosystem.Golang'sdesignencouragesclean,readablecodeanditsgoroutinesenableefficientconcurrentoperations,t

Laravel vs. Python (with Frameworks): A Comparative Analysis Laravel vs. Python (with Frameworks): A Comparative Analysis Apr 21, 2025 am 12:15 AM

Laravel is suitable for projects that teams are familiar with PHP and require rich features, while Python frameworks depend on project requirements. 1.Laravel provides elegant syntax and rich features, suitable for projects that require rapid development and flexibility. 2. Django is suitable for complex applications because of its "battery inclusion" concept. 3.Flask is suitable for fast prototypes and small projects, providing great flexibility.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Does Python projects need to be layered? Does Python projects need to be layered? Apr 19, 2025 pm 10:06 PM

Discussion on Hierarchical Structure in Python Projects In the process of learning Python, many beginners will come into contact with some open source projects, especially projects using the Django framework...

Python vs. C  : Which Language to Choose for Your Project? Python vs. C : Which Language to Choose for Your Project? Apr 21, 2025 am 12:17 AM

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

See all articles