Tuesday, May 6, 2008

JavaOne - Day Two

I realized my day numbers may be off since I'm counting the Java University as day one. Consider this a 1 based indexing.

The conference kicked off with Sun's general session "Java + You". Some intro and demo on devices, including Amazon's Kindle; impressive JavaFX applications that crashes, but still exciting nonetheless; Neil Young's music archive project running on Java & PS3.

On to the technical sessions.

Overview of the JavaFX Script Programming Language - Christopher Oliver

Language features:

  • Integrated with Java

  • Object-Oriented

  • Closures

  • First-class Functions

  • Multiple Inheritance

  • Imperative and Declarative Syntax

  • Statically Typed with Type-inference

  • Time is a first class type

  • Key frame animation

Too bad it followed immediately after Sun's JavaFX demo, which made examples in this session look really really boring. 3D HD video rendering vs a spinning box...

More "Effective Java" - Joshua Bloch

Lots of people went to this. A bit of a fiasco with line control. There were people everywhere and the coordinators tried to do a snake line. Only problem is, we didn't know that. The quote of the day would be "They are not lined up properly. I'm not going to let them in."

Back to topic: Effective Java 2nd Edition is out. New stuff:

  • Chapter 5: Generics

  • Chapter 6: Enums and Annotations

  • Java 5 language features

  • Concurrency (renamed from Threads) for java.util.concurrent

  • Existing items updated to reflect current best practices

  • 57 items in first edition; 78 in second edition

Spring Framework 2.5: New and Notable - Rod Johnson

Lots of new stuff. Strong preference for using annotation based dependency injection. Here's one slide on pros and cons of using annotation-based DI.


  • Annotations can reduce or eliminate external configuration

  • More concise mechanism because you specify what would be injected, with the location of the annotation providing where


  • Annotations are per-type not per-instance

  • Doesn't work for legacy code with existing classes without annotations

  • Need to recompile Java code to modify configuration

  • Not well suited for externalizing simple types

That's 2-4. Obviously not equally weighed points.

Defective Java Code: Turning WTF Code into a Learning Experience - William Pugh

Some examples taken from The Daily WTF.

  • Don't synchronize on String constants; they get interned. Use new Object(). A rare case of appropriate use in instantiating an Object object.

  • DateFormat not synchronized. This tip would've been handy 2-3 years go. ;-) Create a new instance of DateFormat (fast) each time or use ThreadLocal.

  • War on equals() implementation: instanceof vs getClass()

  • FindBugs

Let's Resync: What's New for Concurrency on the Java Platform, Standard - Brian Goetz

Moore's law still in effect, only it shifted from CPU clock rate to number of CPU cores. ---> Many more programmers are becoming concurrent programmers whether they want to or not.

Parallelization technique: divide-and-conquer, much like the merge sort algorithm.

Java Fork/Join framework to the rescue.

  • Create a limited number of worker threads

  • Each worker thread maintains a private double-ended work queue (deque)

  • When forking, worker pushes new task at the head of its deque

  • When waiting or idle, worker pops a task off the head of its deque and executes it (instead of sleeping)

  • If worker's deque is empty, steals an element off the tail of the deque of another randomly chosen worker

Code Ninja

The folks at Amazon's booth dubbed me a Code Ninja for solving their coding puzzle.  I'm bringing the puzzle back home.  Here's one hint:  it has to do with adding numbers.

No comments: