Coolest D features

Mike Parker aldacron71 at yahoo.com
Wed Dec 27 07:49:15 PST 2006


Waldemar wrote:

> Actually, the reality is Java is plenty slow in many applications.

I don't know about that. I have seen some nasty, klunky Java programs, 
but my experience is that they are the exception rather than the rule. 
Netbeans and Eclipse both started out as klunkers, but neither is today.


 > There is JNI for a reason.

JNI was developed for compatibility with legacy code. It was used in the 
early days as a performance optimization tool, but these days not so 
much. Even for Java games, JNI is used only to access native APIs like 
OpenGL, OpenAL, or DirectInput. The old Dirty Java article at Gamasutra 
lost its relevance with the release of Java 1.4.

 > Never mind cases where Java is not even considered (fast servers,
> OS internals, communication, graphics, driveres, embedded, etc, etc.)  As soon as
> Java reaches C/C++ speed, C++ will disappear.  Not too worry, won't happen any
> time soon.
> 

I don't expect people to write device drivers or any other performance 
critical code in Java :) That's not what Java is intended for. It *is* 
quite prevalent in embedded systems -- your cell phone is most likely 
equipped with JME, and you may even have some form of Java in your DVD 
player. The PS3 is equipped with a limited version of Java.

Java isn't a bare-metal systems language, but it isn't *slow*. The 
reality is somewhere in the middle. It's slower than C++ in most cases, 
yes. But there are plenty of applications that can be written in Java 
where a 5%, 10% or even 20% performance difference isn't going to 
matter. With my interest in games, I love to point out Java games like 
Tribal Trouble, Puzzle Pirates, and Bang! Howdy, all of which are 3D 
games, or the shooters developed by Puppy Games which are 2D on OpenGL. 
Since the JVM is bundled with each of them, most people don't know or 
don't care that they are written in Java. Performance is just fine in 
each of them.

The preceding paragraph is the typical response you are going to get 
from a Java programmer when you say Java is slow. There's a lot going on 
behind the scenes in the JVM, as Walter mentioned, and Java programmers 
understand that. There's a trade-off between safety/security and speed. 
They accept that. Do you think anyone at all would choose Java if it 
truly was a snail at everything? They like the ease of writing 
concurrent applications in Java compared to other languages. They like 
Java's inherent networking capabilities. They like the advanced 
development tools available for the language, such as the free 
profilers, full-featured IDEs, and the ability to choose between and 
fine-tune for several different GC implementations to get the best 
performance possible. Some hardcore Java programmers might be willing to 
write a video or audio codec in Java, but most are more grounded and 
understand that Java isn't suited for that.

So my point is that Java programmers use Java for a reason. Ask any of 
them and they will surely point out faults they find in the language 
(Generics being a popular one). But very few who choose to use Java will 
cite performance as a negative for *their purposes*. So to entice a Java 
programmer to come to D, the speed argument just isn't going to fly.

To court Java programmers, you have to convince them that D's features 
are shinier than Java's. You have to show them an advanced tool chain 
that lets them monitor every aspect of an application's performance. 
They want to be able to dynamically instantiate objects via a class name 
string. They want easy use of web services, support for web 
applications, and not to worry about porting issues across different 
platforms.

No matter your opinion of Java, or Walter's, people who use it on a 
regular basis see it in an entirely different light.



More information about the Digitalmars-d mailing list