Python Or Php, Python vs PHP, Python & PHP development

 

Both Python & PHP Web Development Formats (PHP vs Python):

  • are interpreted, high level languages with dynamic typing
  • are OpenSource (except where various Zend products, recommended by some, are employed)
  • are supported by large Python & PHP developer communities
  • are easy to learn (compared to C++, Perl)
  • are easy to extend in C, C++ and Java
  • are extremely portable. They run on almost all platforms in existence without recompilation.
  • support for variable number of function arguments.
  • have the ability to freeze live objects in a string representation (for storing arbitrary objects on disk, moving them over the network, etc); they can then be converted back to identical objects with data intact. PHP's serialize function; Python's pickle and marshal modules. Note that PHP, handling of serialized objects and classes is much weaker and error prone than Python's due to PHP's lack of modules. When an object is serialized, only its attributes are stored, not its methods. Thus, the object's class must be present (with the exact same name) in the script that unserializes it. In Python this is handled automatically via the module/import framework. (this COULD be handled with PHP 5's autoload(), but is not done automatically)
  • support namespaces
  • support for docstring (pydoc / reflection + phpDocumenter)
  • support method chaining
  • have several debuggers and IDEs
  • support for dates that aren't limited to UNIX timestamps (<1970, >2038)
  • support for cached byte-code compilation (an extension in PHPs case)
  • have a standardized database API
  • support GTK and QT
  • support lambdas and other builtin functional PHP & Python programming constructs
  • have a single statement (unset/del) for all data types
  • can be used for PHP scripting and general programming (CLI sapi, embedded etc., in the case of PHP) 

Comparison Between Python & PHP programming languages (PHP vs Python)

