Back from the Beyond

October 20, 2006

So as I said I would, I've taken a look at Python and Django. In my brief look at it, I've learned a few things. One is that Python isn't that weird, it's just different. Handling blocks based on indentation is cool. Django is cool in a lot of ways. The thing I was most impressed with is the admin interface. The thing I was least impressed with is that the admin interface isn't very customizable. You get you what you get, which is a lot, but you don't have much control over it.

But this blog post isn't really about Python or Django specifically, it's about languages and web frameworks. Here's what I've decided. Choosing a web framework and programming language is like choosing a guitar. There are die hard fans of different types. There are obscure niche types. There are widely used types. There are even variations among the different types. But the bottom line is that if you are a shitty guitar player, it's going to sound like shit, not matter which one you pick. And if you are a great guitar player, anything is going to sound pretty good. Choosing between them is really a matter a preference. The part where this analogy falls apart is that once you learn to play guitar, you can pick up any guitar and play, but just because you are a Ruby on Rails expert doesn't mean you can build a web site with Java, and vice versa. So it's not perfect, but you get the idea.

I think up until recently, you couldn't argue with a straight face that building a Java application is not more complicated than building a Ruby on Rails app. Anyone who has tried to maintain a web app built with Struts 1.x, Spring, Hibernate 2.0, JSP 1.0 and an overly complex set of ant build scripts can attest to that. But I'm a believer in the latest innovations in Java. Annotations and Generics are making life easier. Stripes and Hibernate 3.2 with Annotations are much better than Struts (or webwork or Spring MVC for that matter) and Hibernate 2.0 respectively. JSP 1.2 is better than JSP 1.0, Maven is better than Ant, the list goes on.

My theory is that we are at a point with Java where we can build applications with the same level of productivity as any other framework. I think we're beyond Beyond Java.

So what I'm planning on doing in attempt to prove Bruce Tate wrong is to build a new version of my own blog in Java. I'm hoping this little side project will give me a chance to provide the world with an example of how Java applications can be built without endless XML sit-ups. I also feel the need to blog about it because it will motivate me into actually doing it. I have had lots of big ideas in the past and I rarely follow through with any of them, but this is one that I intend to. And so it begins.

Posted in Technology | Tags Django, Python, Stripes, Ruby, Java, Rails | 16 Comments

Python is Weird

September 20, 2006

I've heard some good things about the Django framework. One thing that as me interested in Django is that the way it works in general is you define your domain model in code, in Python objects, and Django figures out how to build a database for you. Conceptually, I like this idea better than Ruby on Rails, where you define your domain model in the database, and then rails generates objects for you at runtime based on the database metadata. Also, you run it my installing mod_python in apache. Again, compared to rails with apache, FCGI/SCGI, lighttpd, mongrel, etc..., I don't know, let's just say I have found the process of setting up a rails production web/app server challenging. I haven't done it for Django yet, we'll see. Should be a small memory footprint too, making it easy to run multiple apps in my 192MB virtual server webhost.

But one thing I want to comment on now is that I find Python to be weird. Maybe this is because I have done most of my programming in Java, but when I started to learn Ruby, everything in Ruby just made sense, without Java's stupidity, such as NullPointerExceptions and primatives. I've soured on rails recently, but I miss Ruby. The language is succinct and powerful, it almost feels like writing psuedo code, except that it actually works.

Anyway, let me just give a few examples of python weirdness. But before I do, let me say this. I don't know python well at all. Consider these statements to be my first impressions of Python. I'm in no way stating that python is poor language due to these oddities, they just strike me as odd and I feel the need to express it. So, on with the weirdness:

So to get started, I started reading the Django install guide. I noticed I needed python 2.3 or higher. Fair enough, so python 2.5 is the latest, so I installed that.

The next requirement is for MySQLdb. It says it works with python 2.3-2.4, doesn't say anything about 2.5. I decide to install python 2.4 to be safe. So just deciding which version of python to use is a little bit of a struggle.

