views:

1270

answers:

11

In a recent conversation, I mentioned that I was using JavaScript for a web application. That comment prompted a response: "You should use Flex instead. It will cut your development time down and JavaScript is too hard to debug and maintain. You need to use the right tool for the right job." Now, I don't know too much about Flex, but I personally don't feel like JavaScript is too hard to debug or maintain, especially if you use a framework. JavaScript is also one of the most used languages right now, so it would seem a better choice in that regard too. However, his reply piqued my interest. Would Flex be a good choice for a distributable web app for which 3rd party developers could build add-ons? What are the advantages of using it vs. a JavaScript framework? What are some of the disadvantages?

+11  A: 

I have recently started to develop Flex applications, and I personally find it a refreshing framework for the web.

You get a state-ful application that runs completely client side. You get no worries about cross-browser portability that you do with JavaScript, and you get some really neat things such as effects, graphing, and rich user interface components.

Flex also makes it easy to communicate to webservices and the XML parsing via ECMA is insanely powerful and simple.

I'm glad I have made the switch. As far as how popular it is...I'm not really sure, but I am fairly certain that the developer base is expanding rapidly.

The only real disadvantage I can think of is a flash player requirement, but I would say it is pretty safe to assume that most browser support flash player; even konquerer in Linux is supported; much more so then a silverlight runtime (which I NEVER plan on installing)

mmattax
I guess most users will get silverlight with IE8 or windows update - automatically same way you get GoogleGears if you install Chrome.
Jakub Kotrla
To add to this, Flex is a good option when doing *rich* applications such as media-heavy or graphics-heavy (that's where it shines), it would be overkill for something mostly text-based.But then again, Flash Player 10 has some kick-ass text layout features too :)
Swaroop C H
Flash works so-so to poorly on Linux and not at all to poor on BSD to the point most of us don't bother. Javascript runs everywhere, including mobile.
Rob
+1  A: 

GWT lets you do the same stuff as Flex for the most part, and handles all the browser compatibility issues, AND lets you code/debug in Java with your favorite IDE.

All without having to learn a new language (or pay Adobe $$$ for the flex IDE you'll need to do anything real).

Flex has some prettier UI widgets than GWT has out of the box, but there's a ton of 3rd party widgets (such as GWT-EXT-JS) you can use - or, you can use your existing favorite JS widgets with GWT.

Check it out if you haven't: http://code.google.com/webtoolkit/

I only use the open source Flex SDK and can make "real applications" sounds like you depend to much on an IDE...and the OP wasn't asking about GWT.
mmattax
+1  A: 

I can't be sure if it was myself, or someone else who made that statement but I would definitely be one to say 'use the right tool for the job'.

Flex has a large community behind it, and is well hyped by Adobe's platform evangelism team. Now, as far as replacing JavaScript, that sounds like a very broad spectrum discussion point. Flex is not a replacement for JavaScript. What it does, it does well, however. That is, 3D, drawing, and data rendering whether in chart or table form. Flex also has the power of ActionScript 3 behind it which allows you to do much of what Flash does in cooperation with the MXML frontend components without ever touching the timeline or keyframes.

In a way, Flex is the .NET of Flash and Rich Internet Application development. It uses the same datasource concepts, and component focused design structures which make it easy, and fast to develop in.

The real question is, what are you trying to achieve? What is the end goal?

As to the debugging point, Flex has a true debugger and profiler within the Flex Builder IDE. JavaScript, unfortunately, has different syntax and execution between browsers due to the nature of JavaScript engines in modern browsers. Flex, because it is essentially Flash, uses the same rendering engine in all browsers due to the use of the Flash plugin.

Hope that clears a few things up. :)

Abyss Knight
Thanks for the information. It helps.
VirtuosiMedia
+1  A: 

Flex has a lot of extra overhead:

  • New language
  • Clients must have flash installed (might need to install, might not be able to)
  • Clients must download flex framework (few hundred kilobytes)
  • Flex content is not indexed by search engines (contrary to what Google might claim)

Flex has one main advantage: - Better at building rich interfaces (see Picnik.com, etc)

For example, in Flex, it is easy to create a custom styled dialog box, complete with drop shadows, inner glows, animated open, whatever you might want.

In summary, use Flex if you need the extra richness.

Brian
Thanks. I didn't know Picnik was written in Flex or that clients have to download the Flex framework.
VirtuosiMedia
By 'download the framework' he means that much is added to the Flash file's download. There isn't a separate download required.
Abyss Knight
+9  A: 

I would push you towards standard web development technologies in most cases. Javascript is no longer a great challenge to debug or maintain with good libs like jQuery/Prototype to iron out some of the browser inconsistencies and tools like Firebug and the MS script debugger to help with debugging.

There are cases when Flash is a better option, but only in cases where you are doing complex animations. And, if you are willing to invest the effort, most animations can be achieved without resorting to flash. A couple of examples...

Flash content is not as accessible as other content.
This will not only affect people with out flash, but also search engine spiders. There may be some hacks to help get around this now, but I think that most flash content will never be indexed by google.

Flash breaks the web UI.
For example:

  • If I click my mouse wheel on a link, that link is opened in a background tab. In a flash app there is no way to simulate this behavior.
  • If I select text in my browser and right-click I get options provided by the browser that include things like "Search Google for this text". In a flash app those options are no longer there.
  • If I right click on a link or an image I get a different set of options that are not available in a flash app. This can be very frustrating to a user who is not "flash savvy".
Prestaul
That's the way I was feeling as well, but I think you articulated it better than I could have. For most projects, I tend to shy away from Flash as a solution and will use JavaScript where I can. Great examples, by the way.
VirtuosiMedia
The biggest thing for me is that - because the content in those examples is all just html - anchors are anchors. Every browser has different features associated with links. There is no way in flash to ever get that functionality for a link, the most fundamental element of the web.
Prestaul
Not completely true... Flex 3 has added support for HTTP like interaction, things such as deep linking and Javascript access.
mmattax
"HTTP like"... There is still no way for flex to determine what the browser would do with a link. When I middle click a link it opens in a background tab. My wife has FF set up to open the link in the foreground. It looks like a link and acts like a link (most of the time) but it isn't a link.
Prestaul
and Flash doesn't work on iPhones. And if you have a teenage audience, then its definitely not the way to go.
Alec Smart
A: 

Aside from what's already been mentioned here, another major difference is that JavaScript is dynamically typed and ActionScript is statically typed. Whether that's good or bad will depend on your point of view :).

