Friday, 7 January 2011

Java Language Want List

Had a discussion with a friend the other day and we got talking about what we'd like to add or change about Java. Personally, I'm generally happy with the Java language and do actually worry about what people are planning to add to Java, though I suppose those changes will be backwards compatible.

However, it's fun to be critical, so ignoring backwards compatibility for now, and possibly without thinking about these things in too much detail, here's my "want list" for Java in no particular order:
  • Inline XML support - probably influenced by ActionScript 3's support for it. Though handling variables in the XML, collections and so on needs more thought. Probably an XML object that is a first class language citizen like String would be required and should allow operations to be performed on it.
  • Inline REGEX support - having to write regexs as Strings really annoys me as it makes them very hard to debug when you have a complicated regex due to escaping. ActionScript 3 handles this very well I think.
  • "blocks" or more commonly referred to as functions. Wasn't a fan of adding this to Java initially, but having used blocks in Objective C / iOS 4 I'm coming around to the idea.
  • Virtual properties - mark a variable as a property and then be able to use getters and setters regardless of if they are actually specified. This is something that both Objective C and ActionScript 3 has and seems almost like a no brainer for an OO language these days. (Someone sent me a link to something that does this in Eclipse but have lost the link now... if you're that person and reading, please post again :)
  • "Protocols" like in Objective C or the ability to mark interface methods as "optional". Two things would be required to support this. Firstly a default call mechanism (or having the compiler generate dummy methods which just throw "UnsupportedOperation") and secondly the ability to ask if an object (rather than class) has a method.
That's it for now, though I keep thinking of things and forgetting them, but I'll try and keep this list updated from now on.

Happy New Year, by the way.