12.10.07. Catching Up

These periods between posts keep getting longer, don’t they?

I’ve got nothing earth-shattering to talk about. Work’s been very busy, and we continue to be served well by Zope 3. I’m still royally confused by things like setuptools and eggs, mostly in regards to how they work in a Zope 3 world when you’ve already got long entrenched ways of doing software. I could not get a good answer from anyone I asked (in fact, I often got wildly competing opinions). So I’m sticking with our internal make-rake-like-ish toolkit which is primarily helpful for automating checkouts from internal and external repositories. I did have some success with zc.buildout, but I don’t yet foresee a time when I can use it to deploy whole sites/applications. I can barely see a time when I can use it on anything but small projects that are relatively stand-alone. There’s just a big gap between The Way Things Have Been Done and The Way That It Seems That Maybe Things Should Be Done In The Future.

Of course, neither setuptools nor zc.buildout seem to have “proper” releases. zc.buildout is in an endless 1.0 beta (beta-30 at this point), and setuptools is at 0.6c7. Does that mean that it’s not even at release 0.6 quality yet? None of this instills confidence in this hurried developer.

The big problem is the legacy code, which is in CVS. Some of it is being extracted out into individual packages that have the proper ‘setup.py’, ‘buildout.cfg’, etc. Finally. But I have no idea how to apply it to the bigger picture, and I’ve found very little written words that target our situation.

The biggest downside of being so busy with customer related work is that it’s very difficult to keep up with discussions, conversations, plans, etc. And I’m sure that my frustrations with lack of documentation, seemingly unfinished releases, and so on, are really the fruit of other hurried developers. I admire them for at least releasing something. It’s more than I’ve done in a long time. It’s more than I see myself being able to do for quite some time.

Anyways, the revolving door of Javascript toolkits keeps turning. I’m now deeply enamored with jQuery. “Write less, do more”. I like it. I like that it doesn’t trample all over Javascript, and thus plays well with others (especially others that play well with others, like MochiKit). MochiKit is just so big… I think I might make a stab at writing, at least for internal use, a lightweight version that brings many of its best concepts out without overlapping jQuery’s functionality. MochiKit brings many wonderful Python-ic functions and tools to the Javascript table that make general development much easier.

I’m also deeply enamored with zc.resourcelibrary which is a Zope 3 add-on that makes it much easier to manage javascript and CSS resources and their relations to each other. Among other things, it helps save resources when they’re not needed. For example::

if len(rendered_boxes) <= 3:
    return self.just_render_the_damn_boxes(rendered_boxes)
else:
    zc.resourcelibrary.need('fancy.scrolling.library')
    return self.render_the_advanced_widget(rendered_boxes)

I’ve also adjusted my coding style, returning to the underscore_separated_words style instead of the camelCasedWords style, at least for functions, attributes, and methods. This is closer in style to PEP 8 (the main style guide for Python code). The Zope style guide differs on this point, using camelCased instead. And PEP 8 does say that it’s OK, if not downright preferred, to stay true to the style around you.

But one thing I learned from looking through Rails code was that the underscore_style was easier to read, since the underscore acts like a space. And I’ve become a big fan of writing code that communicates intent; that reads like a story (somewhat). Extract Method is your friend. I’ve grown very distrustful of excessive nesting, or of having very long bodies inside of a ‘for’ or ‘if’ block.

That’s about it. Hell of an update, huh? Well, work’s really started to become work, and is quite enjoyable. I’ve got a good flow going and don’t feel I have as much need (nor place) to be an advocate or crank. As I’ve mentioned before, we’ve gotten incredible levels of code re-use by building our internal libraries and applications on top of Zope 3, and we’ve been able to grow them so much that they’re really the first level of framework. It was such a struggle to do this in Zope 2, but in Zope 3 it does fall (fairly) neatly into place. Nothing else in the Python web-framework-whatsit world comes close.

