Quote:
1) Java's not that slow anymore. Yeah, I know -- you always read that "OMG Java's dog slow", etc... but that's not really true nowadays. It used to be a horrible performer, back around 1.1 -- but Sun's put in some serious work into optimization. As of 1.6, Java's fast enough for use in a desktop app. The main cost comes at JVM startup -- but once the JVM is running, it's honestly not that bad. How fast is it? Well -- the Quake 2 engine's been ported to Java, and runs at basically the same speed as the native engine. I'd say that unless you're gonna be doing something more graphics-intensive than Quake II, Java will perform just fine on a modern machine.
The optimizations you're talking about are the JIT compilation it does on bytecode. But really, Sun Microsystems didn't do JIT right. You have to remember that Java bytecode is essentially assembly language for a nonexistent machine. So basically, the JVM is an emulator. If you add a JITer to an emulator (in this case, the JVM), you should see no more than a ten percent decrease in speed relative to native code. This means that if I write a program... GenPrime, for instance, the Java version should be no more than 10% slower than a C/C++ version. I'll do some benchmarks today to demonstrate Java's grotesque speeds relative to native code. But I can tell you right now that the JVM is running more than 10% slower than native code. Easily.
Quote:
2) C# isn't portable. The only reason I can think of to write a game in Java is portability -- and that's one thing that C# definitely doesn't have in its favor. Yes, C# has a JIT compiler -- but that's not unique; Java has several JIT compilers available as well. GCJ can even build fully-native binaries from Java source (or from compiled .class files, for that matter.)
No, C#
is portable. Ever heard of
Mono? What's not portable is Microsoft's .NET framework. So you can write using the Mono framework and it'll run as C# code on any platform. Also, have you ever
tried the GCJ compiler? The code it generates is both massive and slow. Slower than Java running through the JVM, even.
Quote:
Personally, I can see the value of writing something in Java (of course, I am a Java dev) -- but in cases where you need more performance, faster start times, or just don't want to deal with the memory overhead of a JVM, native code's your best bet. You wouldn't stand a chance writing something like FarCry (or even Halo, for that matter) in Java.
Something like an Uplink clone, on the other hand, I think could do quite well in Java, as it's not terribly demanding, performance-wise. That said, there's the question of "why?" As was pointed out earlier, Uplink runs on all three major platforms natively -- so why bother to re-invent the wheel (other than for the learning experience / fun / sadomasochism of it.)
I could, however, see one massive benefit of writing a hacking sim in Java: Multiplayer. Java would allow you to sandbox your app, as well as ensure that buffer overflows, etc. won't result in the compromise of a player's machine. I've often toyed around with the idea of writing a multiplayer hacking sim in Java, and even got as far as writing some netcode. Then I realized that my vision of a hacking sim (far more realistic than Uplink, command-line only, etc.) would have pretty much zero interest from gamers. Oh well.
Ooh. I hate the crappy buffer overflow argument. I always hear C# programmers use this argument. "Just wrap it in a string class and it's safe from buffer overflows!" Sure, that's true, but consider the overhead. I've gone into how C# does this. It first does some calls into MSIL code in the .NET Framework to do bounds checking of a memory copy or string copy or whatever operation is pending, and then goes into some native code and does a few more calls until it finally gets to the memcpy() routine in the native runtime.
But that's C#, so how does that reflect Java? Well, Java can't be much different. In fact, it can only be worse. The JVM itself is written mostly in Java. There are bits of native code to do the translation and dispatch of machine instructions, but for the most part, the JVM is written in Java. I've already established that they're not doing JITing properly, and their code is, as a result, slow. So what's worse here is that to do a simple string copy or other manipulation, it's going to be doing it all in Java code. Slow, slow, slow, slow.
The people that argue that Java is so "easy" to write sockets in don't realize that they really aren't writing sockets, nor are they learning what those sockets are doing underneath. A C++ socket class could easily be written to provide the same functionality (and there are in fact libraries that already provide such classes), and it'd be many magnitudes faster.
Performance is incredibly important. You have a processor with a certain clock frequency and certain features. You have memory with a certain latency. You have a hard drive with a certain seek time and read/write speed. You have a graphics card or chipset with certain amounts of memory and clock rates. In a game, you have to accomplish so much every 1/60th of a second or the game will suck.
Sorry, but I can't see Uplink/Onlink written in Java and running nearly as fast, nor as well-implemented as Onlink is.