Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python VS Java

  1. Jul 3, 2007 #1
    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.
     
  2. jcsd
  3. Jul 3, 2007 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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: Jul 3, 2007
  4. Jul 3, 2007 #3
  5. Jul 3, 2007 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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: Jul 3, 2007
  6. Jul 3, 2007 #5

    -Job-

    User Avatar
    Science Advisor

    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: Jul 3, 2007
  7. Jul 3, 2007 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    There any many different implementations of Python, some which do JIT and some which do not.

    - Warren
     
  8. Jul 3, 2007 #7

    -Job-

    User Avatar
    Science Advisor

    The non-JIT Python implementations have to be considerably slower than Java 6.
     
  9. Jul 3, 2007 #8

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    That depends on how the code was written, and how well the programmer takes advantage of natively-coded modules.

    - Warren
     
  10. Jul 3, 2007 #9

    -Job-

    User Avatar
    Science Advisor

    Same goes for Java though.
     
  11. Jul 8, 2010 #10
  12. Jul 8, 2010 #11
    It's a good way to look at the performance of pure Python ;-)
     
  13. Jul 8, 2010 #12
    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 - but that isn't how those programs were measured.

    Java Hotspot JIT compiles hot methods to native code and switches to those compiled methods while the program is being run.
     
  14. Jul 8, 2010 #13
    Which Python JIT implementations are ready for production use?
     
  15. Mar 29, 2012 #14
    Python is a programming language that lets 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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Python VS Java
  1. Python wx vs qt (Replies: 2)

Loading...