Why Python is better than Java?

Dhananjay Nene recently switched over to Python and has discovered that he is much happier writing programs in Python. He has a detailed post over at this blog on the reasons:

I think the most dominant impression from the last few months is that python does make programming feel a lot more easier and often more enjoyable. The feeling is not very different between riding a bicycle without gears then riding one with gears. In the latter case one just feels one can cover a lot more distance much more easily though any physicist will tell you the actual effort is not particularly different. It just feels like one has a much bigger toolbox (ie a wider assortment of tools) to work with and therefore the task seems simpler. Why do I think that way ? I believe the following features of python do help (in no particular order) :

* Concise Coding style : The code typically is much more concise, with much lesser verbosity
* Dynamic typing : You really do not need to worry about declaring data types and making sure the inheritance hierarchies especially for all the interfaces and implementations well laid out. The various objects do not even need to be in the same inheritance hierarchy – so long as they can respond to the method, you can call it. This is a double edge sword, but that doesn’t take away the fact that programming under dynamic types environment does seem a lot easier.
* Easier runtime reflection : Java seems to have all the reflection capabilities but I think these are just way too painful to use as compared to python. In python the entire set of constructs (classes, sequences etc.) are available for easy reflection. In case you need to use metaprogramming constructs, python really rocks.
* More built in language capabilities : Items such a list comprehensions, ability to deal with functions as first class objects etc. give you a broader vocabulary to work with.
* Clean indentation requirement : It took me about 2-3 days to get over it but, it seems that python code is much easier to read since if you do not indent it correctly it will be rejected.

I am a Perl person myself, and think similar thoughts about Perl, and I don’t really care for the forced indentations of Python. But Perl is really for disciplined programmers who don’t get carried away and start doing all the weird things that the language allows. For the indisciplined folks, I guess the forced indentation of Python is probably a good way to keep them in check.

Anyway,  read the whole article. You should also read the post he wrote at the time he chose Python for this next project. In fact, subscribe to his blog. He writes detailed and insightful articles that, as a techie, you would do well to read. If you are interested in programming languages, I would recommend reading “Contrasting java and dynamic languages”, and “Performance Comparison – C++ / Java / Python / Ruby/ Jython / JRuby / Groovy”. And if you are a blogger, check out his tips for software/programming blogging.

Dhananjay is a Pune-based software Engineer with 17 years in the field. Passionate about software engineering, programming, design and architecture. For more info, check out his PuneTech wiki profile.

7 thoughts on “Why Python is better than Java?

  1. The “forced indentation” is the exact same indentation as you’d use in any other language. Meanwhile, you get to dispense with brackets, begin/end, or similar nonsense. It’s a huge win with no downside.

  2. Python is AWSOME. It is the only language out of the mainstream ones I have used I get excited about using.

    YMMV depending on what field your in. Python is very strong for glue work. Has a long way to go in other areas though. Very popular getting for web development – for that I think it may overtake Java.

    To learn I advise getting videos from lynda.com or similar sites to get the basics down. Then go and find other peoples code and just read it. That is really how most people learn programming not from long winded books they just get stuck in working over code from experienced programmers.

    Look for books that teach algorithms, design patterns and frameworks or using python for a purpose you need it for (you will NEVER learn everything any language can do so stick to your area of need). You also learn more actually trying to use it for a specific project than always book reading.

  3. The overhead in Python basic is minimal. The overhead in Python advanced pedagogy is no more absurd than any other language including Java. Then you have the whole dynamic vs static typing argument, which boils down to more of what you expect out of the language(s). Python currently has poor adaptation when it comes to its ide of choice, you are basically stuck with idle. Unless you revert to anything below Python 3, but then you enter the whole why should I even bother argument. Its as if the developers of this language simply want to push out newest versions without any care to the community of users that don’t want to upgrade. Java shines in this department it has two strong ide’s and they don’t mind what version of Java users use as you can approach your work ethic from any angle. A working auto completion feature in both Netbeans and Eclipse change the whole argument for writing long lines to complete tasks, it doesn’t change the fact Java is much beefier than Python but what does change is that Java is for serious coding. Python is more of a glue language that relies on C++ for abstraction whereas Java is C++ complete (no batteries).

Comments are closed.