Donnerstag, 17. Mai 2007

Java is too terse (reading and writing)

I am glad that Obele pointed out the merits of the verbosity of Java.

Code like
  DataSourceAdaptorWrapper dataSourceAdaptorWrapper
= new DataSourceAdaptorWrapper(
DataSourceAdaptorWrapper.DEFAULT_DATA_SOURCE_ADAPTOR_WRAPPER);
has just the right amount of verbosity to make it easy to read. No wonder Microsoft basically copied Java and even changed their own programming language to be nearly as verbose.

But Java is not the first programming language ever invented, and not even the most readable. For instance, it is not explicit enough to express exactly were objects are in memory and were they go.

Sure, you can do something

dataSourceAdaptorWrapper = null;
Runtime.getRuntime().gc();

every time you don't need the object anymore, but, unfortunately, that is just a hint to the garbage collector, you don't really know if your object will really disappear. What you want, is explicit memory management. And don't even get me started about exceptions which might jump at you out of knowhere!

Fortunately, in the old days, there was C, where you had to do the error code propagation and "Object-oriented Programming" by hand. No more calling of functions by accident which you didn't even know existed because they are in some super class! Unfortunately, Java and C have a terse way to do recursion, which looks just like a normal function call and hides stack handling from you, which is why I prefer with Fortran 77, where you have to be explicit about it.

Keine Kommentare: