Java Musings
I've finished my first project for my CS class. Typical annoying CS busy work, but it did give me a chance to play with Java. As I've said earlier, I do like Java, but it has some annoyances:
- No function pointers. A callback here or there would be nice.
- No lexical scopes. This can be very handy, and...
- No closures. No lexical scopes + no pointers = no closures. Closures are incredibly useful and powerful. Yes, I know I can fake it with anonymous classes. No, that's not good enough.
- After 40 years of language development, it's shocking that we're still using languages with fixed arrays. We're using compilers for a reason!
- Constructors can't be inherited. Sometimes inheritance isn't about changing instance variables!
- Static. Don't use the keyword static in your language. It means 8 different things in dozens of different languages. Use a name that actually has a mnemonic.
- Instance/method access. This is actually a mistake that java inherited from C++. The paradigm of directly accessing methods and instance variables inside a class is bad. It's too easy to confuse them with a static member. Java has plenty of spare syntax to make it easy:
public void foo() { return foo; // Instance or static var? } public void bar() { return this.bar; // clear, but bad Huffman coding! } public void bar() { return :baz; // nice and perl6'ish! } - No operator overloading. I know some people don't like this, but I do. We could avoid all sorts of object.equals(thingy) shenanigans and save on typing. object == thingy please.
- The compiler error messages suck. We'll, more to the point the tools we've been told to use suck. I have a very nice editor, I would like to use it.
- Exceptions: good. Declaring what exceptions a method might throw: handy. Having to do that all over the place just to use a damn exception: crap.