I am currently developing a new project in Java, details of which I hope to share in the future. However, this article is about why I have chosen Java over Python for this particular project (which is database centric) and the advantages of Java over Python.
So without any further ado, here's why I am loving Java so far:
- Mature IDEs: NetBeans is a great IDE for Java and has the added benefit of a built-in GUI editor, integrated VCS and resource management. This is something Python does not have. Yes, it has several IDEs, but none of them were satisfactory from all points of view. You usually end up doing a lot of command-line work in spite of the GUI. Eclipse is also good, but I ended up veering towards NetBeans, as it is also the "official" Java IDE.
- In-Built GUI: Python does not have any native GUI. Yes, Tkinter does a job, but it's not in the Python standard library and it is non-native. Moreover, Tkinter is not suited for more complicated GUIs. Python does have excellent support for other GUIs, but Java has swing, which is pure Java and dependency-free.
- More cross-platform: Obviously Python has several cross-platform benefits, but Java code is usually "write once - run anywhere". Yes, you need to avoid platform specific code, but using most of the standard Java libraries, you avoid it easily. However, with Python, you need to watch for many gotchas.
- Easier to distribute: Jar files are elegant and easy to distribute. Python has no such easy distribution mechanism. Of course, there are several solutions in Python, but I find Jar to be a very simple and easy option. Even the dependencies can be easily packaged with a Jar file.
- Static typing: Static typing, i.e. explicit variable declaration takes out a lot of runtime heartburns, because type mismatches are easily caught at compile time and you can debug much easier. I am aware of the big debate between statically and dynamically typed languages, but the fact is, catching more errors at compile time potentially reduce the unexpected and subtle run-time bugs.
- Feels more robust: This is a more subjective thing, but I find that Java code just feels more robust and consistent because you must enclose everything inside classes. And yes, you can write non-OOP code within classes with entirely static methods and properties and treating the class as a mere shell/namespace, but it's usually preferable to stick to the OOP way. With Python, you can mix OOP and non-OOP all over the place, potentially leading to ugly and inconsistent code.
This article is not a reflection on Python, which I still like a lot and will continue to use in my hobby projects. I just think that you need the right tool for the right job and you just cannot stick with any one programming language to handle all types of software development.