1) Auto-casting
To reduce redundancy in the code I will introduce Auto-casting. What this does is that if an object could be cast in place to satisfy a constraint then the compiler would do that. It will fail if the auto cast is ambiguous or if it would fail if the programmer put the cast in explicitly.
Map p = new HashMap();
p.put(“test”, “test”);
String s = p.get(“test”);
MyEJBHome home = new InitialContext().lookup(“java:comp/env/ejb/MyHome”);
System.getProperty(p.get(“test”));
2) using a factory like new method instead of an operator.
StringBuffer sb = StringBuffer.new();
3) Reflective invocation operator to allow objects to have shapes without explicit interfaces.
Object s = “test”;
s = s->trim();
4) Closure-like (lite) anonymous inner classes. If an anonymous inner clasc c̣eated from an interface has only one method, allow that method to be implemented without signature. Name any arguments with the lowered classname plus a number if there is more than one or allow them to name the parameters in the new expression:
Runnable r = Runnable.new() { System.out.println(“ran method”); }
FilenameFilter ff = FilenameFilter.new() { return string.endsWith(“.gif”); }
FilenameFilter ff = FilenameFilter.new(File dir, String filename) { return filename.endsWith(“.gif”); }
Why don’t I just use Groovy? Well, I think that optional parenthesis, optional semi-colons, optional line endings, really anything that makes the code writable in a million different ways, probably doesn’t help in the long run. I have already run into many bugs in my own Groovy code that occurred because of the optional syntax that is absolutely unneeded. What I really want is just a slightly better Java, not a Java-ized Ruby variant.
Anyone want to add any features to this list? Its a fun exercise, if ultimately for naught.