Java versus Python

I've been working a lot on a personal project recently, not for monetary gain, purely to solve a pet peeve of mine that I've had since a long time ago. I've always been slightly miffed that there is no single website available to me where I can maintain a list of all the things that I've seen (movies, tv shows, anime) or read (books), and what I thought of it. I gave up on this project last year because I found out about this website called Anime Planet, which almost completely fulfilled my needs in terms of anime. I was already using IMDB to keep track of movies and tv shows for me, but realized that both sites are still lacking for me. What I really want is a single list of all my things, regardless of what kind of thing they are, and I want to be able to rate the same thing multiple times, using different dates for each rating. That's the core idea that I wanted to accomplish with my project.

I started this project last year on a vacation but never quite finished it. I got quite far to releasing it but then gave up on it for lack of time and the discovery of Anime Planet. Now that I've got time again I've picked it up, and I'm hoping to release it before I find a job, which will undoubtedly be disastrous for my free time. The nearly finished app was implemented completely in Java using Hibernate, and was very enterprise-y. I had a lot of cool ideas that I wanted to accomplish and started to work on already but left half-finished. Still, the back-end was fairly robust. The front end, though, was a bitch. I used the Prototype javascript library to AJAX my way in-between the client and the server but never really designed things right, making the whole thing a mess and bothersome to maintain. I needed something else.

Enter the wonderful world of weirdly-named six-letter frameworks: Joomla, Drupal, Django, Spring, Struts, Hadoop, whatever. There's too many of them, and no, I did not consider Hadoop for my project, I just wanted to mention it here because it resonates nicely with the other silly names in the list. I mentioned in my previous post how disappointed I was at Spring, and looking at all the Java Facelets/Portlets/Server Faces stuff didn't make my life any easier, so I decided to give up on my comfortable Java environment and try out something new instead. After a couple of days of researching the many unknown frameworks I decided on a Python-based framework called Django.

I should note here that I am seriously intent on putting this web app online at some point in the future, and my hoster won't run Java on their servers, which helped me take the decision to plunge into Python. And what a plunge it was: it's hard to describe how much simpler my life has become since I switched to Python+Django. There's just so many things I don't have to worry about any more. Getting started with Django has been a dream. The documentation is easy to understand and makes so much sense. The Eclipse plugin just installed and worked on the first try (cough unlike Spring cough). Following the instructions in the tutorial project is also straight-forward and everything just works the way it should (cough unlike Spring cough). I am still amazed at how little code I have to type to get something quite complicated to work. It's the complete opposite of Java.

In one day I was able to develop the Python web app to do about 90% of everything that the Java app could ever do. I haven't measured how many lines of code it took to do this, but I'm pretty sure that the Python version is less than half as big, partly thanks to the compact syntax of Python and partly thanks to the excellent libraries that Django provides. The code is a lot cleaner, both at the architectural level and inside each individual file. The only potential source of worries I've found so far is that Django doesn't do connection pooling for MySQL unless you hack it a bit, but I'll worry about that when/if I get there. I read somewhere that Python is exceptionally great if you don't know where you're going. I don't know exactly what this web app is going to do when it's finished, but I know that Django gives me the flexibility I need to try out all kinds of things.

I know that there's probably other frameworks out there that could make my life even easier, but I already spent two days scrounging the net to find info, comparing frameworks, doing tutorials and trying them out on my pc. If I really wanted to choose the best framework for my needs I'd need to research another two weeks or even two months. At some point you just have to get productive, stop searching and take the best thing that springs (..) to mind at the moment. In my case that turned out to be Django.

When talking about productivity a lot of books and articles recommend that you create pressure on yourself by announcing your goals to others. When other people know about your goals you'll feel extra pressure to not lose face with them, and you'll push yourself harder to succeed. Being my usual skeptic self, my first thought is that this doesn't apply to me because I don't judge myself based on what other people think of me. But then again, I might start to feel pressure from this later on. Let's see what happens. In any case, I'll keep posting updates on my project as I go along. It might not be as exciting as cycling around Japan, but bear with me :P

Later!

Posted in Tech