Monday, October 24, 2005

First came A,B,C...

Rated: Geek
For: Lots of language bigotry and computer compiler complaining.

I've always been a C++ hater, and recently a Java hater. However, I've had enough years of C coding to know that it's productivity is pretty low compared to more advanced languages. I think it's ridiculous to write an office application in C. But today, it's also ridiculous to write an office application in Java or C#. Whence shall C++ die?

Why I "hate" java:
  1. The evolution of the language has been a complete re-invention of all the standard libraries and toolkits already available through C and C++.
  2. Using JNI(Java native invocation) to access said libraries is like playing with a box of bullets and a framing hammer to shoot a deer. Yeah, been there, done that.
  3. It's a major memory hog. It shouldn't require 16 GBytes to run a first class production web server. Yes, been there, done that.
  4. It's a CPU hog. While it does good on benchmarking, this is completely at the expense of memory management. Hit the memory wall and expect a massive wait time while java takes out the trash. This is the reason there is a "server" and a "client" VM now.
  5. Language iteration has been awful. The base types are not first class objects, and can't be "boxed" into them easily. There are multiple threading models (though the latest is actually nice), and lots of "styles" of code around. I say they shoot the duck and make a coherent standard library.
  6. AWT is foo to work in. Swing is slow. The obvious way to go is SWT - which is "abhorred" by the pure java community. Get a grip!!! SWT is wonderful to work in - it's the java client that we all deserved years ago. Eclipse is the prima donna example.
  7. Failure to provide customer optimized native code. Yeah, I know this wasn't the goal of Java - but step through the looking glass and imagine a world where developers write the code and distribute the app as bytecode. When you install the app on a machine it builds a fast, sleek native version that always starts fast, and works on every operating system out there - flawlessly. In other words, the ultimate software delivery model for almost every customer out there. Yes, it's hard to do. Too bad java missed this boat.
I am of the opinion that C# is the way to go if you want to live in the virtual machine world. Java just makes me mad because it's all over the place version to version. I'm no Microsoft lover, either.

The good things about java though:
  1. Interfaces, OOP, threading, sockets. Java taught the world that this stuff should be in the language and basic. My original fascination with java started here.
  2. Applets. Yes, I love them - too bad they are under-utilized.
  3. Eclipse. I'm in love with eclipse. Java is actually usable with eclipse.
I won't get into C++ - suffice it to say, I love templates and generic. I hate the memory management and the nasty syntax add-ons. Again, the evolution of C++ has battle scar written all over it. Not to say that you can't do some truly awesome stuff in it - quite the opposite. It can be very productive and given the choice between C++ and C for general development I'd go with C++. One controversial comment though... is it just me or are real C++ programmers sometimes snobby?

Now onto the goodies.

I've been doing much work with C# latily. WOW. Big WOW.

Let me list the goodies:
  1. Coherent architecture, methods, naming conventions, types. It's just a JOY when you KNOW that the length of some type is .Length.
  2. Structs live on!
  3. Invoking native code is easy. I'd say 7x faster, as I've written wrappers for both java and C#, being completely non-proficient in either. One day, versus a week to get a simple library interfaced.
  4. Built-in XML parser. No dabbling with multiple libraries, adding JAR's to your distribution, etc.. I know, it's semantic, but the JCP could have standardized on something like this long ago.
  5. Pointers when you need them, mixed managed and unmanaged code. Yes, warn me that I'm using a pointer - no, I know what I'm doing.
  6. Follows Java syntax and form, provides the goodies to build native GUI's without huge sacrifices.
  7. Follows Java's example in threading, sockets, and other base libraries.

Now, the list of badies:
  1. No native code, still have to live with a VM.
  2. Again, memory is killed for CPU sake, though I've noticed that C# doesn't hit the memory wall nearly as easily.
  3. Complex native structs just require pointers sometimes - I wish there were easier ways to manage structure members without having to write a complete getter/setter interface sometimes - but it's a small price to pay compared to pinning memory and locking the whole VM ala java.

Is there any hope for the average application developer? How about systems developers that want more productivity when the want it? How about developing an office application without sacrificing your soal to the dark one?

I think I've found it.. it's called D. It's a relatively new language, only 4-5 years old. However, it's not afraid to break old code and it's really moving in a nice direction.

From my basic overview of the language, I am hugely impressed.
  1. It's clean, fast, compiles to native code, and supports all the goodies of java and C# without the big overhead.
  2. Contract programming and unit test code "built into" the language
  3. C# type delegates (basically functions as pointers you can juggle as needed)
  4. C# type strings in switch statement (No more strcmp or overloading junk)
  5. Resizeable arrays
  6. No header files, methods are definitions
  7. Threading, sockets, exception handling
  8. Associative arrays ala perl hashes. BIG timesaver here.
I have to say, I am hugely impressed so far with the base language. I can see this language filling the needs of many developers. There's much work to be done on the libraries though - but again, a good base will naturally create ease in library development.