Whenever people think about the next generation of web applications, many people think AJAX. Others think Flex. These two worlds often collide, with many blog entries and articles written on the subject comparing the two, deciding which is the hands-down best technology for you to use on "your" website. The problem that I see with this is: "who decided that these should be competing technologies?" Sure they are separate methodologies, and learning both takes longer than just picking one and going forward with that. But, if you really want to build a quality web application, then it might be in your best interest to tough it out and just learn both. Really, they’re not that different from each other. If you're learning one (or have already learned one), then a lot of that will carry over to the other. JavaScript and ActionScript are both ECMAScript-based* languages, so they are very similar, not only in syntax, but usage as well.
I'll give you a list of what I think are important strengths and weaknesses of the two, but keep in mind, I am happily on the fence when it comes to deciding between them, and I’ll tell you why in a bit.
Flex - strengths
- great for rich interaction and media heavy pages
- has Flex Builder IDE, built off of familiar Eclipse IDE
- Flex Builder has design mode for those non-programmers interested in building Flex apps
- greater access to multimedia components of your computer
- effective use of caching for improved speed
Flex - weaknesses
- ActionScript and MXML, although similar to JavaScript and XML, are not as common in everyday pages
- back button and right-click don’t have desired effects without enhanced coding
AJAX - strengths
- great for large text-based content
- Open AJAX Initiative
- also strong caching (depending on implementation) for improved speed
AJAX - weaknesses
- heavy amounts of JavaScript and DHTML to achieve certain dynamic effects
- no IDE with integrated debugger
- back button can easily be broken with certain applications of AJAX
As you can see, both have their strengths and their weaknesses. It can be appropriate in certain applications to use one over the other, and vice versa. But with that in mind, who’s to say that you can’t use them together? Well you CAN, taking the best from both worlds, especially with the help of a library for Flex, created by Ely Greenfield (one of the original developers of Flex), called the Flex-AJAX Bridge, or FA-Bridge for short. The simple summary of what this does is it allows your ActionScript code to be available to your JavaScript code. For example, if you wanted to change a value in your Flex app such as a panel width, normally you would have to do it through AcionScript with a line of code something like "my_panel.width = 250". But with the FABridge library, you can do this through your JavaScript code, like so: "flashApp.my_panel.setWidth(250)". You can read all about it on Ely’s blog, QuietlyScheming. I think he puts it best by saying…
Smart developers take the time to equip themselves with as many different tools as they can, and great web apps use the right technology for the task at hand
For those of you that were sitting on the fence, looking for a nudge in a certain direction, hopefully I’ve convinced you to stay there. Try this solution out and see for yourself. There’s plenty of room on the Internet for both Flex and AJAX. If you come up with anything cool, feel free to share!
Charles
Trackback URL for this post:
Wp Trackback


Great post!
Thanks for the great post, Charles. There is a lot of hype on both sides of the argument these days, and it is good to see an Adobe guy touting how well they work together. I’m looking forward to getting my hands dirty with Flex and AJAX in the next couple of months. :)
Thanks!
Thanks Andrew. In the next short while, I'll hopefully be posting some tutorials on Flex and AJAX integration using the FA-Bridge that I mentioned. Stay tuned...
Missing points
It seems clearly biased in favor Flex. Missing points. Cost, dependency from Adobe, pretty much undexable by search engines, requires server side install/reboot, …
True, but...
That’s true Jon, there are missing points, but missing both for Flex as well as for AJAX. Note though, that this post isn’t trying to promote one over the other, but rather to encourage the integration of the two technologies for your specific needs.
cost
“but missing both for Flex as well as for AJAX.”
while the cost point clearly puts flex at disadvantage
it’s deliberately missing i’d say
actually, Flex IS free, just like AJAX
Hi Ken. Actually, I don’t think that cost puts Flex at a disadvantage to AJAX. Remember, the only cost associated with developing Flex applications is in buying the Flex IDE, Flex Builder. However, you can get the Flex SDK completely free from http://www.adobe.com/products/flex/sdk/. The only difference is that you get the development environment in Flex Builder, whereas with only the SDK, you will have to compile from the command line. But there isn’t anything you can do in Flex Builder that you can’t do with the free SDK.
So, in terms of cost compared to AJAX, they in fact ARE on even playing fields. I would actually say that this puts Flex at an advantage because, although it (as in Flex Builder) isn’t free, there IS a powerful Flex-specific IDE available whereas there isn't one for AJAX.
Clarification
Hey Jon,
Just to be clear...
- Cost, which as commented on by Charles already is pretty much in the same field. Flex is entirely open source to include the SDK. That's also all you need to develop with, the SDK. If you want the Flex Builder IDE you can pay for it, but there are open source solutions as well. There are even alternative commercial options for example IntelliJ supports Flex development (and they built it all on their own without any involvement from Adobe).
- Dependency from Adobe, would be true only in the case of the Flash Player itself (of which there are even open source options). To be fair, an application developed with Ajax technologies, especially one that's as sophisticated as Flex generally have browser dependencies as well. Ever see "tested against Browser X, version 1, 2, 3?" I'd call that a dependency.
In my opinion, dependency isn't a "versus" statement, but rather a development choice. My application can do virtually everything the desktop does and run all the way back to Netscape 3 with exact, predictable consistency if I inject Flash Player. Or ... My Ajax application can run with a good degree of consistency if I inject a dependency on a browser vendor/version." Not versus - just a development decision that should be based on requirements, not bias.
- The idea that Flash content is not indexable by search engines is largely a myth. Chances are that the application you're going to build with Flex is going to have a login. At that point, I don't want a search engine crawling my private content. The exact same thing holds true for Ajax applications that reach the same sophistication as what Flex offers. If I'm logging into Basecamp (from 37signals) as an example, I don't want a search engine to index that content.
When Ajax is used, search engines in general have a difficult (if not impossible) time accessing that data. Let's not confuse Ajax (largely not indexable) for HTML (highly indexable). As for just Flash content in general, you can query Google for Flash content and get a vast number of results. There are also a number of techniques to expose content from within Flash. These types of problems have been largely solved and are becoming increasingly easy to manage.
- Flex used to require a server installation, but this changed well over a year ago when Flex 2 was released. There is absolutely no dependency on a server whatsoever. You can develop Flex applications using nothing more than the SDK and your favorite text editor. The SDK itself is just an archive, so there's no install - and certainly no reboot.
Regards,
Kevin Hoyt
Adobe Systems, Inc.
Hi, is it possible to make
Hi, is it possible to make an image in an imagegrid of flex application draggable and resizable at the browser by using the ajax libraray to make the image draggable. I’m trying to use the flex-ajax bridge and the ws_dragdrop.js javascript