What does PHP Web development have that Python development doesn't?
  • syntax from C/C++ and Perl, with lots curly braces and dollar signs and "->"-s
  • the 'switch' statement and 'do ... while' construct
  • increment and decrement and assignment operators (assignment is a statement only in Python)
  • the ternary operator/statement (... ? ... : ...) 
  • confused tableau of function names. The builtin library has a wide variety of naming conventions. Functions often have prefixes to denote their source (but often not). Functions are often placed into classes to simulate namespaces.
  • a somewhat weak type system (not to be confused with dynamic types
  • an expedient (commonly installed) environment
  • one array type that doubles as a list and a dictionary. Dictionary keys are iterated in their original order.
  • private, protected and public modifiers for both properties and methods
  • abstract and final modifiers for both classes and methods
  • Python 2.6 has introduced Abstract Base Classes.
  • variable variables
  • default arguments in functions
  • embedding in HTML
  • a wide range of byte-code caches available

What does Python Web development have that PHP development doesn't? (PHP vs Python)

  • indentation is used to mark out block structure rather than curly braces
  • modules
  • Rules that help catching typos more; reading an undefined variable is an error, it's not silently treated as if it was null.
    • Retort: PHP will issue E_NOTICE. This will be shown in a develop environment.
  • a small core (language or runtime?)
  • very clear, concise, and orthogonal syntax
  • keyword arguments (i.e., parameters passed by name instead of by position) to functions and methods, easy support for default arguments
  • true object orientation and 'first class' classes and functions
  • classes are used extensively in the standard library
  • multiple inheritance
  • object-oriented file handling
  • excellent introspection
  • everything is a reference! (references are painful in PHP)
  • consistent case sensitivity (PHP functions are case insensitive, but variables are case sensitive)
  • a simple array slicing syntax
  • iterators
  • structured exception handling in PHP & Python
  • operator overloading
  • SWIG integration
  • threading
  • "with ... as" statement to deal with resources that need closing reliably and concisely
  • an excellent profiler
  • lots of high-level data types (lists, tuples, dicts, DateTimes, NumPy arrays, etc.)
  • differentiation between arrays (lists) and associative arrays (dictionaries).
  • cached byte-code compilation built in
  • support for all major GUI frameworks
  • strong internationalization and UNICODE support
  • tends to lead to much more scalable applications -- importing modules is safer than textually including code as in PHP: global variables are not used to exchange information. 

Compared as Web Development Frameworks: PHP web applications & Python web applications (PHP vs Python)

Unlike PHP, which has web development features built directly into the core language, Python's web development capabilites are provided by add-on modules. Basic CGI capabilities are provided by the 'cgi' module which comes in Python's standard library. There's also a wide range of third-party modules available for Python; some are complementary, others compete. As a result, Python provides a more flexible base for web development.

There are some adverse side effects of this flexibility. First, the range of choices can be bewildering. Unless you are working experienced Python web developers, PHP is easier to get started with. Second, support for PHP developers is more common with shared-hosting companies than support for the various Python web options.

Another difference is that PHP web page is embedded in the web server, whereas Python web applications can either be embedded in the web server like PHP or run in a separate process.

The vast majority of Python & PHP Web applications are run in a separate process. This has some important implications. 

Security (PHP vs Python)

PHP has historically had a horrible history when it comes to security. See the following article as an example: http://old.lwn.net/2001/0704/a/study-in-scarlet.php3 (Note: This article was published 10 years ago PHP web application development, and is no longer valid for more than an idea of PHPs history with security).

Community Support (PHP vs Python)

1. PHP / PHP Web developers / PHP Web Development
  • huge installed user base, but the figures are probably distorted by shared hosting
  • low signal-to-noise ratio -- because PHP is so expedient, many of the users are not invested in the technology (or even their own code) or the community
2. Python / Python Web developers / Python Web development
  • sizable, but not huge, installed user base
  • Python Software Foundation
  • lots of specialized interest groups
  • very high signal-to-noise ratio

Documentation on PHP & Python Web Development (PHP vs Python)

Although both PHP and Python web programming language have excellent core documentation, Python's is more extensive and generally higher quality. PHP development has a large number of translations available. Python doesn't. For PHP see http://www.php.net/docs.php and for Python see http://python.org/doc/ Python development allows documentation on modules, classes, and functions to be included in the program code. The documentation becomes an attribute of the module/class/function, accessible from inside of the language itself. Python manual is really awfully structurized and presented compared to PHP manual, which uses cross-links, a lot of colorized examples and invaluable user comments to make it easier to comprehend the magic. PHP manual merges different versions of the language together making it a little bit bloated.

Editorial Notes Regarding PHP & Python Development (PHP vs Python)

Given the copy-and-paste origins of this document, along with the age of the original document, the text has been somewhat incoherent. Several changes have since been made to tidy up the text, drop redundant content (old comments which can be viewed in the original document, links to outdated resources and content found elsewhere in this Wiki), and to focus the remaining content on the actual topic of the page.

Constructive Criticism / Observations (PHP vs Python)

I came here for an objective comparison between PHP and Python programming languages but what I see is a document that is not only incorrect but is also heavily biased. I realize this is a Python site but that doesn't give editors (read anonymous visitors) carte blanche when it comes to facts. For example - it is claimed that unset is not uniformly used in PHP applications but in fact it works on variables, objects and arrays. Next is the comment about Python having a profiler, so does PHP. Other items that should not be in the section labeled things that Python has that PHP doesn't include: method chaining, classes are used extensively in the standard library, maturity, easy support for default arguments, debuggers and IDEs and that is just the beginning.

I don't see the harm in referring to future functionality because leaving it out implies that it isn't going to be available - for example the addition of namespaces and other features in PHP5.3 is going to be a nice step for the language and the release is imminent. That having been said, OOP in PHP is not complete IMO so I would like to see objective comparisons of OOP in PHP and OOP in Python which would be an enormous benefit to myself and others.

I don't want seem like I hate Python, I honestly have no notions whatsoever about it but I do not like coming to a comparison page between two languages and discovering that the comments cannot be trusted. The reason I came here at all was to decide if Python would be a good fit for future projects that I intend open source but I am leaving this site unsure of the true advantages that Python has to offer. In the spirit of helping people know the difference, I suggest that you collaborate with someone who has no bias.

Using Python and PHP Platforms together (PHP vs Python)

The Embedded Python PECL extension "allows the Python interpreter to be embedded inside of PHP, allowing for the instantiate and manipulation of Python objects from within PHP". The PyPI phpserialize package is "a port of the serialize and unserialize functions of php to python". phppython "is a php to python code converter that currently can: convert small php code snippets, functions to python code". WPHP is a WSGI->PHP gateway that "allows you to run PHP processes inside of Python, using a WSGI gateway".

Incoming Search Terms:

php python
convert php to python
php to python converter
php to python
php or python
python php
php vs python
php in python
call python from php
perl php python
learn php or python
php python comparison
php or python for web development
python vs php
php python integration
php python interface
php execute python
php vs python vs ruby
python web development
php python ruby
php python perl
php vs python performance
python php server
python for php developers
php vs ruby vs python
python web programming
python v php
python ide
python or php
php and python integration
python programming
php versus python
php ruby python infographic
php ruby or python
python vs ruby web development
python in php
php call python
php python bridge
python vs php performance
ruby vs php vs python
python web server
php vs python web development
django developers
ruby php python
python development
python for web development
python to php
php perl python
web programming languages
php programming language
php 2 python
should i learn php or ruby
python developers
python android development
python and php
python versus php
php run python script
python programmer
python game programming
php exec python
python and web programming
running python from php
php coding
django web development
python vs ruby for web development
python web development with django
coding in php
ruby programming
php vs perl vs python
php vs python speed
fun python
python vs php speed
learn python
php programmer
should i learn ruby or php
programming in python
python programming languages
php programmers
php call python script
web development with python
how to learn python
python for php programmers
learning python
learn php
python vs php for web development
ruby vs python for web development
php development tools
calling python from php
pythan language
python programming tutorial
django developer
python web application
freelance php
python for programmers
web developers
python vs ruby vs php
learn pyhon
php freelance
web development tools
perl vs php vs python

0 comments:

Post a Comment