Flash vs. Ajax: It’s time to expand your toolbox 14 September, 2007
Posted by endweb in Ajax.1 comment so far
I’ve decided not to write the obligatory SXSW wind down post as all your favourite bloggers already have and there’s no point in adding to the pile but I’d like to talk about one particular topic that came up in Jonathan Boutelle’s Ajax or Flash:What’s right for you? panel. In the panel he talked, quite generally, about the relative advantages of each platform, examined services like You Tube, Slideshare and several others and essentially came to the conclusion that both have their place and are not mutually exclusive. In fact, it seems that hybrid Flash/Ajax applications have the best of both worlds and that developers who’s skills lie in both Flash and Ajax will become more and more valuable.
For quite a large proportion of my career I’ve been a Flash developer starting round about Flash 4 with my final commercial work being done with MX 2004. I was even a beta tester for MX at one point. In fact, thinking about it I’ve probably spent an equal amount of time working with Flash as I have with JavaScript but of late, and mostly since the Web Standards movement took hold, I’ve been working in the field of HTML/CSS/JS (for front end work) almost exclusively so this panel struck a cord with me. I left the room with a mission: update my Flash knowledge by learning about ActionScript 3 and Flex 2 but more importantly examine more fully how Flash can fit in with more modern (read: trendy) web development trends like REST, semantics and friendly URLs and how this can all interface with JavaScript and HTML…
Flash has some really quite incredible features that we struggle with implementing with HTML/CSS/JS: Sound, Dynamic vector drawing, Sockets, local storage, video. I could go on. Why the hell are we struggling with <canvas> and VML? Comet is essentially a hack while XMLSockets are built in to Flash…and then you have Red 5. To add to this, Apollo has just been released which is looking pretty interesting. See what I mean?
The sweet spot for JavaScript and Ajax has always been for those small, progressive enhancements rather than for creating rich interfaces. It seems to me that the more you head in that direction with JavaScript the more serious limitations you encounter. Browser JavaScript is never fast, has memory leak issues, browser bugs, CSS bugs and all manner of other tom foolery that, when you get to the stage of building something like for Google Maps get’s really time consuming and messy. There are many efforts (WHATWG, Tamarin etc etc) that are working toward solving many of these problems but for now and for the foreseeable future we are stuck with em. This, I think, is when it’s time to bring out Flash. Not for the whole app of course, but used in conjunction with HTML/CSS/JS. Flash however is not without it’s problems.
I lost interest with Flash mainly for these reasons:
Monolithic applications: Flash apps tend to exist at one URL, fail to respond to the back button well and generally work within their own environment in the browser rather than working with the browser.
Bad programming environment: Working on a Flash app with more than one person was always a pain in the arse. Because a lot of the app was contained inside one or more FLA files which could only be opened by one person at a time and it was a binary file version control was a pain.
Controls didn’t work enough like browser controls: The in-built components helped a bit but Flash select boxes, scroll bars and other widgets just didn’t look or act the same. Bad for usability.
Accessibility no-no: Previously SWFs where essentially a black box to assistive technologies and event MX components seemed to have trouble with keyboard focus and tabbing. * Limited and tedious interface with JavaScript: Getting data in and out of the SWF was possible but never easy.
ActionScript is heading toward Java: Oh man, don’t get me started. As ActionScript develop it becomes less and less dynamic. `You get native classes and packages but type annotations? I suppose you get a performance boost but really. Static types are for stupid people…we don’t need em
It’s not open source
After re-examining these many are solvable, avoidable or have been solved recently. Solving the first problem is probably the most interesting of the lot. We all know the internet works best when it’s used as a linked web of resources. To do this each resource in the flash application needs it’s own URL even if these all just point to the same SWF. I’ve not seen this done but I’ve got some ideas on how this could be achieved. What I’m thinking is that rather than a Flash app having one end point, eg. flashpaint.com it can have an end point for each document that can be favourited, linked to and all that shit eg: flashpaint.com/pictures/dans-bum. If we architected an application like this it would be easy to use the end point to provide different formats eg. flashpaint.com/pictures/dans-bum.svg etc.
The bad programming environment problem is solved for us. Flex 2 is all text based and although a bit XMLy for my liking isn’t bad. You can even get a Textmate bundle for it. Most importantly you can lob it all in version control. Better. Accessibility has also been greatly improved of late, I don’t yet know the details, but I do know it’s no longer a black box.
The interface to JavaScript has been improved too with the Flash/Ajax bridge (stupid name aside) but I think this can be improved further. It’s all a bit heavy on code and complex but sure it can be streamlined some. Unfortunately though, ActionScript continues it’s journey away from the land of dynamism but on the upside you do get E4X and all kinds of other nice stuff and we can’t do much about it. Even JS 2 is going this way.
Then finally, there’s the whole open source thing. Where do we start? I’ll start by saying that I’m not a religious person neither spirtually or technically. I’m a pragmatist and while I normally work in open source with its many benefits I can take a bit of proprietary action if need be. I’ve heard many members of the web standards and ajax communities basically strike Flash off on this point alone which to me is just insane. It may be proprietary but it’s got a great community around it (and a great OS community for that matter) so that works for me. No, it’s not a standard, but really, what have standards done for us anyway? The power of the ‘web standards’ movement was, in my opinion, more about moving back to semantic HTML and the separation of content and presentation rather than about valid code and standards anyway. I say drop your prayer book and use the best tool for the job.
So yeah, I’ll be looking in to Flash and Flex then. I might even write about it. But then it seems other people already are which is cool. So what do y’all reckon? Am I barking up the wrong tree?
PS. That comment about Static typing was totally unqualified and slightly stupid statement. I like it though. It’s the kind of thing you’ll catch me saying after 5 pints at Pub Standards.
source danwebb.net









