Brandon's Blog

3/23/2009

Everything Python

You almost have to stop and listen when Zed Shaw writes, and he has in recent times adopted a more people-friendly personality.  He wrote a favorable article about Django that really captured my attention over the weekend.

I’m sure part of it is the interest of reading a Ruby/Rails self-exile’s thoughts on Python.  I try not to get too religious about Python, but the more I write it and read it, the more I really believe in its power.  Python 3000 seems like it will be outstanding, and I look forward to porting Sigma over when the time is right (we won’t have very many deprecated features, probably just some string library fixes and maybes some class tweaks).

Another point of interest is my prior work on the PHP CMS, which, while a resounding success in terms of final code quality and design elegance, was a painful write.  I believe I first became familiar with the term CRUD while coding the engine.  It’s a humbling amount of “stupid code” to implement a truly user-facing interface to everything, even in something as basic as a CMS with minimal features.

What if the user types a letter into a number field?  Input validation (especially in the filth of PHP syntax and structure) and edge-case prediction becomes your life.  It’s not pleasant.  You write ten lines of straight business logic and float on air for a week.

So then I read about Django, and how you just plug junk in and get an administration site.  Then you realize that all this stuff is so ripe for code reuse its amazing people haven’t done better making that happen.

The boilerplating that Ruby on Rails does seems really cool in the tutorial, and then you start with the “but I’m special because…” stuff and realize a lot has to be redone.  I’m sure with more familiarity it would feel similar to the impression I get from Django, but RoR felt weird to me for some reason, maybe just because Ruby has always felt weird to me.

[As an aside, my feeling about Ruby is like if you were to design a tonal language for general communication.  And you had a way to write it down, but you instead encourage people to talk it as much as possible.  And, you designed the language such that when you recite the pledge of allegiance the tones arrange themselves to play Yankee Doodle.  And every time you teach anyone your language you teach them the pledge of allegiance because you know everyone will see how cool it is that such a thing could just work out.

Then, your student takes his stuff home and tries to write an English report with it.  He figures out that he (1) has to write it down, and (2) reading it out loud sounds like cats fighting outside his window.  The student blames himself, assuming there is some way to put everything together such that the tone is beautiful.  But the cartoon foxes don’t prove as helpful as one might think…

Anyway…]

But the admin interface… seriously, how special could it be?  And it’s not like you can’t make changes.  It seems like Django lets the admin stuff kind of demand-pull the proper stuff into the generated pages.  It seems gorgeous.

I wonder how little time it would have taken to implement the CMS in Django.  I wonder how many lines of code…