17 of 26
A: 

If you want your web application to look like it's not a web application, Flex is pretty good. You also get to sidestep all the messiness of making HTML+JS look like a real app. For something which is essentially a website, Flex might not be the best choice, but if you really want to write an application which happens to be accessed through the browser, it's quick to develop with and gives great looking results.

MidnightGun
+10  A: 

Here is my experience: you really need to consider 2 things separately - development and the end-user experience. Flex shines in the first area:

  • ActionScript is a nice mixture of Java and JavaScript so you get a familiar language with strong support for OOP
  • debugging is far easier than what you can achieve in JavaScript
  • Flex framework is component-oriented and event-driven which helps in creating rich user interfaces (HTML was not really created to support application UI scenarios)

On the other hand, the end-user experience is worse when running a Flex app compared to an AJAX app. First, you need to have Flash Player installed but this is probably not an issue for most computers today. Bigger problems are with usability - Flash Player handles all UI interactions (instead of a browser) so the password manager doesn't work, text fields don't remember previous entries, Ctrl+T and middle-clicking doesn't work, text search doesn't work etc. etc.

My advice would be - if you are developing an application (rich UI, relatively separated from the rest of the web), go for Flex as it will save you time, money and will make your users happier by providing richer functionality and shorter periods between new versions. On the other hand, if your application needs to be tightly integrated with the web and you want your users to be able to use features of their browsers, go with AJAX.

Nice example is Google Docs vs Buzzword. Buzzword is much more feature rich (for instance, text can flow around an image from both sides which is something you could never ever achieve in DHTML) but Google still decided to go for an AJAX version because they are the "web company". There is no right or wrong in doing it the one or the other way, it's just different and it's important to consider who your end users are.

Borek
A: 

You should try Google Gears instead. Create your application, add some Gears to it, and you can greatly increase the speed (and reliability) of your application.

http://gears.google.com/

Essentially Google gears gives you access to two useful things for any application: offline data storage, and native threading control (allowing updates/computations to run in the background and not slow down the users computer).

The really nice thing is, you can use whatever Framework you like for your application, as long as data storage/retrieval and server side communication is handled with JavaScript.

It also allows you to cache whatever files client side you want, which is especially useful when you want to avoid that 'flickering' look in the browser while some needed image is being downloaded by the browser.

David Wees
A: 

A few reasons to consider Flex:

  1. The control library is much richer in Flex than anything you can do with JS/DHTML. The charting controls are killer for business apps and things like the DataGrid / AdvancedDataGrid are pretty well ahead of anything you can do with HTML.

  2. The Flex framework was designed for building applications. It abstracts away the "frame-based" concepts in the Flash Player to really make it easy to build apps. It has a well-designed component hierarchy that makes it easy to extend any of the standard controls. It also has a pretty intuitive event model for handles user inputs and makes it easy to have any of your controls dispatch custom events that can bubble up to parent components or get routed through a central event dispatcher. While it may be possible to do this with JS/DHTML, I don't think it's nearly as easy and it certainly wasn't designed for it.

  3. You can take a Flex application and quickly deploy it to the desktop with the AIR runtime. AIR also offers additional APIs for things like local system access, embedded SQLite DB, etc. Gears offers something similar but it does require a browser. Granted, AIR requires the AIR runtime but at least it's purposed towards building desktop apps.

  4. You can build a very rich, very sexy UI that will knock your users socks' off. As programmers we might not care about UX but our users do. Part of the reason why Apple is having a lot of success lately is because they really value UX and users/consumers are taking note of this.

The biggest con I think is that if you are really used to Java or C#, the ActionScript language will seem a bit limiting. If you're comparing it JavaScript, it's at par or maybe slightly better.

A lot of people will rail on Flash Player (or AIR) because it's not "standard-based." If we were only willing to use sites that were 100% standards compliant and free of plugins, we wouldn't have YouTube today. Or pretty much any other site that does interesting data visualization you can't do with HTML/JS (or at least, not with a sane level of effort). Adobe has been pretty progressive in opening up the Flex framework, Blaze DS (for backend Java development), publishing the AMF spec and starting the Open Screen Alliance to push Flash Player to mobile devices. Flash Player, Flex, Flex Builder and Blaze DS all have public JIRA bug trackers. I'd say there is a good chance that Flash Player itself will be open source within the next 2-3 years. I think Adobe is continuing to move towards being very open and that the criticisms of the platform being "closed" and "proprietary" are becoming less relevant. I think if developers approach Flex/FP with an open mind that they would really be impressed with how it all fits together.

cliff.meyers
A: 

This comparison table was good enough to make me decide what to use . I prefered javascript:)

http://askmeflash.com/article_m.php?p=article&id=11

Sydney