Monday, November 23, 2009

Java vs Python

There some things that made me conclude that Java is easier than python

1) Good documentation. Yes python has a very simple syntax , while java is more verbose but nothing can make thing any easier than good documentation, especially with third party libraries. Many of them actually require their users to read C++ documentation that defeats the purpose of using python in the first place.

2) Speed. Python is very slow, and even this does not show very often only for CPU intense tasks , that does not mean that python does not consume too much CPU. Again this might not be the problem for non intense CPU stuff, but because I working with midi and audio it makes my life harder.

3) Lack of a good IDE, IDEs is an essential part of RAD and none of the IDEs that support python works in a way that is hassle free. Especially in the GUI design department these IDEs leave alot to be desired.

I love the python syntax, it is surely the best of the best, that is why I have jython close at hand , but overall, at least for me what killed python is bad documentation and fragmented cross platform availability of libraries ( I have even experienced severe problems into making python work on macos).

I dont see python conquering the universe, the best language is yet to be invented. Its a great language however and alot of fun to use.

I do understand that the 3 above may not apply in all cases. Some people do not use IDEs, their python libraries have very good documentation, and do not real need speed.

My issue with python are quite old, but it was now that I decided to make an app that via MIDI protocol will control external hardware synthesizers ( I make music as well -> www.soundclick.com/kilon ) . Problem one , finding the right GUI. Qt is not free, GTK need X11 to work in mac, and Wxpython has non existent official documentation. Problem two, finding the right MIDI library, again the documentation is non existent.

Also I did not like the pure python ides or the IDEs that support python via plugin. I ended up that I would had to use several programm to do what I want and that is not good.

Java already solved the above problems.

Another motivation is jython. Java developers hate it beacause it inherits the slowness of python. Python developers hate it because it does nto allow of the use of cpython libraries unless they are already implemented in jython and thus is tied to java library and thus is not really pythonic. And other people love it ,like me, because it unites easy python syntac with the power and popularity of java libraries.


4 comments:

Syllepsis said...

I stumbled across your blog while researching something at work. I don't want to sound like a Python zealot; there are enough of those. As a student, I learned on both Python/Jython and Java at the same time, which made for an interesting learning experience.

1. I definitely agree that the Python documentation has a lot of flaws. Its pretty inconsistent and spotty. And from what I've seen, Java has some of the best documentation of all of the languages, both because of its age/popularity and the standards it poses to users. I think part of Python's differences on this may be due to its interactive nature. When I'm faced with a module I havn't used before, I spend some time looking it over and playing with it in the interactive interpreter, which is something you don't really have as an easy option in Java; its just not designed with that aspect in mind. But when you you do need documentation, it is certainly sub par.

2. I don't think anyone can really argue that Python is faster than Java; it's just not. I don't have that much experience benchmarking languages, but does using the C (or Java, for Jython) libraries when working with video still slow it down significantly? I know there's overhead with loading up Jython and such, but is the actual run time all that much worse? If you're doing something that heavy, Python just might not be the solution for you.

3. Lack of good IDEs? What do you define as a good IDE here? What exactly are you looking for that the standard Eclipse/netbeans options address?


I'm not saying Java is a bad language; its great and I do use it often. I'm not saying Python is easier than Java, I think that really comes down to the person using the language and what they do with it. I think some people approach Python as another C++/Java style language, and its not. You have to make some sacrifices for the features that Python provides. I don't think those sacrifices make Java an easier choice.

kilon said...

Hi there sorry for the late reply.

Well I turned to python, I think now I can understand further how to make python work properly for me.

About Speed I have discovered Cython which can speed things up even beyond Java speed and reaching C/C++ speed. It is 100% python syntax with the addition of some statically typing . So I have to say I am very impressed.

Also I took a look to ctypes and looks extremely cool , being able to use any C/C++ library directly , without any wrapping. Very powerful stuff.

So the ability of python to mess with C/C++ libraries with no C/C++ coding is pretty impressive.

I still wish there was more and better documentation, and some deeper IDEs especially in the GUI section, but still python has become my favourite language and I now use it for a project of mine that I do for fun.

So I have to say that now I am programming with python solely.

Java was fun , but python is better for my needs. And with Cython I can have all the advantages of C/C++ with no disadvantages .

Hard to say no to this offer.

So for now I vote Cython and Python , a deadly combination offering the best of the programming world.

Except a blog post about this.

Dipanjan said...

Python is better than JAVA. Because we can do any thing using python. It's a scripting language.We don't need and other language for web development like java script. We can make .exe file for windows. can use java modules, ctypes for low level programming. Gui programming can be done with .net as well as for open source programming.There are number of IDEs for python. Glade & Qt are the popular designers for gui. Syntax is too much easy then any other language. Data structures are simple and useful for complex programmes. Python is part of LSB (Linux Standard Base).

Jesse Taylor said...

It's also important to keep in mind that as far as the speed difference:

1) Modern JIT compilers are making the speed difference between a lot of native and "interpreted" code very small. Of course there are still some areas where native code is going to be much, much faster. But these areas are becoming rarer with better compiler technology.

2) Python is very easy to use with C/C++, so you can get the benefit of rapid application development and simpler code (i.e. less bugs) using Python, and then tackle the performance bottlenecks in C/C++