Date post: | 19-Jan-2016 |
Category: |
Documents |
Upload: | shanon-tucker |
View: | 227 times |
Download: | 5 times |
PHP vs. PythonPHP vs. Python
SimilaritiesSimilaritiesare interpreted, high level languages
with dynamic typing are Open Sourceare supported by large developer
communities are easy to learnare 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.
SimilaritiesSimilaritieshave 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.
Differences – What Python Differences – What Python LacksLackssyntax from C and Perl, with lots
curly braces and dollar signs the 'switch' statement and 'do ...
while' construct increment and decrement and
assignment operators (assignment is a statement only in Python)
the ternary operator/statement (... ? ... : ...)
Differences – What Python Differences – What Python LacksLacksschizophrenic tableau of function
names. The builtin library has a wide variety of naming conventions. There are no namespaces, so functions often have prefixes to denote their source (but often not). Functions are often placed into classes to simulate namespaces.
Differences – What Python Differences – What Python LacksLacksa very casual language where all
variables are "set" (to NULL), and a somewhat weak type system (not to be confused with dynamic types)
an expedient (commonly installed) environment
references ('$a =& $b' means that when $b changes, $a changes also)
Differences – What Python Differences – What Python LacksLacksone 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
interfaces
Differences – What PHP Differences – What PHP LacksLacksa general purpose programming
language (not just for the web) indentation is used to mark out
block structure rather than curly braces namespaces and modules
a small core very clear, concise, and
orthogonal syntax
Differences – What PHP Differences – What PHP LacksLacksit is self documenting with
docstrings and pydockeyword arguments to functions
and methods, easy support for default arguments
true object orientation and 'first class' classes and functions
Differences – What PHP Differences – What PHP LacksLacksclasses are used extensively in
the standard librarya notion of private attributesmultiple inheritanceobject-oriented file handling method chainingexcellent introspection
Differences – What PHP Differences – What PHP LacksLackseverything is a referenceone 'del' statement for all data
types.consistent case sensitivity (PHP
functions are case insensitive, but variables are case sensitive)
a simple array slicing syntaxlambdas and other builtin
functional programming constructs
Differences – What PHP Differences – What PHP LacksLacksiteratorsstructured exception handlingoperator overloadingSWIG integration threading an excellent profilerseveral debuggers and IDEslots of high-level data types (lists,
tuples, dicts, mx.DateTimes, NumPy arrays, etc.)
Differences – What PHP Differences – What PHP LacksLacksdifferentiation between arrays (lists)
and associative arrays (dictionaries).
dates that aren't limited to UNIX timestamps (<1970, >2038)
cached byte-code compilationa standardized database APIsupport for all major GUI
frameworksstrong internationalization and
UNICODE support
Differences – What PHP Differences – What PHP LacksLacksmaturity, stability and upward-
compatibilitytends 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.
BenchmarkingBenchmarking
BenchmarkingBenchmarking
ConclusionConclusionPHP’s big core uses huge amount
of resources as compared to Python.
ReferencesReferenceshttp://xodian.net/serendipity/
index.php?/archives/27-Benchmark-PHP-vs.-Python-vs.-Perl-vs.-Ruby.html
http://wiki.python.org/moin/PythonVsPhp
http://frcchang.blogspot.com/2005/07/php-note-difference-between-php-and.html
http://www.wellho.net/mouth/67_Object-Oriented-Programming-in-PHP.html