Friday, June 13, 2008

Flex Builder 3: Impressive

I spend an inordinate amount of time writing about Eclipse-based software.  I have to say the platform has grown on me, but there are things about it I still don't like.  One is the all-or-nothing approach to different vendors' add-ons.  I use Aptana, Zend Studio, and now Flex Builder 3, all of which are based on Eclipse.  The problem is this: I could use one base install of Eclipse and install all three of these as plugins, and they would each bring their own perspectives, views, menus and suchlike.  Theoretically, they would all stay out of each others' way and the whole thing would work beautifully.  In my experience doing that however, it meant that context menus were insanely long, there were tons of choices that didn't apply to what you were doing in case you started doing something else, and the whole mess took forever to load.  I eventually deleted the whole thing and did three separate installs.  The problem with that, of course, is that you have three identical copies of the base software, but with hard drives as large as they are these days that's not much of a problem.  

But this wasn't meant to be a continuation of my Eclipse rants.  I meant to write about Flex Builder 3, which I am impressed with, IDE platform to one side.
Flex, which Adobe hopes will be the next big thing instead of Silverlight, or AJAX, is really just Flash dressed in business clothes.  Gone is the timeline, gone the library of images and movies and bits, and everything focuses on what you would do with Flash if you were going to use it for websites instead of cartoons or games.  I approve of that.  Flash and the Flash IDE are great for web animation and games, but the Flash plugin has far too much power to be used only for Homestarrunner.com.  (the only web animation I've ever liked, by the way)

Flex lets you make things that do work.  It's designed from the ground up to work with AJAX-style HTTPRequest objects and accept data from remote sources in plain text, XML, JSON, or RPC notation, your choice.  It is built to easily display multi-page forms, and making transitions between pages is as simple as giving the transition you want an id in the XML source code.  I've done RPC-type stuff in Flash 8, and while it's possible, it isn't fun or easy.  It's both in Flex.

Much has been made of the AIR framework, allowing you to write apps in Flex and deploy them to the desktop, so all I'll say is "You can write apps and deploy them to the web or desktop. That's cool".

Most Flex apps will have three parts: the XML (all in the mx: namespace) that defines the objects in the app, the Actionscript that defines what the app does, and the server-side code that gets and sets data for the app.  The first two parts are handled in Flex proper, while the third can be written in any language with which you are comfortable.  I mostly use PHP, but RoR works just as well. As long as your server understands the requests coming in (GET or POST, by the way) and can send intelligible responses back, you're set.
The XML part is very similar to XHTML, with specialized options for more advanced forms or displays.  XHTML doesn't have a , but MXML does have an that accepts external data and lays it out in a scrollable, editable table.  Tags have predictable id properties, will accept style, height, width, and other properties that you would expect to give them if you were writing XHTML.  The Flex Builder application makes all this easy to do with good tooltips and a context-sensitive help menu that usually lists the API for whatever component your cursor is in at the top of the list, a far cry better than Flash 8's help function. Unlike any other WYSIWYG editor I've ever used, I rarely find any reason to argue with the code the "design mode" editor writes.  If you know what you're doing you can set farily complex style rules on things from design mode and the code will be clean and valid.  There are advantages to being in charge of the IDE and the parser.  the namespace is tightly controlled, and I appreciate that.

Actionscript is Actionscript, so if you've ever used it in Flash you're ready for Flex.  I've been told it's quite similar to JavaScript, but, embarrassingly, I've never gotten around to learning JavaScript.  Sorry.  On the plus side, Flex apps will run on any browser that allows Flash, no JavaScript required.  

All in all, I only have two problems with the Flex builder: the first is the Eclipse strangeness mentioned earlier. The second is the price.  I got Flex Builder for cheap because I'm an employee of a university.  Most people pay hundreds of dollars.  (although they are giving it free to students).  To my mind, charging a lot for the IDE isn't a clever way to take over the internet.  Yes, the API is free and open-source, but writing the code entirely by hand without a debugger and code tips and all that isn't fun, and few people will do it.  

Still, in spite of these two drawbacks, Flex is an elegant solution to getting content rapidly designed, tested and deployed, and in a world where almost everyone has Flash installed on their computers, It's an attractive alternative to AJAX.  Give it a shot.

0 comments: