Comparing Python and Java: Performance & Standard Libs

Click For Summary

Discussion Overview

The discussion centers on comparing Python and Java, particularly focusing on their performance, standard libraries, and the implications of using each language in application development. Participants explore various aspects including syntax, library completeness, just-in-time compilation, and performance benchmarks.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Exploratory

Main Points Raised

  • Some participants argue that Python's standard library is as extensive as Java's, though it may lack consistency in naming conventions and organization.
  • Warren claims that Python can outperform Java in certain scenarios, especially when leveraging native libraries like NumPy, and suggests that experienced Python programmers can optimize performance significantly.
  • Concerns are raised about Python's performance in benchmarks, with some participants noting that tests often involve CPU- and memory-intensive algorithms implemented in pure Python, which may not reflect real-world usage.
  • Questions are posed regarding Python's support for just-in-time (JIT) compilation, with some participants noting that there are multiple implementations of Python, some of which do support JIT.
  • There is a discussion about Java's performance benefits due to its virtual machine and dynamic optimization capabilities, with references to outdated benchmark comparisons.
  • Warren mentions that the performance of both languages can heavily depend on how code is written and the use of natively-coded modules.

Areas of Agreement / Disagreement

Participants express differing opinions on the performance of Python versus Java, with no consensus reached on which language is superior. There are competing views on the implications of JIT compilation and the relevance of benchmark tests.

Contextual Notes

Some participants highlight that performance measurements may be outdated and suggest that comparisons should consider the use of native libraries in Python. The discussion also notes the variability in Python implementations regarding JIT support.

neurocomp2003
Messages
1,359
Reaction score
4
Any one have any opinions on the differences between these two language (and their closeness to C)...

chroot posted about python being almost as complete as java interms of standard libs. I attended a presentation which seemed to verify that claim though you have to download some of the added libs like numpy,scipy,wxpython.

Is there a performance difference between the two?

My goal is to try to minimize the number of packages to be downloaded for my application which currently uses both java/python. Not sure why since wxpython seems to be platform independent but they use java's awt/swing because of clientside platform independence.
 
Technology news on Phys.org
Python's a better language, all around, in my opinion. The syntax, built-in data types, weak-typing, and other features just make it incredibly fluid and flexible.

The standard library is certainly as big as Java's. The only downside is that it's rather messy, since it was written by a ton of different people. There are no universal naming conventions -- some people use initial-capped class names, some use all lowercase. Some have oscure names that make them hard to search for. (If you were looking for an object serialization system, would the word 'pickle' come to mind?)

Python's performance is often much better than Java's. Experienced Python programmers can write code such that the processor spends most of its time in the underlying native, optimized C implementation, rather than in the interpreter code. The best way to use Python is as high-level coordination of native modules like NumPy and wxPython. I hesitate to call Python "glue," since you can do almost anything in pure Python. On the other hand, if speed is essential, try to use libraries with native implementations. In my real-world experience, Java is significantly slower than Python.

You can even compile virtually any Python program to a native executable with free, open-source tools like Pyrex. There are some similar tools for Java, but they're not nearly as capable.

- Warren
 
Last edited:
Why does Python have such a poor performance on the language shoot out page?

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=java&lang2=python

I tought that the power of Java lies in the VM (it does dynamic optimization rather than compile time static optimization).
 
Last edited by a moderator:
From what I can tell, these people implemented CPU- and memory-intensive algorithms in pure Python. That's a very good way to ensure your Python program is slow. I'd be much more interested in seeing a comparison against Python programs that use native libraries (like NumPy) in a way that a real programmer would use them.

- Warren
 
Last edited:
Does Python support just-in-time compilation? A second run of a Java application is largely native due to JIT. The values used in the benchmark were probably on runs after JIT has taken place, considering it's a server application.

Otherwise it has probably to do with optimization like haki mentioned (where Java's rigorous yet verbose standards might be a factor).
 
Last edited:
There any many different implementations of Python, some which do JIT and some which do not.

- Warren
 
The non-JIT Python implementations have to be considerably slower than Java 6.
 
That depends on how the code was written, and how well the programmer takes advantage of natively-coded modules.

- Warren
 
Same goes for Java though.
 
  • #10
haki said:
Why does Python have such a poor performance on the language shoot out page?

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=java&lang2=python

I tought that the power of Java lies in the VM (it does dynamic optimization rather than compile time static optimization).

Those measurements are OUT-OF-DATE!

Here are up-to-date measurements -

http://shootout.alioth.debian.org/u32/compare.php?lang=python3&lang2=java"

http://shootout.alioth.debian.org/u32q/compare.php?lang=python3&lang2=java"

http://shootout.alioth.debian.org/u32/compare.php?lang=pypy&lang2=java"
 
Last edited by a moderator:
  • #11
chroot said:
From what I can tell, these people implemented CPU- and memory-intensive algorithms in pure Python. That's a very good way to ensure your Python program is slow. I'd be much more interested in seeing a comparison against Python programs that use native libraries (like NumPy) in a way that a real programmer would use them.

It's a good way to look at the performance of pure Python ;-)
 
  • #12
-Job- said:
Does Python support just-in-time compilation? A second run of a Java application is largely native due to JIT. The values used in the benchmark were probably on runs after JIT has taken place, considering it's a server application.

No - there's no link between a second run of a Java application and a previous run.

We can force there to be a link by starting Java and then repeatedly running the application once, twice, ... without stopping Java - http://shootout.alioth.debian.org/help.php#measure" .

Java Hotspot JIT compiles hot methods to native code and switches to those compiled methods while the program is being run.
 
Last edited by a moderator:
  • #13
chroot said:
There any many different implementations of Python, some which do JIT and some which do not.

- Warren

Which Python JIT implementations are ready for production use?
 
  • #14
Python is a programming language that let's you work more quickly and integrate your systems more effectively. It supports multiple programming paradigms (primarily object oriented, imperative, and functional) and features a fully dynamic type system and automatic memory management.
 

Similar threads

  • · Replies 75 ·
3
Replies
75
Views
7K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 4 ·
Replies
4
Views
13K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 127 ·
5
Replies
127
Views
27K
  • · Replies 10 ·
Replies
10
Views
4K
Replies
13
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 10 ·
Replies
10
Views
4K