Ah, the standard laundry list of complaints. First, a bit of history, so you know where I come from here: About five years ago, I first saw Java applets, and laughed it off as a stupid web animation tool. Four years ago, IBM came out with JDK 1.0 for OS/2, and I gave it a try, and within three months I'd permanently abandoned C and Objective-C, my former languages of choice. I've written a few dozen lines of C in the years since, and I'd like to never do it again. I also do Python and PHP (well, and far too many bash scripts...), so I'm not a one-track programmer...
On native compilers and speed: Just-In-Time compilers and Hotspot already do compile your bytecode to native machine code. They do it at program startup time. The one flaw in this plan is that they currently do not cache the machine code, and so there's a nasty startup delay (Hotspot a bit less so than JIT). The current speed is, for most tasks, 80-95% of the speed of equivalent C programs. The worst-case, high-CPU, array-intensive code (thus getting a bounds check on every test, and so on), can drop that to about 50%. The speed in the first few years was far far worse, and if you turn off the JIT, you can still experience that 5% efficiency. So don't do that. If you do blatantly foolish things like
for(int i = 0; i < s.length(); ++i)
s2 += s.charAt(i);
Then yes, you will see worst-case performance. You should learn the native idiom, by looking at what's in the libraries:
int len = s.length();
StringBuffer sb = new StringBuffer(len);
for(int i = 0; i < len; ++i)
sb.append( s.charAt(i) );
s2 = sb.toString();
is actually just syntactic sugar for:
(and the default size of a StringBuffer is only 16 chars...) String addition is almost never a good idea.
"But I miss templates, multiple inheritance, pointers, and operator overloading!": Too bad. C++ programmers have proven, starting with Bjarne and his thrice-damned iostreams, that most programmers cannot be trusted with certain features. It's all their fault, they abused the concept and ruined it for everyone. Feel free to punch the next C++ programmer you see in retaliation, but please don't ask for these things in Java. Pointers in C (and the lack of garbage collection and array bounds checking) are the cause of almost all software crashes and security holes in "modern" software.
Things Java is really missing: Enumerated types are my #1 complaint. Especially if they could have had a way to get the NAME of the enum as a string, unlike C's brain-damaged implementation. Sure, you can make a class to do it, and I have a standard superclass for Enums in my own library, but it was a horrible omission. The runner-up is not pretending that primitives are objects, too. The primitives SHOULD have been objects, replacing those silly wrappers. IMO, they got almost everything else right.
Write Once, Test Everywhere: Aside from the brain-damaged early implementations of Java on the Mac, and early variations between browser-supplied JVMs, this really does work almost all of the time. I initially wrote Java under OS/2, and it worked perfectly under Windows (and Mac once I'd learned what to avoid). Now I develop under Linux... and it works perfectly everywhere, too. But you do have to test your apps and applets on multiple platforms, there's no other way to catch all the 'gotchas' in cross-platform computing.
Sun sucks: Yes, it does. Scott McNealy is so paranoid he makes Fox Mulder look like Neville Chamberlain, and the political battle around standardizing Java was just insane. But that doesn't change the fact that Java's a kick-ass language, often in spite of Sun's best efforts.
Applets suck: Yes, they do. Applets are useless, except as clients to a server-side application. I never browse the web with Java turned on, I turn it on ONLY for specific pages that have some applet client I need. That said, they're also really really great, because they're a zero-effort installation. No download/run/click through the wizard stuff, no fiddling with config files, and best of all, no risk of viruses. Just go to a web page, and turn on Java support. Bang (well, after the download...), you're running.
Ultimately, it's the best language I've yet seen for writing applications. It's not appropriate for device drivers or writing operating systems; that's what portable assembler, aka C, is for. It's not a good scripting language, as it has no 'eval', fairly poor support for running external programs, and pretends that all OS's have the same kind of filesystem. For that, use Python (or whatever...). Java Servlets and JSP (which are actually compiled into Java servlets by the JSP engine) are a good competitor for PHP, but I think PHP's a simpler and more elegant language for dealing with database-driven web sites, and it's a good deal leaner.
-- Mark Hughes