Why Dart Is Not In Java

From Biowiki
Jump to: navigation, search

The following notes were written very late at night in a somewhat low blood-sugar state of mind. A quick disclaimer: I fully acknowledge that Java deserves its place as the premier platform for enterprise programming. I am a Java fan. No really, I am. However, my DART code is in C++, and I've often been asked to justify this. The following rant is my somewhat defensive attempt to explain myself. I realise that I come across as a bit of a javaphobe here, but what the hell, I'm going to leave it up here for posterity. Or whatever. Ian Holmes, March 25 2005

Why DART is not written in Java

  • First up, you better realise that language proselytising is immature.

I certainly realise it. Preaching language preference is just a waste of time. Grown-up programmers know multiple languages and use the best tool for the job. Nothing about my use of C++ in DART is religious or ideological or dogmatic. It's just practical. That said...

  • There are still reasons why we pick the languages we do.

I have been asked to justify, or (more usually) scoffed at for, my choice of C++ as the programming language for DART. Many times. Why not Java?? As if no conceivable reason could be pronounced in polite company, without making a face.

  • So here are those reasons. brace yourself

Still-valid reasons why DART should not be in Java

  • Java is still not as fast as C++.

Java fanatics refuse to believe this. They're in denial. However, Java will always inherently be slower than C, partly because of the bytecode interpretation, but also because you don't have fine-grained control over memory allocation (which is a major cause of nonlinearity and slowdown in real applications). Java's slowness seems especially apparent for numerically intensive computations. See for example the great language shootout.

  • Java doesn't have templates

I know about generic java. But, again, it isn't "there" yet. Not widely supported, not widely accepted. It's a great idea, but it isn't yet a standard.

As a result, java programmers end up doing dynamic casts all the time, and their code spills runtime cast exceptions all over the place. This is just dumb, and it adds to java's inherent slowness. A high-level language should be typesafe and statically bound where possible. Java isn't. Generic java maybe, but again, it's not there.

  • It is therefore difficult to convert a large amount of working legacy code into java from C++

but i would welcome volunteer offers. The test I care about passing (in a JUnit sense) include Xrate Tests and Stemloc Tests.

Reasons why I'm STILL lukewarm about java as a language compared to C++

  • Java is verbose

With its absence of templates, its insistence on long variable names, its ugly constructs like System.out.println and its lack of operator overloading and other neat syntactical shortcuts, java forces programmers to type more. My fingers thank me for using C++.

  • Java still has problems with incompatibilities, stale dependencies and changing APIs

Java was meant to solve these problems. And it doesn't. OK, you get incompatibilities with C and (especially) C++, but in my experience these are no harder than Java problems to fix, and usually easier. Perhaps this is just what I'm used to, but given that this is one of the things Java was supposed to not do, I think it's pretty sad.

  • Well-written C++ is just as safe/secure/stable as Java

I've never had a segfault I couldn't immediately fix by compiling in debug mode (where I use bounds-checking wrappers around the vector template, among other safety checks). Java programmers, on the other hand, face runtime exceptions on a regular basis that simply don't occur in good ol' typesafe C++.

  • The C++ standard template library is better than Java's standard library

Sorry, it just is.

Old, no-longer relevant reasons why DART was not written in Java

  • Java wasn't "there" in 1998

When I started writing DART, java was still underdeveloped. In fact, early development on dart began in 1996. At that stage, java was still a fun curiosity.

Of course, now java is much more established, which makes C++ code (arguably) legacy.

  • Java wasn't "there" in 1995

I loved the java buzz. Seriously. I lapped up every drop of it. And my phd supervisor (rightly) recommended I stick with a better-established language, in order to meet scientific goals within the period of my Phd funding.

Sometimes not being an early adopter is the right choice. However, java is a pretty smart choice right now. Why?

Reasons why it would be good for DART to be written in Java

OK, finally I have to say this by affirming that I'm STILL a java fan and I recognise that DART is still, ultimately, MEANT to be in java. And here, to prove I'm sane, are a few of those reasons:

-- Ian Holmes, March 18 2005