Reputation: 9049
Since now javascript gets compiled to machine code by browsers. I was wondering which programming language gets better performance between java and javascript. I'm thinking of writing a 3d browser FPS or MMO and am trying to decide between the two.
Also what are thoughts on compatibility? It seems like with java and opengl I could reach a larger audience than using javascript and webgl since support hasn't been announced by IE.
Upvotes: 0
Views: 7221
Reputation: 9572
Depending on the level of detail you pretend from it, Java could cut it or not.
Take a look at Minecraft, a contemporary example of a Java 3d multiuser environment (alas, a very blocky one)
An yes, Javascript won't be able to give you any sensible 3D experience until WebGL (or what will take its place in the final HTML5 revision) takes afoot.
But until then I found out you may give a look into Google's O3D, an higher level interface to Javascript 3D that is available now as an installable plugin (for IE too) and has vague promises of being available later as a pure Javascript implementation, built over WebGL
Anyway, in general: Java on the browser is declining in usage, (Minecraft being an awkward exception) while HTML5 is the new g*dam buzzword.
Upvotes: 1
Reputation: 536339
For what it's worth, JavaScript's performance has greatly improved since the emphasis on scripting speed in Browser Wars 2.0; Java has evolved less radically. Directly comparing such fundamentally different languages isn't really practical, though. And to be honest I don't think performance of the core language is usually going to be your main problem if you're doing something as ambitious as a 3D game in the browser.
To add another option, today you would typically do this Flash using one of the 3D libraries.
Java is what you'd use yesterday (its desktop/applet acceptance is on the wane IMO); WebGL is, hopefully, what we'll be using tomorrow. All three are currently very annoying to write 3D apps with. Get a bunch of practice writing some 2D games before going anywhere near 3D in the browser!
Bonus option for if you don't mind arbitrary closed plugins: Unity
Bonus option for if you're insane: JavaScript, doing the rendering itself, to a <canvas>
.
Upvotes: 3
Reputation: 140032
As an avid FPS gamer, here's my biased two cents:
If you're going to write a 3D FPS, follow QuakeLive's example and create a browser extension that uses compiled code.
In FPS games, every extra frame and every few millisecond counts. So, a cross-browser solution like Flash, Silverlight, Java etc. may not cut it.
It's a different story if you're writing a turn-based game or a MMORPG where latency or low frame rates don't necessarily matter.
Upvotes: 5
Reputation: 8374
For browser-based games, I don't think you should be using either. Flash is the way to go.
Also, 3D games, even simple ones, are a pretty heavy-duty task. I suspect you don't know what you're getting into, but there's only one way to find out.
Upvotes: -1
Reputation: 718718
As @Benoit says, this is a difficult question:
Having said that, here are a couple links to the "Computer Language Benchmarks Games" comparing Java and Javascript implementations:
Note that these are comparing Javascript with interpreted Java. You can fiddle around with the settings to get comparisons with (for example) server-mode Java.
Upvotes: 5
Reputation: 7064
It is very difficult to give you a response. Java and Javascript are totally different languages :
So there is no absolute response to your question.
Theses two languages have also very different functionnalities that can't be compared...
Upvotes: 4