Showing posts with label java7. Show all posts
Showing posts with label java7. Show all posts

2011/11/15

Devoxx11: Java 7 toolbox


Project coin brought some minor improvements to the Java language. Most notably:
  • easier generics:
    • diamond operator <>: less copy/paste thanks to smarter compiler
    • less warnings on vararg's
  • easier error-handling:
    • multicatch: less copy/paste
    • 'try-with-resource' contstruct: automatic & correct closing and error handling
  • consistency / clarity
    • Strings in Switch
    • numbers improvements:
      • direct binary format: 0b0101001
      • logical grouping of large number in sub-chunks: 123_435_576L --> java ignores the underscores.
IDE support
  • Netbeans & Intellij have excellent support for Java 7
    • inline hints and refactorings are offered
    • batch refactorings throughout the 'inspect and transform' dialog
  • Eclipse is somewhat lagging behind.

2009/11/18

Devoxx 2009: Project Coin

18/11/2009, Joe D. Darcy, Sun

slides: http://blogs.sun.com/darcy/entry/project_coin_devoxx_2009

Project Coin
  • small language changes in JDK7
  • keep broad consideration of java landscape → remain consistent with the Java Language
  • bigger language changes, not in scope of Project Coin
    • JSR308: annotations to improve static checkers (e.g. @NotNull)
    • JSR294: modularity
principles of Project Coin:
  • reading more important than writing
    • 'beautiful' code
    • don't hide what's happening
  • simplicity matters
  • no slash-and-burn: remember broad user-base
  • balance stability versus progress
  • prefer library / IDE changes over language changes (String.join)
  • no new keywords
  • no type system changes
  • small in specification, implementation and testing
methodology:
  • open: blog entries / white board on Devoxx2008
  • call for proposals
  • prototypes recommended
    • lot of work
    • very beneficial → learn / find issues
  • existing requests for enhancement: 120 changes → too much
final list of Project Coin enhancements
  • numbers:
    • binary notation: 0b00100100001
    • group numbers with '_': long big = 1_123_456_789;
  • switch on a String – really cool!
    • specification: only one word added
    • proposal contains a suggested implementation:
      • uses String.hashCode() for an initial switch
    • big patch in javac
    • lots of tests to validate change
      • reject pre -source 7 classes
      • null behavior
      • hash collisions
      • fall-throughs
      • → comparable to enum switch control flow
  • diamond <> operator : type interference → e.g. Map <String,String> map = new HashMap<>();
    • a lot of prototyping work
    • quantitative analysis
    • some concerns on language evolution were considered
  • JSR292: invokedynamic for dynamic languages
  • auto-close of Closable types within a special try block (ARM)
    • try(File f = new File) {} → f is automatically closed when leaving the block
  • simplified varargs method invocation, working along with generics
  • language support for Lists and Maps:
    • List<String> list = [“1”, “2”];
    • list[0]
    • map{“hello”}
not retained in Project coin:
  • Elvis operator:
    • use ?: as a shorthand for testing on null
    • conclusion from building a prototype→ doesn't fit well in java
  • multiple exception handling
    • disjunctive means of | operator
  • properties:
    • changes the type system
    • a lot of work (e.g. reflection api, corner cases …) – the 'enum' specification is demonstrated as a comparable change that involved a lot of rework
    • pseudo-properties workaround: via annotation-processing → Project Lombok
  • reified generics
    • source language compatibility issues – java generic erasure was chosen for backward compatibility
    • C# created a separate generic library
    • difficult for other languages to target the a platform with reified generics
  • extensible enums
    • most enums are constant
    • low utility

Devoxx 2009: JDK 7 Update

18/11/2009, Mark Reinhold

higlight: Closures in java are BACK!

Aims of JDK7
  • modular platform
    • JDK7 status:
      • 13MB download with pack200 compression
      • difficult to support smaller (embedded) hardware
    • → Jigsaw project
      • low-level modules, at the rt.jar level
      • language support: module-info.java file
        • explicit module / version requirements
        • create simpler OS-specific package, with correct dependencies (e.g. deb-packages)
      • OSGi interoperability
  • multi-lingual support
    • better JRuby, Jython support on the JVM
    • InvokeDynamic
    • “Da Vinci Machine project”
  • productivity enhancement
    • “Project Coin”
    • language changes that improve programming experience. E.g.:
      • type inference with the <> (aka. 'diamond') operator: Map <String,String> m = new <> HashMap();
      • split numbers with '_' for better readability: int a=123_456_789;
      • support binary notation: int b=0b00100100001;
      • Lists: direct construction and access to set/get with []: a[4] = b[5];
      • Map: direct construction and access to set/get with {}: a{“b”}=”xyz”;
      • auto-close Closeable interfaces: try(File f = new File()) where f is always closed correctly.
  • performance
    • multi-cores are there! → java support needed.
    • → fork/join framework
    • Dual-Pivot Quicksort
    • Closures: “It's time to add them” – I thought this was dropped from Java7 plans...
      • needed:
        • function literals
        • function types
        • extension methods
      • “doesn't fit in java”:
        • non-local control transfer
        • capture non-final vars
        • library-defined control structures
When?
  • Planning shifted
  • Milestone 10: 2010/09/09: release candidate