Why is Python slower than Java but faster than PHP

Posted by good_computer on Programmers See other posts from Programmers or by good_computer
Published on 2012-05-03T13:45:26Z Indexed on 2012/11/16 5:13 UTC
Read the original article Hit count: 431

Filed under:
|
|
|

I have many times seen various benchmarks that show how a bunch of languages perform on a given task.

Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder why is that the case.

  • Java, Python, and PHP run inside a virtual machine
  • All three languages convert their programs into their custom byte codes that run on top of OS -- so none is running natively
  • Both Java and Python can be "complied" (.pyc for Python) but the __main__ module for Python is not compiled

Python and PHP are dynamically typed and Java statically -- is this the reason Java is faster, and if so, please explain how that affects speed.

And, even if the dynamic-vs-static argument is correct, this does not explain why PHP is slower than Python -- because both are dynamic languages.

You can see some benchmarks here and here, and here

© Programmers or respective owner

Related posts about java

Related posts about php