Wednesday, March 30, 2011

5 Reasons why I left Java for Python

My programming history can be dated as far back as 1999 when I started off with HTML and got it perfected by 2001 in Secondary School. This followed programming in JavaScript then Java.
I have been programming in Python for close to 2years now thanks to Kennedy Kasina. Of course I programmed in Java more and had not looked Python in the eyes. But I had very simple Systems Administrative tasks to accomplish and that was when I looked at Python especially since it's used heavily at The Fedora Project.
It all begun to make sense to me when I had to write a simple application to pull information from an Oracle database and push it over SMPP.
Accessibility to libraries were easy and there seems to be a solution for everything in Python any time you search on Google. Then I understood why Python is said to come with "batteries". If you unplug the main power, you can still run with it.
I will share with you 5 reasons why I left Java which I loved so much and was an advocate of for Python.

1. Simplicity: Thank you done adding delimiters to my code. I also love the fact that I can write some code and indent it to show various levels of logic. Compare the code below to do the same simple task of printing a string to stdout.
All codes realize their respective coding styles and standards.

1. public class speak{
2. public static void main(String[] someargs){
3. }
4. System.out.println("Leaving you");
5. }

1. #!/usr/bin/env python
2. print "Leaving you"

Do you see the Total Lines of Code (TLoC) in both languages?For the same task done in 2 lines in Python, Java covers 5 lines. This is just a tip of the iceberg. I have several other applications which are very heavy in Java.
On several levels there are multiple tasks that are done simple in Python than in Java. Python is very light weighted and hence my choice of implementing major programming projects.

2. Speed: Need I say more...Code time + Compile time + Run time=Java. Code time+Run time= Python. I was asked to provide statistics proving my concept of speed in Python. This is what I usually do, use the matrix below:

a) Same typing speed: eg. 80 words/minute
b) Compile time
c) Execution time

Using the same example in my first reason for leaving Java, do the Math yourself and find out what your answer will be. I can confidently tell you that on the first count, for Python, you can eliminate b). This comes to reducing the total amount of time required to run an application written in Python.

3. Performance: Python is a thin language at execution. The elimination of a virtual machine reduces the number of stacks required for running a program. Python has shown tremendous strength in larger organizations such as Google.

4. Support: Trust me when I say, Python sure does come with batteries. For almost every little task you want to accomplish, there is an available library. I found this true when I had to search for an available smpp library implemented in Python. To my amusement there was a simple and available library just for that. The same occurred for the ISO8583 library. There are countless solutions out there just for any problem you may have in Python.

5. Flexibility: Like fine clay which can be moulded to form several beautiful artefacts, Python can be used for various task, GUIs, Systems Administrative CLI, Enterprise Applications,Mobile Applications and so much more.
I could go on and on about the benefits of Python over Java, however just these few pointers should set you thinking again. Ruby has been on the block for quite a while. It is gaining attention gradually, but I will stick with Python, C and Perl for now :)

My next blog entry will be on 2 tools im writting with help from members of the Open Source Community.
1. OpenUSSD - This is an Enterprise based USSD engine that connects to various USSD Gateways to handle dynamic and static content.

2. d3vbeast - A light weight Penetration Testing tool that uses Metasploit and Nmap to generate quick security assessment reports including building proof-of-concept attacks. Here we add some Artificial Intelligence to the tool so it simulates various forms of attack on detecting vulnerabilities. Good security starts with being able to write good tools.

So what are you waiting for, if you are on Linux, you already would have Python running,if on Windows download the Python Interpreter and grab a Dive Into Python book and start learning now. Python surely rocks.