PDA

View Full Version : Web Game: Flash or Java?


tau
06-01-2007, 12:46 PM
Greetings,

I'm thinking about my next project and I would like to do something new - a web-based only game. The main reason is the ability to update the game without too much trouble for the end user. Just an experiment of some sort. :cool:
My choices: AJAX, Flash or Java applet.

I'm considering AJAX as the starting point, but seems like JavaScript is not fast enough to draw things in the browser, so I also think about Flash or Java applet with their 2D hardware acceleration features.

The technical side of it is not a problem for me. The reason I'm posting this is that I dont know what is the situation with the availability of Java (as the browser extension) and Flash.

From what Macromedia used to say (now Adobe), almost 70-80% of major browser users have at least Flash Player 7 (update to 9th version is quite smooth now) installed on their machines. That's nice. And it seems like Flash game portals are having really good times.

As for Java, it's a big mystery for me... I remember I had problems to install JRE to work properly with my browsers, and now the process is seamless (kudos to Sun), however, I dont know how widespread JRE is now for browsers, and I would like not to force my users to install 3rd party software too much ;)

What you your thoughts, Ladies and Gentlemen?
Thank you!

Update #1: Seems like Flash is more popular (http://www.adobe.com/products/player_census/flashplayer/) and this is the Flash version penetration (http://www.adobe.com/products/player_census/flashplayer/version_penetration.html)... I like Java better, even if it takes second place by popularity :), however, I'd be interested to hear if anybody had some issues while developing and running Java applet games.

Bad Sector
06-01-2007, 01:18 PM
I recommend Java because it's more powerful and the tools are available for free and for any major (and some minor) platforms.

When it comes to availability, Java isn't as good as Flash, but the difference isn't big. I've yet to see an internet computer (that is a computer that is used to browse internet a lot) without Java.

However if you only care about availability and don't give a nickel (:-P) about programmer friendliness, cost of development tools, poor performance (Java performs better because it uses hardware acceleration -last time i checked, everything in Flash was done in software only- and the HotSpot VM executes much faster any bytecode interpreter or even a plain JIT), mediocre IDEs (Eclipse and NetBeans are the best IDEs for Java), then you can go the Flash way.

Of course i've seen people writing C programs in MSDOS Edit and compiling them using Borland's free C/C++ Compiler via command line, so it seems that everyone has different needs and values for programming. You may not care about what i consider big pluses for Java :-).


(that and the fact that Flash doesn't work in my x86_64 mode Linux)

EDIT: ah, btw, my Square Shooter (http://www.slashstone.com/more/squareshooter/) game is made with Java :-)

tau
06-01-2007, 02:02 PM
Thanks for the thoughts, Bad Sector

I like your square shooter, made 9000 :)

It's quite smooth on my computer in Firefox, however I've noticed 0.5-1 Sec pauses when (I assume) the garbage collector kicks in at the time of many squares are "dying". I wonder if you have any information about the %% of users visiting your Java game pages and do not have the right JRE installed? Can you share that data, please? You can just PM me.

That's the thing, I prefer Java, but the market dictates the dinner time.
Actually Flash 9 is hardware accelerated, so it's quite fast, the only thing is the tools as you've mentioned - the studio is a bit expensive...

What I like in Java also is that I can use built in security for signed jars...

Bad Sector
06-01-2007, 02:09 PM
It's quite smooth on my computer in Firefox, however I've noticed 0.5-1 Sec pauses when (I assume) the garbage collector kicks in at the time of many squares are "dying".

Not sure, but i've read that garbage collector never needs that much time in such cases (it mostly needs around 100-200ms). That was somewhere in the JavaGaming.org forums.

I wonder if you have any information about the %% of users visiting your Java game pages and do not have the right JRE installed? Can you share that data, please? You can just PM me.

Unfortunatelly, no. I'm not sure how to collect this kind of data...

tau
06-01-2007, 02:12 PM
From my sites, using Google Analytics, I can see the following.

Java support: 98.24%, but it does not tell the JRE version range.

As for flash versions:
9.0 r28 - 36.14%
9.0 - 35.30%
9.0 r45 - 8.50%
9.0 r16 - 5.51%
8.0 - 4.82%
8.0 r22 - 2.22%
9.0 r31 - 1.68%
8.0 r24 - 1.30%
7.0 - 1.15%
6.0 - 1.00%

I wish someone who has high traffic sites would share this information as well.

Philippe
06-02-2007, 05:15 AM
Although I like Java, my opinion is stay away from applet-based games. It's not so much the availability of the plug-in – it's the fact that when the VM starts up, most browsers freeze for several seconds (I just went to processing.org – firefox on my MacPro froze for somewhere between five and ten seconds).
If I know a page uses Java, I'll most likely stay away from it, and I know that a lot of people think alike. If you can pull off what you want to do in Flash, I think you should do so.

Bad Sector
06-02-2007, 09:00 AM
Why stay away? Unless the webgame is totally crap, you'll likely play it more than 5-10 seconds. And if there is a *game* there, you'll likely play it.

I know many people who grouch about applet's taking a lot of time to load (usually in very old or badly configured computers - in my 4yr old Athlon64 3200+ it takes only around 2-3 seconds to cold start and a less than a half second for warm start), but none of them will actually "stay away" if they know there is a webgame to play there. If you ask them however, they will tell you that they won't play it (just to make their point bolder) - but personal experience shows that they will :-).

