Xavier
Xavier

Reputation: 9049

Which has higher performance java or javascript?

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

Answers (6)

ZJR
ZJR

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

bobince
bobince

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

Ateş G&#246;ral
Ateş G&#246;ral

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

Mike Baranczak
Mike Baranczak

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

Stephen C
Stephen C

Reputation: 718718

As @Benoit says, this is a difficult question:

  • Comparing (primarily) client-side and server-side languages is comparing apples and oranges.
  • Different languages perform better / worse depending on the application / task.
  • You can only benchmark language implementations not languages.

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

Benoit Courtine
Benoit Courtine

Reputation: 7064

It is very difficult to give you a response. Java and Javascript are totally different languages :

  • Javascript is executed by your browser: performance depends of you browser javascript engine
  • Java (if executed on the client machine, by JNLP for example), run in a JVM environment: performance depends of your JVM

So there is no absolute response to your question.

Theses two languages have also very different functionnalities that can't be compared...

Upvotes: 4

Related Questions