FLASH VS AJAX
They are the household names for dynamic design on
the web – but which is best? Time for us to hold our own
doorstep challenge and stoke the fires of debate to see which
next-gen technology rules the roost
AJAX and Flash have matured into
powerful, stable software platforms
that can support nearly any sort of
application. The question “which
technology do I need to use?” has
become “which technology am I
most comfortable with?” The final
decision may have more to do with
the process and tools you are familiar with and the resources that are available
to you than the limitations of a particular technology.
That said, there are areas where one or the other clearly wins out. As we have seen
with the rise of YouTube and its countless imitators, video is an area where Flash has become
dominant. Conversely, template-driven sites with significant back-end integration are still almost
always built with HTML, CSS and JavaScript. As a developer, it is your job to understand the pros and
cons of each, and to make intelligent choices.
Before pitting them head to head, we want to provide a brief overview of each technology.
THE OPENING GAMBIT
Adam Pasztory, a web developer with a host of experience in web development
and consultation, outlines the merit in making comparisons between Flash and
AJAX. The feature continues with a case for each technology and concludes with
an overview on the epic duel.
No technology provides a perfect solution to the problems you will face as a
developer. You want to select the best tools for the job at hand. As a developer, it is
important to be familiar with a variety of technologies and to be able to compare their
strengths and weaknesses. When a client comes to me with a new project, I try to give
them a fair opinion about what the best approach will be for them. The last thing you
want to do is to force them to use a technology that they are not happy with. A lot of
companies simply don’t have a high comfort level with Flash, so you may need to sell
them on it by explaining the potential benefits. AJAX is usually an easier sell to clients
because it is more closely related to familiar technologies.
THE CASE FOR FLASH
AT THE TIME when AJAX arrived on the
scene, Flash was going through significant
growing pains. Adobe acquired Macromedia,
and many Flash developers feared that the
unique vision that made Flash special would
be lost. Indeed, the most exciting advances
in Flash were coming from the open source
community. Meanwhile, Microsoft was waiting
in the wings with its new RIA technology,
Silverlight.
Fortunately, the Adobe management
were smart enough keep their hands off
and let the former Macromedia employees
keep doing what they did best. The
company quickly put any scepticism about
the merger to rest by unleashing a slew
of new technologies related to Flash that
were greeted positively by the developer
community. It didn’t hurt that these new
technologies underwent extensive public
beta periods on the Adobe Labs site, during
which developers could acquaint themselves
with the tools for free.
The Flash Player 9 upgrade introduced
mind-blowing performance improvements
that made learning the new language
worthwhile. Real-time 3D graphics and
online video suddenly became
a reality. And in a bit of a
departure from previous release cycles,
major new features, such as fullscreen mode,
were released as minor upgrades to Flash 9
as they became available. With ActionScript
3, they rewrote the underlying of Flash from
the ground up. AS2, while useable, was a
hotchpotch of inconsistent usage due to
its dependency on previous versions of the
Flash Player. By drawing a line of demarcation
with AS3 and essentially rewriting all their
objects from scratch, Adobe engineers made
a bold break from the past.
Finally, with Flex Builder, Adobe created a
development environment targeted squarely
at developers as opposed to artists and
designers. Professional programmers often
dismissed the Flash Authoring Environment
(or IDE) as simply an art program because
it didn’t look like a typical programming
environment. Flex Builder allows developers
to write their Flash programs in an IDE
called Eclipse, which is popular among Java
developers. To get started in Flash, it was no
longer necessary for programmers to learn
arcane concepts like timelines and
Movie Clips. Moreover, Flex Builder
shipped with a slick set of user
interface components that were
easy to get running in minutes.
Previous attempts to introduce
standard components into Flash
had been a debacle, so the
Flex components represented
a major breakthrough.
THE CASE FOR AJAX
AJAX IS NOT so much a particular
technology, but a movement. The individual
components of AJAX existed as far back as
the mid-Nineties, but the movement did
not coalesce until Google and a few other
prominent companies championed AJAX
with killer apps that ushered in the age of
Web 2.0. AJAX became a more practical
option as PCs became faster. JavaScript
running in a browser is particularly slow
because unlike ActionScript, it is interpreted
by the browser at runtime. An analogy
would be a multilingual speaker attempting
to perform a live translation of a written
work, as opposed to translating it ahead of
time. AJAX gained traction because it no
longer mattered that JavaScript running in a
browser was slow – it was fast enough.
When AJAX first came on the scene,
proponents argued it was inherently
superior to Flash because it was based on
the core technology of the web. To them,
AJAX promised to eliminate the confusing
interfaces and other usability problems that
seemed to appear in every Flash application. This was
a mistaken assumption. What people didn’t
acknowledge was that the ascension of AJAX
was part of an evolution from web pages to web
applications. Links and simple controls were no
longer adequate to express the functionality
needed to take the web to the next level
(Web 2.0). A slew of widgets were written
including tabs, menus, slider bars, colour
pickers and interactive charts. Though some
of these widgets were fantastic, many were
no less confusing than Flash UIs, and they
were hampered by performance issues.
AJAX developers also had to adapt
themselves to the methodology of building
state-based applications. That is, when
a user takes some action on a page, the
browser does not load a new page but rather
reconfigures the current page to a new state.
Integrating state-based applications into
a web browser presents significant design
challenges: what happens if the user pushes
the Back button? Does the application
undo the last action on the page or does it
load the previous page? What happens if
the user tries to bookmark the page in its
current state? Can the application return to
the bookmarked state or is work lost? Flash
developers had already been struggling with
these problems for years.
Cross-browser compatibility issues have
also been a scourge on even the most
erstwhile AJAX developer. It horrifies us
to contemplate the countless hours the
developer community must have lost to
minor browser glitches. How simple life
would be with Firefox, Opera and Safari, but
no IE.
AJAX might have died a premature death
had not a slew of libraries and frameworks
swooped in to save the day. It seemed a
new AJAX framework would pop up nearly
every day, but now a few have risen to the
top: notably Dojo, jQuery and Prototype on
the open source side, ASP.net AJAX from
Microsoft, Google Web Toolkit (GWT), Spry
from Adobe and the Yahoo! UI Library.
Frameworks vary greatly in approach. For
example, GWT is written using Java and
then compiled down to JavaScript. However,
frameworks share the goal of making
programming more pleasurable by enforcing
consistency, and allowing the developer to
write code that can run in any browser.
This brings us to the Flash platform, which
shares the same goals with AJAX frameworks
but tries to remove the browser from the
equation entirely by isolating the application
within the Flash Player.
BROWSER INTEGRATION |
|
Plug-in required, but it is nearly ubiquitous. Flash content is limited to a
rectangular area, however, it can be designed to scale with the
browser window.
|
JavaScript is natively supported by all browsers. Many browser controls can
be scripted (eg, status bar, back button, etc).
|
| AJAX WINS |
COMPATIBILITY |
|
There are only minor variations between the versions of Flash. The Flash
Player works well on all browsers dating back as much as ten years.
|
There are major differences between browser versions. Legacy browsers
do not support new features. AJAX frameworks can alleviate compatibility
issues.
|
| FLASH WINS |
SERVER INTEGRATION |
|
Most back-end platforms provide some sort of integration with Flash, but
often only as an afterthought. There is no simple solution available for
dynamic generation of Flash content.
|
Most back-end platforms provide seamless integration with AJAX,
including code generation.
|
| AJAX WINS |
PAGE LAYOUT |
|
Fixed layouts are still the norm, though new components have opened the
door for more flexible layouts.
|
Direct access to the document object model (DOM). Fixed and liquid
layouts are supported.
|
| AJAX WINS |
FONTS |
|
Font embedding at the character level. Text can be scaled and rotated, as
well as animated.
|
Limited default font selection makes most applications look alike. Font
embedding is clunky and seldom used. The browser always has the final say
as to how fonts are displayed.
|
| FLASH WINS |
RASTER BITMAP GRAPHICS |
|
Graphics can be embedded in an SWF or loaded dynamically. There are
powerful features for manipulating images at the pixel level.
|
Images can be loaded dynamically. Image manipulation requires serverside
tools such as ImageMagick.
|
| FLASH WINS |
VECTOR GRAPHICS |
|
Extensive support. Vector graphics can be embedded into SWFs or
generated programmatically at runtime
|
Firefox has a native SVG implementation, but this will not port to other
browsers, which have conflicting standards. The Dojo AJAX framework has
a set of vector drawing functions.
|
| FLASH WINS |
AUDIO |
|
Audio can be embedded directly into SWF files, or can be dynamically
loaded from MP3 or AAC files.
|
Supported only through external plug-ins (like QuickTime and Windows
Media Player).
|
| FLASH WINS |
VIDEO |
|
Flash dominates video distribution on the web. Several codecs are
supported, including H.264.
|
Supported only through external plug-ins (like QuickTime and Windows
Media Player).
|
| FLASH WINS |
CSS |
|
Applications can be styled with CSS, but the support is limited and not
standardised. Most Flash applications do not use CSS.
|
Full support for complex style sheets.
|
| FLASH WINS |
PROGRAMMING MODEL |
|
ActionScript 3 and Flex provide a cohesive foundation for programmers on
par with other major object-oriented languages like Java.
|
JavaScript is long in the tooth, and applications often have to resort to hacks
and clumsy coding constructs. AJAX frameworks do alleviate the pain to
some degree.
|
| FLASH WINS |
DEVELOPMENT TOOLS |
|
Flex Builder and the Flash IDE are fully fledged development suites. Strong
open source alternatives exist as well, such as FlashDevelop.
|
Big-name development tools like Dreamweaver and Visual Studio are
still perfecting their support for AJAX. Aptana Studio has also arisen as an
impressive alternative.
|
| FLASH WINS |
SEARCH ENGINE OPTIMISATION (SEO) |
|
Flash applications are impenetrable to search engines, and usually rely on
an HTML wrapper for meta-tags.
|
AJAX can more easily control meta-tags, browser URLs and other content
that search engines are paying attention to.
|
| AJAX WINS |
OPENNESS |
|
Flash applications are a black box. In Flex Builder, developers can opt to
publish their content with a View Source feature. Flash applications may be
more difficult to maintain.
|
AJAX code is open to the world. Applications can be more easily
aggregated and mashed up (cf. GreaseMonkey). CSS files can easily be
swapped to alter the look of a page.
|
| AJAX WINS |
MOBILE |
|
Flash Lite has limited penetration among handsets, and relies on a dated
programming model. No iPhone support.
|
Mobile browsers support AJAX to varying degrees.
|
| AJAX WINS |
GOING OFFLINE |
|
Adobe AIR allows you to easily port Flash applications to the desktop.
|
In addition to Adobe AIR, there are a plethora of technologies for taking
AJAX offline, including Google’s Gears.
|
| AJAX WINS |
CLOSING STATEMENT
The chart that accompanies this article identifies key components of a web application and attempts to declare
a winner for each one. In some cases, it was a very close call. Of course, developers have to make choices based
on the nature of the application they must build. As a general rule, applications that are comprised primarily
of text and static images are best created in AJAX. On the other hand, multimedia applications and games
more naturally align with Flash’s feature set.
My hope for the future is a world where Flash and AJAX can coexist seamlessly. Perhaps the
future is not so far off. Already, with a language called Haxe (www.haxe.org) you can
compile the same program into Flash (both 8 and 9) and JavaScript. Meanwhile,
Mozilla and Adobe are working on the Tamarin Project (www.mozilla.org/
projects/tamarin), which aims to unite ActionScript and JavaScript as
a single language. Until this perfect future, we must do the best
with the tools we have. Fortunately, they are an impressive
set of tools, and the future is bright regardless of
which side your loyalties lie.