Adobe, Apple, iPhones, iPads and the Flash Player – my two cents

There have been some nasty fights recently between Apple and Adobe regarding allowing the Flash Player to run on mobile Apple platforms, which is starting to descend into massive criticism of the Flash platform itself.  I guess its obvious which side of the debate I am going to be on and here is some of my reasoning:

  • One part of Apple’s beef with Flash is that it munches performance and battery.  In fact, Flash isn’t inherently a CPU hog, but is a flexible and powerful tool which means that a coder who doesn’t optimize his code well can end up using more resources than they need to.  Apple seem to think that HTML 5 canvas and Javascript will somehow perform better, but it seems pretty obvious to me that bad (or high performance) code in HTML is going to munch just as many resources as its equivalent Flash app.  As a case in point check out the very cool JSNES HTML emulator at – its an awesome project, but just listen to your fan step up as it runs…
  • Another of Apple’s problems is that Flash is a closed platform.  Its true, and I as much as anyone would be happy to see the AVM open up; however, Apple are being pretty hypocritical here – the iPhone/iPad platform (as opposed to Android) is also completely closed.  Furthermore Apple own patents in H.264 (the video codec they are promoting in concert with HTML 5 as the replacement for Flash video) and stand to make a mint out of their ‘open’ replacement.  This sounds like a business tactic to me, rather than any high morals to advance the open source community.
  • As a case in point Apple are quick to mention that even on high powered OS X machines Flash performs badly.  Well, the main reason for this is that Apple block access to certain API required for higher performance, no doubt so that they can then claim that Flash performs badly on high powered OS X machines.
  • In almost all the chat around the web Apple seem to be complaining about one thing (although without specifically saying it); streaming video.  Flash is of course used heavily to deliver video and streaming over the web, but this is a tiny part of what Flash can and does do.  What about Flex, RIAs, applications, etc?  Flash is a fully featured platform which happens to be ok at delivering video but by taking this stance Apple will be blocking everything else that is good about Flash.

Apple seem to think that everything that Flash can do will be replicable in HTML 5 using Canvas, Javascript and CSS.  Even apart from the fact that HTML 5 does not have anything like the feature set of the AVM, lets think about this from a developer perspective for a second and we can pretty quickly see some of the downfalls:

  • Javascript is one of the most horrible programming languages about; in fact its the same as Actionscript 1 which was released in 2000 and then outdated in 2003.  The thought of developing fully featured RIAs in AS1 is horrible!
  • Despite the fact that HTML 5 is a standard, history strongly suggests that its going to perform differently in IE, Firefox, Safari, Opera and every other browser increasing development and maintenance time.  Flash is a plugin, and although this certainly has its negative points at least you can be sure that it will do the same thing in every browser and platform.
  • If there is a bug in the Flash Player, Adobe release a new version which updates itself from within the player.  Imagine if something turns out to be wrong with HTML 5?  Its a standard which means that the bug fix will need to be implemented as a upgrade to the standard, then every browser will need to implement the update off their own steam.  We will certainly end up with a situation where browsers support different states of HTML 5 at the same time.  Adding new features will face a similar issue.

The whole thing feels like Apple playing off consumer loyalties and technical ignorance to try and control as much of the web as they can.  I believe that ultimately this will result either in developers falling away from the Apple mobile platform in favour of devices that support the cross-platform model which will end up damaging their business model.  At which point, no doubt, Flash will suddenly be supported again 🙂

How to stop SWFs caching in the browser once and for all

As Flash and Flex developers know all too well, browsers have a habit of caching SWFs so that when you put up a new version it doesn’t always show up on client machines.  There are two classic ways to get around this – either by manually clearing your cache (and telling your clients to do the same) or by appending a random number to the end of the filename as a parameter which is then ignored by the application but fools the browser into thinking that the file has changed.  The first method is unreliable and the second method causes the SWF to reload every time you visit the page (even if it hasn’t changed) which munches up your bandwidth and your time.

As it turns out, there is a third and far superior way!  With a tiny bit of PHP in your embed code you can make browsers refresh the SWF only when it has changed.  Note that this uses the SWFObject library, but would work equally well with any embedding method.

   1: swfobject.embedSWF("MySWF.swf?version=<?php echo filemtime('MySWF.swf'); ?>", "myDiv", "100%", "100%", "10.0.0");

It works by using the file modification timestamp of the swf as the version number with the result that browsers will refresh their cached copy if and only if you replace the swf with a new version.  Simple and extremely useful!