The #1 reason (for me) to use Flash or Java over C++ or any other alternative is that games using the first two should be playable, painlessly, by the vast majority of would-be gamers. But how well does that hold up? Here’s what I was able to find:
try to sort out how widespread the support for Flash and Java is,
I did a bit of research. Macromedia claims Flash is the real winner,
with 98% market
penetration, versus Java’s 87%.
But, dig a little deeper, here:
and you’ll see that a lot of that support is for old versions of Flash. The current version (version 7) only has 83% penetration in the U.S. (though version 6 is much better at 95%) And while Java is shown to have an 87% overall penetration, I was unable to locate any specifics as to Java versions. So I did some ad-hoc testing, as follows:
First, I checked the four machines we have in the house, of varying origins. They came back as follows:
All these machines have been used for web browsing and the like for 1-4 years, yet only two of them had the current Flash version and only 1 had the latest Java VM (and that was on my high-end Compaq - I can't remember, but it may have gotten the Java 2.0 VM when I went to install the Java SDK).
So then I went to my local Circuit City to see what was installed on the demo machines there - all current machines running Win XP, presumably assembled in the last 3 months or so. I'm only listing manufacturers here, as software pre-installs are generally uniform across a manufacturer's entire product line:
So, between my menagerie of machines and those at the store, Flash was supported in every case, although frequently it was version 6. Java support was far more varied, with a couple of machines omitting it entirely, and others stuck with the old MS JVM at version 1.1 (dating from 1997).
Note that all Macs ship with Java and Flash (latest versions, AFAIK). Java and Flash can also both run on Linux, though I believe they're rarely included in standard Linux distributions, because they're proprietary, and the default Linux distros only include open source software.
It seems that using Flash and sticking to version 6 is the best way to use a fairly current-version development language and be able to run right off the bat for the vast majority of users. Macromedia's quoted 95% penetration for Flash 6 seems reasonable, given my above data. Note that while Flash 7 has an option to publish SWFs in Flash 6, when I tried it, the resulting .SWF file still wouldn't play on a Flash 6 player. If you plan to publish to Flash 6, my advice is to buy an older copy of the Flash development tools off of EBay.
For Java, it seems like the way to go is to target the lowest common denominator - version 1.1. Even at that threshold though, two of my 11 test cases completely lack Java support. Again, this is in accordance with Macromedia's statistics.
For the ~5% and 15% respectively (Flash and Java) who don't have the product installed, it would appear that for Flash it is easier to add-on, with the download coming in at 700KB, versus 7 MB for Sun's Java. Both installs do require a reboot for Windows users, though.
How will Java and Flash fare in the future?
In general, I see no reason for Flash's prospects to change much over the next couple of years. There's no real current competitor for Flash from Microsoft or anyone else. Microsoft is rumored to be working on a technology called Sparkle, which may be loosely targeting Flash in their upcoming Longhorn version of Windows. From what I've read on Sparkle though, it doesn't really seem like a Flash-killer, and anyways, Longhorn is likely 1+ years from release, and 2-3+ years away from widespread market penetration.
Java's future is dicier. Sun seems to have wavered a few times over the last 5 years in their commitment to Java on the desktop. Microsoft hates Java and would like to kill it. They stopped bundling it with Windows XP in spring '04, and now only those manufacturers who have a deal with Sun include it. (Admittedly, this is similar to Flash's situation, but Macromedia appears to have had success in getting Flash pre-installed on every new PC, whereas Sun's record is spottier).
My seat-of-the-pants estimate is that it's probable that Flash's market penetration will remain high for at least the next 3 years, whereas Java's penetration might begin to slip further in that timespan.
If you want to commercialize your casual game, you have to reach an audience. These days, that means distributing your game through one or more of the ~6 major and ~50 minor game portals (Pogo, Yahoo, AOL, MSN Games, etc). Do these portals have a strong technology preference?
I browsed the major sites and played many of their games. You can usually tell that a browser-game is made in Flash by right clicking on it (which gives you some Flash specific options). Java games are obvious because while they load, a Java-standard loading screen is shown. From this type of inspection, as well as reading a summary of their opinions as of last year's GDC here, it appears that most of them are technology ambivalent - open to either Flash or Java, and in a few cases, still supporting ActiveX as well. A lot has changed in the last year, i.e. the impact of Windows XP Service Pack 2 (which really killed Active X), and the Sun-Microsoft Java settlement (which hurt Java), both events occurred in the last 12 months. But for now, anyways, it seems that both Flash and Java are acceptable to the portals.
There are two kinds of relevant benchmarks to compare Flash, Java, and C++.
Benchmark 1 - Arithmetic
First, you can compare their raw ability to execute code (semi-interpreted for Flash and Java, compiled for C++). Here's my results from a very simple benchmark I performed a couple weeks ago (details here)
processing results (milliseconds to complete benchmarks, lower is
Visual C: 16
For general purpose processing, Java is much slower than compiled C, and Flash is much slower than Java. Since I posted that story, a couple readers posted comments indicating ways that Java might be sped up. Admittedly, I'm no expert - there probably is room to improve the Java results through various voodoo. Flash, on the other hand, doesn't seem to have a lot of options for improvement, performance-wise. It's a pig.
Benchmark 2 - 2D Graphics
Probably the most important benchmark for my purposes is the ability to draw 2D graphics. Can a game with complex 2D graphics run at a reasonable frame rate on the kinds of older PCs often used to play casual/browser-games?
My benchmark was to measure the frame rate of my Snakebite test game. I unlocked the frame rate, added a frame rate monitor, and measured the results on a few different machines. Since the game is so simple, I also wanted a simulation of more complex 2D graphics, with more overdraw. So I tested by drawing the entire screen (background and objects) from 1 to 10X before blitting to the screen. In my estimation, a static-screen puzzler would probably, on average, be most like my 2X overdraw result, whereas a scrolling action game would be most like my 5X overdraw result. Flash is NOT included for now (see below)
In general, the Java versions held up respectably - much more so than Benchmark 1's arithmetic test would suggest. The reason for this is that drawing 2D graphics is primarily a function of memory copying/blitting, and internally, the Java Virtual Machines are undoubtedly executing this with a compiled, native mode function. I only did a side-by-side C versus Java test for the first machine - the AMD, and on that machine, Java outperformed C in the heavy overdraw cases that most closely resemble a complex 2D game. Carrying the Java test across the older machines shows that performance doesn't take that much of a hit as the CPU and video card drop down. Again, 2D graphics are primarily about memory speed (system RAM, not video card RAM), and system RAM speeds haven't been improving as much as CPU speeds over the years. A new machine with a CPU that's perhaps 4X faster than a 3 year old machine will have system RAM that's perhaps 2X faster than the 3 year old machine.
I've listed the Flash results separately, because the testing for Flash had to be done differently, and produced some odd results. Flash is not very conducive to this kind of test. The Flash player manages the rendering process itself. Framerate is capped and can't really be unlocked. Because Flash manages the screen draw (using a dirty rectangle system), using the overdraw system I did wouldn't really work (Flash would just ignore the overdraws). I could only do the 1X overdraws (i.e. no overdraw), and I had to force Flash to draw the whole screen by positioning objects that changed visually in opposite corners of the screen (thereby forcing Flash's dirty rectangle system to consider the whole screen to be dirty.
I initially tested by double clicking on the .SWF file on my desktop, and the results were good - 77 fps on my AMD 3000+, vs. 97 for C and 56 for Java at comparable 1X overdraw levels. However, when I uploaded that same SWF to my website and launched it in Firefox, the framerate was cut in half, to 37 FPS. Running in Internet Explorer also produced a speed hit, but not so severe. I tested on a different machine and found a similar speed drop off between I.E. and Netscape 7.5 (Netscape 7.5 and Firefox share code origins and both use the same Gecko rendering engine). I went back and re-tested my Java results and found that Java performance was the same in I.E. and Firefox. I couldn't test Java outside of a browser as my game was not set up for that.
My best guess is that the Flash player plug-in is particularly optimized for desktop playback, and particularly unoptimized for Firefox/Gecko playback. But it's worrying that, running in Firefox, my simple 2D app only pulled 37 FPS at 640 x 480 on my high-end system. On the lower end system, at 1X overdraw, in Firefox, Flash ran at 18 FPS, versus 28 for Java. For more details on Flash performance considerations, see this article.
Java should be fast enough for any reasonable 2D game thrown at it. Flash should be able to handle any reasonable static screen game. Neither is very good at heavy duty arithmetic (Flash in particular is abysmal at this), so complex simulations (like my Tropico or Railroad Tycoon 3) rely on a lot of math under the hood, and their economic models would have to be greatly simplified to have acceptable performance under Flash.