OpenJFX Lambda Day, Feb 25th 2014

anton nashatyrev anton.nashatyrev at
Tue Feb 18 09:25:32 PST 2014

Hello All,

     I'd like to add my 2 cents to lambdafication of JavaFX:

     Recently I was working on a fix in the JFX and used convenient JFX 
beans feature - 'select binding':*(ObservableValue<?> root, 
java.lang.String... steps)

     I.e. to select some chain of properties one should write something 

BooleanBinding bb = Bindings.selectBoolean(control.sceneProperty(), 
"window", "isShowing");

     When having templates and lambdas this API looks legacy. This kind 
of usage is not type-safe, may lead to runtime errors and involves 
reflection in the implementation.

     The idea is to use type-safe functional-style 'selector' like this:

public interface Selector<T, E> {
      ObservableValue<E> selectValue(T t);

     and the helper interface (class):

public interface SelectElement<E> {
      <K> SelectElement<K> select(Selector<E, K> p);

      <K extends Boolean> BooleanBinding selectBoolean(Selector<E, K> p);
      <K extends Integer> IntegerBinding selectInteger(Selector<E, K> p);
      <K extends Long>    LongBinding selectLong(Selector<E, K> p);
      <K extends Float>   FloatBinding selectFloat(Selector<E, K> p);
      <K extends Double>  DoubleBinding selectDouble(Selector<E, K> p);
      <K extends String>  StringBinding selectString(Selector<E, K> p);
      <K>                 ObjectBinding selectObject(Selector<E, K> p);


     The new Bindings method replacing all select*() methods:

     publci static <E> SelectElement<E> select(ObservableValue<E> o);

     With the new API the example above would look like:

BooleanBinding bb =
         select(s -> s.windowProperty()).
         selectBoolean(w -> w.showingProperty());

     The benefits of the new API:

  * Static type checking - no chances for a mistake when selecting long
    chain of properties
  * IDE code assisting for property selection
  * not restricted to properties only, but might be used with any
    observable. I.e. one may want to select an element from observable
    collection at any selection step
  * might be implemented without reflection, which may result in some
    performance gain

This change is of course might be targeted to JDK9 only.

Thanks for taking a look!

On 15.02.2014 3:35, Stephen F Northover wrote:
> Hello all,
> Mark it on your calendar.  Feb 25th is OpenJFX Lambda day.  On that 
> day, we will lock the code base, lambdify everything in sight, and 
> then open up for business again.  One thing that we won't be doing 
> right away is converting our code to use streams and other JDK8 
> features but this is inevitable (perhaps after 8u20).  We are part of 
> the JDK, we ship with the JDK so we will use features from the JDK.
> Like "Lambda's to the slaughter" the Android and iOS ports of OpenJFX 
> will be affected.  We've been discussing the use of RetroLambda on and 
> off in JIRA for a while and it seems that it will work for both 
> ports.  We care about these ports and it is possible that Lambda Day 
> will slip for one reason or another.  For one thing, the lambdifying 
> tools blow up some of the source making lambda conversion a somewhat 
> manual process.  Hopefully we can get the bugs fixed before the day.
> On that day, I will be listening to 'The Lambda Lies Down on Broadway" 
> all day.  Those of you with children might prefer "Mary had a little 
> Lambda".  Despite being called "The Lambda Police", I am and old 
> Lisper and a card carrying member of the "Knights of the Lambda 
> Calculus".  Look that one up.  I know the founder personally but will 
> never tell who it is.
> Steve

More information about the openjfx-dev mailing list