Why is Python slower than Java but faster than PHP
- by good_computer
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