Like you said, written in Java, it's okay. Just the language that's inefficient.
Is Java less efficient than C# or the other .NET languages? Is it less than PHP, in which Facebook is written?
(Preemptively split because I can see where this is going.)
But java is client side mainly. But on our older 1Ghz XP computer without a graphics card, vNES ran at .20 FPS. Pretty inefficient.
I've had better results with vNES on a computer comparable to that (1.8 GHz Pentium 4 and built-in Intel 845 graphics, and P4 and Atom have lower IPC than the Pentium III or Pentium M you're probably talking about). What versions of Java and vNES did you use? Does the problem still occur when you play
LJ65 in vNES?
Can't tell, sine then all the computer we got were better. I think the main reason though was that it didn't have a graphics card that was anywhere near modern. I think it was like 512MB RAM and onboard stuff for everything else. As for my new PC, playing vNES on the 2.9Ghz x64 4GB with 512MB graphics card in my laptop it still kicks up the CPU to high usage, although with it there's no lag at all, it runs multiple vNES's pretty good.
By definition, Java should be more inefficient than say C. It compiles down to byte code for a virtual machine (in an effort to make Java a compile-once, run-everywhere language) so the virtual machine has to translate that into actual machine instructions. I imagine that the VM for Windows x86 must be optimized in that it can turn its byte code into fairly efficient code for the x86. Also, certain fancy OO stuff adds overhead (virtual functions is one). Code Complete says that Java's relative execution time is around 1.5x that of compiled C++.
That being said, people (like me) just hate the language. Just because. For me, it's because of its intimate connections with the buzzword "enterprise" and the fact that it runs in VM would be better if it weren't the obstructive Java VM on modern operating systems. It's a personal thing, mostly.
Isn't java bytecode just a stack-based VM language with lots of pushes and pops?
I have no idea what kind of native code the JIT systems actually generate, anyone care to post an example?
Java is very probably more efficient than all interpreted languages (such as PHP) as it's compiled to a bytecode, but then the bytecode has to be interpreted by JRE instead of being directly executed, therefore off course it will be less efficient than C(++), but that doesn't mean it's inefficient.
I don't know a thing about C# so I don't know, but if it comiles into executable code then it's probably more efficient than Java.
Bregalad wrote:
Java is very probably more efficient than all interpreted languages (such as PHP) as it's compiled to a bytecode, but then the bytecode has to be interpreted by JRE instead of being directly executed
This was true in 1995 when Java was first released, but for the past decade Java has been running on a JIT compiler called HotSpot. A modern JVM only interprets bytecode when it is first started. Methods that are being executed many times over are quickly compiled to native code and then typically run just as fast as a C program. This extra runtime compilation step is part of why Java apps are typically slow to start up.
In my experience PHP is incredibly slow compared to "real" VMs such as Java or .NET, but Facebook built a tool called HipHop which I believe allows them to compile PHP down to native code so that they can squeeze out every last bit of performance out of it.
Every trojan or virus I've ever gotten was from the Java runtime environment. Absolutely sick of this, I made it a point to never install it anywhere.
My last experience was insidious. It came from a google image search for some mundane plug-in card for a computer. As soon as google took me over to the site hosting the photo, Java fired up and took over and the results took 2 work days to try and stomp out. So no more Java backdoors for me.
Just absolute effing garbage that never lived up to its potential is the JVM. Tack on the fact that the kinds of people that are attracted to program in Java- people that have never written a machine code program, or don't know how a CPU or Graphics Chip does what it does, but live under the mantra that "there's a library I can include that does that for me!"... I can see why an emulator in Java would chug.
The sad part is that it doesn't have to be this way; just another computer language. But it's the baggage that surrounds it.
That baggage is being solved. Lately, many web browsers have been incorporating whitelists for plug-ins such as Flash Player or Java applet player: if the user hasn't added a hostname to the plug-in's whitelist, all of that plug-in's boxes are replaced with "click to play".
whicker wrote:
"there's a library I can include that does that for me!"
The fact that nearly EVERYONE programs like that today is what drove me away from programming for a living. Nowadays, programming is almost exclusively a hobby for me.