The only toolkit that’s even better? SQLAlchemy. It’s pretty much the only way I’ll interact with RDBMS systems in Python from this point out. And I don’t mean I’ll be writing every RDBMS interaction as an object-relational mapping. SQLAlchemy is great because it provides a good connection / pooling infrastructure; a good Pythonic query building infrastructure; and then a good ORM infrastructure that is capable of complex queries and mappings (as well as some pretty stone-simple ones).

Labels: , , , , , , ,

23.2.07. Flex my Dojo

OK. I don’t get Flex. By my understanding, Flex is the components / widgets from or for Flash. Actually, I can’t find a definition. I’m hitting the main pages, and they all treat me like I already know what Flex is and why I need it. But I don’t. From the buzz I see around the web, it smells a lot like the promises of Java Applets circa 1996. It’s the universal platform - rich internet applications! cross platform! run everywhere! It’s in the browser, so you lose yet another tab / window to some application that’s not quite a full application!

As a life long Mac user, I’m dubious of any cross platform promise. Java with some cross platform toolkit or another has never been a great experience on the Mac. Eclipse fares fairly well, but I’m still very aware that I’m in a different environment. This has something to do with look, but really it’s about feel. There’s a way that I expect my widgets to feel: ways that I can move around in a text field, responsiveness of a button, and so on. Cocoa’s text fields benefit from their NeXTStep ancestry which has provided some powerful and extensible features: basic EMacs keys (ctrl-a and ctrl-e to get to begin and end of line, ctrl-k and ctrl-y for kill and yank to a separate copy/paste buffer); spell checking; in place dictionary lookup; often, a common set of search/replace features including ‘use selection for find’; word completion; etc. Input Managers can be installed for even more control. I used an Input Manager to get word completion in early versions of Mac OS X, before it was a built in feature. Now I use “Edit in TextMate” to edit HTML TextAreas, emails (from both GMail and Mail.app), even to tweak a filename using TextMate’s editing tools. Any Cocoa text field, whether it’s a single line or a large block, can be wired this way without the application’s knowledge.

In cross platform toolkits (as well as most Carbon apps), I lose these features. XUL (Firefox/Mozilla); Java AWT, Swing, and whatever the hell Eclipse’s toolkit is called; and now: Flex. Don’t get me wrong: I like that these toolkits enable some apps to exist on the Mac at all; but I’ve seldom been as productive in them as I have been with native apps.

I took a look at a Flex Quick Start page covering “Building a simple user interface” to see basic Flex in action. As I feared, the controls followed a different set of rules than those I expect. Since the tutorial covered only basic UI, there wasn’t much that was terribly impressive. I didn’t see anything that stood out from what I had seen in rich JavaScript/DHTML toolkits like Dojo and YUI.

So I decided to do a quick comparison - how did some of the basic Dojo widgets compare to the basic Flex ones? I went to Dojo’s “See it in action” tab and looked at the FormTour, which housed some basic widgets including one of the few “rich text editors” that works in Safari. And sure enough, even though some of these widgets had some extra behavior wired in, they were still built on browser native elements. All of my usual keyboard behavior worked as expected in text fields - even in the rich editor.

I can see how Flex may be useful for fast dynamic graphical components, such as charts. Beyond that, I feel like it’s another round of the magical cross platform kool-aid; another round of trying to shoehorn a sub-universe within the sub-universe of the web browser. I think it has its uses, but some people seem to think that it’s the new holy grail of rich internet applications.

I’ve heard this song before, and I’ve been horribly disappointed almost every time. So far, all I’ve seen of Flex is a retread of the promises of Java Applets. I would like to see statements about what makes Flex different. Has it learned from Java Applets and the various “abstract” Java toolkits that promised a common UI everywhere? Does it have a focus, or will it devolve into servlets and enterprise architecture? Is Flash still an animation platform, a movie player platform, or a GUI/Form platform? Can it handle all of the above? Will Adobe be wiser than Sun and avoid big clashes with Microsoft?

My gut says not to trust it.

Labels: , , , , ,