So now I have python 2.4 and MySQLdb. I want to try and do something simple to verify it is working. I find an example in the docs:

import MySQLdb

c.execute("""SELECT spam, eggs, sausage FROM breakfast
          WHERE price < %s""", (max_price,))

What's with the 3 quotes? Anyway, let's give it a try. First, I add c:python24in to my path, fire up a command prompt, and enter "python" in hopes of getting an interactive shell. Python isn't found. Why not, because the python executables aren't in c:python24in, they are in c:python24. Ok fine, I fix my path, but I decide to use the IDLE GUI instead. I try to enter a query, but I make a typo. I press the up arrow, but it doesn't bring up my previous command. I re-type it and get it right this time. The query is:

select count(*) from users

This returns 9 when I execute the query in mysql. What does Python return?


1L? What is that? Again, I am naive when it comes to python, this is not a fair criticism of Python, I have done very little to learn the language at this point, I just trying to illustrate a point. I know Java well. When I started learning Ruby, from the start, everything just worked as you expected it would. As I look into Python, I find one oddity after another. I'm sure if you know Python well you will consider many of the things in Java odd, so I'm just going to consider all of these things first impressions and move on to learn more about the language and give it a fair chance. But Python is still Weird.

Posted in Technology | Tags Django, Python, Ruby, Java, Rails | 26 Comments

Better Web Apps

March 21, 2006

There is an interesting movie posted on the NASA Object Oriented Data Technology (OODT) Wiki created by Sean Kelly. It compares Java/J2EE, Ruby on Rails, and a couple of Python frameworks. The basic conclusion is J2EE sucks and any of the other frameworks are much more productive. Even though the video is 370MB and 36 minutes long, I suggest you watch, if not just for the entertainment value.

I did have a couple of questions/criticisms, which I emailed to him. Here they are:

First of all, a two part question. What do you mean by each of these things?

data collection - XML feeds? Querying other systems for data? data conversion - Converting data from what to what? archiving/aging - ? query optimization - SQL queries? metadata mgmt - What metadata?

And, why is J2EE better for these things?

Secondly, when you first start talking about what the metrics are for a good framework, you say it should use convention over configuration. To the best of my knowledge, this is a term that was pretty much invented by and coined by the Ruby on Rails crew. (let me know if you think otherwise). But anyway, you are saying convention over configuration is good. Then, when you discuss the drawbacks of Ruby on Rails, you complain about having to use the special naming convention for database tables and columns. Isn’t that just convention over configuration in practice? Sure you have to write “more code” if you need to support a legacy database schema, but isn't that true of the other frameworks as well?

Also, I’m not sure that comparing Plone to Ruby on Rails is fair. Plone is a CMS, which by nature will give you more features (authentication, authorization, i18n, etc.). A CMS is not a web framework. A CMS is built on top of a web framework. Web frameworks don’t have web interfaces to create pages, that’s what a CMS is for. I think comparing Django or TurboGears to Ruby on Rails is more fair. AFAIK, there is no CMS built in Ruby on Rails, so that makes Plone a clear winner in the Ruby on Rails CMSes vs. Python/Zope CMSes, but doesn’t necessary make Python/Zope better than Ruby on Rails.

And lastly, when I get a free moment, I’m gonna have to build the Java/J2EE version of the time tracker. 223 minutes seems a little bit ridiculous. I don’t know about the lines of code, but my bet is that it can be done is less than two hours, if not faster.

But overall, to some degree, I agree with what you are saying. This is the same thing Bruce Tate is saying in his book “Beyond Java”. Other dynamically typed, more object-oriented languages allow you to build frameworks that are easier to use, and developers who use those frameworks will see an increase in productivity.

Posted in Technology | Tags Python, Ruby, Java, Rails, Plone | 0 Comments

<< Newer Articles