Besides, keep in mind that most "downloadable" games will take much more than 5-10 seconds to boot.


A note though: there is a delay when the Java VM does a cold start. I'm not trying to say that there isn't. If you make a site with a webgame, you must have this in your mind. Doing so it's easy, though:

a) First of all, don't load the Java applet immediately. Put it in an iframe that once the page is shown, it has a "splash" screen of the game. Then put a timer to around 300ms to replace the image with the applet code.

b) Use the same splash screen for applet (yes applets can have a splash screen while the JAR is downloaded).

c) Don't put the game in your front page or any page where there wasn't an applet expected. In other words, make the browser load the Java VM only if a user clicks a link, so he'll perceive the delay as the result of his will to play the game, not because he visited that page.

If you do that, i think the experience will be much better :-).

(yes i know that i didn't 'a' and 'b' for Square Shooter - i just thought these things, that's why)

20thCenturyBoy
06-02-2007, 09:46 AM
Although I like Java, my opinion is stay away from applet-based games. It's not so much the availability of the plug-in – it's the fact that when the VM starts up, most browsers freeze for several seconds (I just went to processing.org – firefox on my MacPro froze for somewhere between five and ten seconds).
If I know a page uses Java, I'll most likely stay away from it, and I know that a lot of people think alike. If you can pull off what you want to do in Flash, I think you should do so.
Strange - I went to processing.org on my ancient PIII-600 (ADSL 512kbps) and clicked on a sample. It loaded in about a second. No freezing whatsoever. I also went to www.puppygames.net. The applet there is bigger but it loaded in about 3 secs. At no time did my browser freeze. It had an unobtrusive splash screen explaining that it was loading. I'm using Java 1.6 but even under 1.4 I don't remember browser freezing. I used both IE and FF.

Maybe it's a Mac thing ;-p

Philippe
06-02-2007, 10:06 AM
Bad Sector, those are some very good tips!
I guess for me Java applets fall under the same category as pop-ups or webpages resizing my browser... If you do this to my browsing experience, there should be a good reason and it shouldn't come unexpectedly.

My point is, if you can avoid exposing your visitor to what you may consider even a minor annoyance by using a different technology, why not do it? If you have to manipulate pixels, if your game uses 3d or if you have thousands of objects on the screen, it's a very different story, but if you're doing something you could just as easily do in flash, I maintain that I'm sure you'll have a harder time attracting traffic.

20thCenturyBoy, it's not a Mac thing. I only recently made the switch, and remember well that this happened on every windows pc I've had, although I'll gladly give you that it varies between browsers and JRE versions. Perhaps my machines were badly configured, but then I think that's the norm rather than the exception on the internet.

