Java7
http://tech.puredanger.com/java7でJava 7の概要を読んでた.
普通に便利そうなのが
- Strings in switch statements
- Comparisons for Enums
- JavaBean property support
- More Script Engines
- BigDecimal operator support
- Java Media Components(追加,というかいままでなかったんだ)
で,便利そうだけどどういう実装になるかによるなというのが
- Closures
- Automatic Resource Block Management
- Language level XML support
- Short instance creation
Stringのswitchは普通に欲しい,enumの比較はできたほうがいいことが結構ある.propertyのサポートはgetHoge()とか書くのは結構面倒なのであると便利.BigDecimalはmultiplyとか書いてると横に長くなるので.
Automatic Resource Block Managementは
BuffereInputStream bis1 = null; BuffereInputStream bis2 = null; try { BuffereInputStream bis1 = ...; BuffereInputStream bis2 = ...; ... ; // Perform action with bis1 and bis2 } finally { try { if (bis1 != null) bis1.close(); } finally { if (bis2 != null) bis2.close(); } } }
と書くのは非常に冗長なのでなんらかの手段は欲しい.ただhttp://docs.google.com/View?docid=dffxznxr_1nmsqkzを見ると,まだどういうsyntaxになるのかは確定してないので便利かどうかはどうなるかによる.
Short instance creationは
Map<String,Integer> map = new HashMap<String,Integer>(); for(String word : args){ Integer freq = map.get(word); map.put(word, (freq==null) ? 1 : freq+1); }
を
map := new HashMap<String,Integer>(); for(word : args) { freq := map.get(word); map.put(word, (freq==null) ? 1 : freq+1); }
という風に型が自明に定まるところは省略できるというもの.
Language level XML SupportはStringはクラスだけど"foo"みたいに特別なインスタンス生成規則があるけど,同様にjava.lang.XMLというクラスを追加して