What I Hate About Your Programming Language
Subject:   Java problems...
Date:   2003-05-14 03:57:48
From:   anonymous2

"If operator overloading is so bad, why does the String class do it?"

What String does isn't really operator overloading. It is a defined part of the language that exists for simplicity.

Also, what is done with String cannot actually be achieved with operator overloading mechanisms as they exist in other languages; it is a construct which is compiled into code that uses an entirely different class ('StringBuffer') to provide an efficient implementation that wouldn't be possible using String, which is immutable.

"I'd like to be able to reuse common code in ways besides inheritance. Mixins that don't require inheritance would be a nice touch."

Have you considered working with a pattern where a private member contains a reference to an object of the type you want to reuse code from, and then this is used within your class? I find this pattern very powerful, and useful in a lot of cases where people naturally turn to multiple inheritance in C++. In many cases, it is a lot easier to understand when reading the code, too.

"The libraries and the interpreter aren't cleanly separated. There are ways (involving decompilers), for example, to get regex support in 1.3, but I'd prefer to upgrade the standard library and the interpreter separately sometimes, rather than in one big chunk."

Is there any real reason they should be? I tend to think of a Java installation as a virtual operating system that runs on top of your own. Would you expect to be able to back-port Windows XP features so they were available on Windows 2000?

"I like the idea of checked exceptions in some situations, but forcing every method to catch all exceptions that its child calls or may call can be tedious. I'd rather be able to ignore an exception and let it propagate upwards. Sometimes, I'd rather not worry about exceptions at all."

Simple solution: add 'throws Exception' to the end of all your method declarations. It'll annoy anyone who isn't lazy and has to interface with your code, but it works just fine as a way of declaring to the compiler that you're not interested in the exceptions at this time.

1 to 1 of 1
1 to 1 of 1