jaguard
06-02-2007, 10:39 AM
I wonder, if java is so good, are there java game portals which are as popular as flash ones? If no(personally, I don't know of a one), why is that? I keep hearing these mindboggling numbers for great flash games, like millions of impressions each month. Are there such java games?

Jesse Aldridge
06-02-2007, 01:44 PM
I agree with Bad Sector that Java applets are the way to go.
The downside with them is you have to deal with a lot more b.s. than you do with Flash.

Here's an incomplete list of problems associated with applets:

1.) Like Bad Sector said, an iFrame is important. If you load the applet normally on the page, the user will experience a very perceptible freeze if they haven't loaded the Java runtime yet (shorter or longer depending on the computer). This definitely creates a bad impression. See my site for an example of what not to do :) (It's mostly defunct... I may get around to improving it someday)
2.) There are a bunch of different versions of Java. On Macs, for a while the default version was 1.4. A lot of computers still have that version (though it's slowly dying off, I'd investigate it again if I were about to publish a game). It's missing some features that later versions of Java have. Notably generics and auto-boxing. Note that with this tool called Retroweaver you can take Java 1.5 code (which can use generics) and turn it into 1.4 code. Even then I still had problems with having to hunt down stray auto-boxing bugs... Note that with downloaded applications it doesn't matter because you can bundle the Java runtime with the executable.
3.) Flash apps are much harder to screw up then Java applets. I've frozen my computer with Java applets a few times. It's never happened with Flash. Flash generally seems to handle bugs better.
4.) I think Flash may be better for non-programmers due to the designer oriented IDE while Java has nothing of the sort (that I know of).
5.) There are some things you can do in normal Java that you can't do in applets due to security restrictions. For example, you can't load images the normal way... you have to use this funky stuff with the class loader, and the image has to be in the same package as the main class... something like that anyway (I'd have to google for the exact method).

So yeah, in summary Java applets are a pain in the ass to get working, but if you do get them working you can get better results. I think all the associated difficulties are what has prevented applets from really taking off.

The key advantages of Java I would say are 1.) hardware-accelerated graphics through LWJGL and 2.) a superior programming environment... Eclipse + Java beats Actionscript 1 & 2 for sure (I haven't tried ActionScript 3 at all, but I'd bet Java's still considerabley better).

Java's also free. The Flash editor is expensive (like ~$500 last I checked...) I'm pretty sure you can do Flash for free by just writing ActionScript, but then of course you'd lose the Flash IDE, which I gather is a major draw. Of course you could always pirate the IDE (and I have a feeling that may be common among smaller Flash developers)... but we're trying to run legitimate businesses here :)

I'm fairly experienced with Java, but not so much with Flash, so you should probably take all my Flash related statements with a grain of salt :)

(Whew, long post. Can you tell I'm sitting in a hotel room with nothing to do? :) )

tau
06-02-2007, 07:46 PM
Thanks for sharing, guys!

BadSector, those tips of yours are really useful , thanks a bunch for sharing! Jesse, your tips are appreciated as well!

jaguard, there are plenty of Java game portals (Yahoo Games is the biggest), however making simple games like match 3 is a no-brainer in Flash for a non-coding guys, who usually use Flash MX.

I'm like a monkey between big banana and small banana, but sweeter - dont know which one to take :)

I'm kinda thinking about adding some pseudo-3D elements to the game (not decided yet), but Flash is too slow for 3D computations, it has only 2D hardware acceleration, and all the 3D staff is in ActionScript, which is very slow.

On the other hand, Flash allows me to penetrate Wii and PS3 markets as those browsers are capable to show Flash 6/7, but I'm not sure if it's very important, if not just geeky...

Tom Gilleland
06-03-2007, 09:53 AM
Director / Shockwave has pretty extensive 3D support. And I feel that the underlying programing language Lingo and programming environment is better than Flash actionscript. Though I think the Shockwave player currently is at about 55% penetration, as opposed to Flashes 95%.

-Tom

XIX
06-03-2007, 10:28 AM
I have a little real world test you can try.

Goto http://www.flash.com : Do you see any java?
Goto http://www.java.com : Do you see any flash?

You may now decided which one is the dominant platform.

:)

Bad Sector
06-03-2007, 10:52 AM
Java doesn't currently support streaming video, that's why Flash is used there. I'm sure that once Java supports streaming video, that Flash video player will be replaced with a Java applet :-).

But you don't need streaming video for a game (usually...).

jankoM
06-03-2007, 01:04 PM
I made flash games and java(processing) applets... To me it's like this..

