Welcome to your new Wikidot site

python compared to java

  • A good entry point to the issue, containing common arguments and reference to many other documents.
  • A small, quite ironic comparison. Not the most pondered analysis, but very precise in describing how python enthusiasts would typically see the perspective of having to develop in java.
  • Bruce Eckel has a long experience with both Java and Python and has written books on both languages (and on C++ as well). He has written a lot about the comparison of the two languages.
  • Jython: Sun pays for the development of this project. It is python completely rewritten in java! It allows the usage of java libraries with python code.
    • Jython, lest you do not know of it, is the most compelling weapon the Java platform has for its survival into the 21st century:-)
    • Python programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity.
  • This is really one think that I love in python: in all the discussion lists people are amazingly smart. The impression that you get is that they have thought deeply on every possible issue. Using the discussion lists you know that you will get an informative, complete, well-thought answer for every worry you may have.
  • Other testimonials (anedoctal but illustrative):
    • A comparison based on the reimplementation of java code into python.
      • Anyway, for a very small development cost I ended up with a codebase 15% of the size of the original, and an implementation that will be far easier to extend (and easier to pass off to somebody else!).
  • A technical but well-written explanation on the superiority of python compared to java for several important issues that commonly appear.

TODO: python compared to java specifically for scientific computing

TODO: python performance

  • explain why the inferior performance of pure python loops compared to C (and also to java) is not an obstacle to write high-performance algorithms.
  • give reasons: numpy, pyrex/Cython, SWIG, f2py, numexpr, PyPy.
    • The 90/10 is a well-known rule in performance computing. It basically says that the 90% of the computing time is spent in just the 10% of the code. So, it is enough for a programmer to ensure that 10% of its code runs as fast a possible. Python has many modules written in C for efficiency, so in many cases it all boils down to use them for the parts of the code where you need speed. And for the rare cases where you need a specific, fast algorithm that is not already packaged in a python module, it is very easy to do it in C, C++ or Fortran and wrap it up to be used in Python. Pyrex/Cython, SWIG or weave are tools that facilitates the C/C++ -> python bridge, while f2py do the same with Fortran code. This makes of python a powerful glue language, which combined with its other virtues (interpreted, easy-to-learn and easy-to-use) allows the users to write the code they need no only quickly but, most importantly, very efficiently.
  • give examples.
    • A dramatic example on how Python libraries can help already very optimized C libraries to reach still better performance is numexpr. Numexpr is the next best thing to writing expressions in C and compiling it with an optimizing compiler. It works by compiling array expressions on-the-flight and feeding the array operands by chunks that fits easily in the first level caches of modern processors. The result is that it can it can perform expressions not only 3x or 4x faster than numpy, but also allowing the vector math library (VML), contained in Intel's Math Kernel Library to reach maximum performance when dealing with very large arrays.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License