PHP developers should try Python.

By | February 21, 2016

PHP and Python both are dynamic typed language, so there is no point the discuss anything related in this aspect.

Exception is first class citizen

Prints 'Caught'

Let's look at PHP:

Better functions

Imagine you can write functions like this

Short-lived vs Long-lived

Almost all PHP scripts are short-lived, including most frameworks, which means to serve a request, your PHP application will run from start to finish. However, Python can run as processes to serve requests, for example, A Django application runs as a process, so initiation code only runs once, serve a request, then wait for the next request to serve.

Imports Properly

Since 5.3, PHP introduced namespace, since they used ."dot" for concatenation, so they had to use the \"slash", looks like this

And use like this

But it doesn't actually import the Test class! Unless you use __autoload!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.