Flash is very widespread, just works and has some graphics shortcuts.. but it's slower on the backend side and it does a good set of things tipically needed but not much more.

Java is much more problematic but it is really fast and has tons of libs for everything (but you can't use it all in applets).

So if I need a lot of processing or 3d and am making something special (so I can think that potential player might also install/update java for it) I will do it with java (like I did with DEBUGR INC where I am simulating ai of hundreds of bugs with it) and I have the possibility of webstart where I can use ful stack java (opengl, networking..).

If I am making something simpler or not processing intensive that as first must be as accessible as possible then I will use flash. Basically I use flash wherever I don't have clear reason to use java because of accesibility reasons.

-- however Java is making consumer JRE right now (and has open sourced which will be aditional boost) and AS3 is much faster than AS2 . --

btw... I just saw this (this is the guy that made gmail) Java is faster than C:
http://paulbuchheit.blogspot.com/2007/06/java-is-faster-than-c.html

20thCenturyBoy
06-03-2007, 11:39 PM
btw... I just saw this (this is the guy that made gmail) Java is faster than C:
http://paulbuchheit.blogspot.com/2007/06/java-is-faster-than-c.html

Hmmm, to be taken with a pinch of salt. For starters, he's using the server vm which uses more aggressive optimisation at the expense of slower startup. The client VM in this particular test is about 10-20% slower on my machine. Also the C version is twice as fast as the Java on my machine (PIII).

Anyway, the code spends too much time doing I/O, so really it's comparing Java's System.out.println() with C's fputs(). I think the latter will win every time.

Xiotex
06-04-2007, 10:01 AM
Having just made a game in Flash CS3 using Actionscript 3 I can say with confidence that the whole experience has improved. I previously made a flash game for PomPom called 'Bliss Island' using the last iteration of flash and it was a nightmare to do. Actionscript 2 was nice but the compiler just let through bugs without failing and the execution speed was lousy.

Flash CS3 with Actionscript 3 was completely different and I would have no hesitation in recommending it to anyone. From my understanding Flash player 9 using JIT compilation on AS3 code which has improved execution speed from significantly from what I can tell (meaning: no - I haven't done measured speed comparisons before you ask).

But at the end of the day I always say go with what you are comfortable with. If you like Java then use it!

KNau
06-04-2007, 10:17 AM
If you are only hosting the game on one site then use whatever you want. If you want to spread the game virally then Flash would likely be the way to go.

Brent
06-09-2007, 10:44 AM
I'm curently creating a flash game. I spent months considering different options for the game. I eventualy decided that flash was better for me for a couple of reasons.
The first reason being that I have a small team of only a couple of people and flash is far easier to use.
Second because of the distribution of flash on computers.
The third reason is my game is a point and click find the "item" game there for I don't need conplex code.
The last reason is development time it would take me months just to get the basic frame work in Java (since I haven't coded in it in quite some time).

Here is a Gamasutra articles that looks at this issue.

http://www.gamasutra.com/features/20050324/steinmeyer_01.shtml

oNyx
06-09-2007, 01:00 PM
[...]
http://www.gamasutra.com/features/20050324/steinmeyer_01.shtml

Note that it's from 2005 and that 1.1 compatibility isn't worth the trouble (http://www.javagaming.org/forums/index.php?topic=12361.msg132264#msg132264) anymore.

"It then moves into games, but the entire game content of the book is aimed at full-screen, stand-alone Java games. I wanted in-browser games (that could also be made stand-alone)."

Not much of a difference really.

Backov
06-09-2007, 02:03 PM
Holy crap that was 2 years ago already?

tau
06-09-2007, 03:30 PM
Holy crap that was 2 years ago already?

I know... time freaking fly...

@ All
Thanks, for sharing your opinions and ideas, I appreciate it!

AS3 looks really interesting, and by the time I finish my game, it will be wide spread, which is cool. I wonder if I can just code everything in AS3 without too much of the Flash Studio help?..

Java is still quite handy at 3D stuff...

I recently saw some info on the Silverlight (http://silverlight.net/), and it does look promising, because the Mono Project team is ready to port it to other platforms, so it's gonna be not only Windows based. I'm sure that AS3 will be ported to it as well, because M$ will be willing to knock off Flash from the market...