Alternative Languages at Devoxx and Soon JavaOne Brazil
steveonjava | November 24, 2010I did my JavaFX Alternative Languages talk at Devoxx and will soon be presenting it at JavaOne Brazil (December 7-9th).
During the Devoxx talk I was honored to have Martin Odersky in the audience (for those of you who don’t know him, Martin is the man behind Generic Java and now Scala). There were several great questions at the end of the talk, one posed by Martin himself.
The question was around this Scala code fragment:
def timeline = new Timeline {
repeatCount = INDEFINITE
autoReverse = true
keyFrames = List(
new KeyFrame(50) {
values = List(
new KeyValue(rect1.x() -> 300),
new KeyValue(rect2.y() -> 500),
new KeyValue(rect2.width() -> 150)
)
}
)
}
He was wondering why I had the extra parenthesis after the variables (x, y, and width). In Scala using parenthesis is optional for methods and allowed for variables, so it appears to be a style issue. However, there is a good reason for this.
The current JavaFX property model has 4 helper methods for each variable:
- int getX() – Standard JavaBeans getter function for the property x.
- setX(int x) – Standard JavaBeans setter function for the property x.
- static PropertyReference X() – A static function that returns a property reference for x that can be used to refer to this field.
- ValueBinding x() – A member function that returns a mutable reference to x that can be used to get or set the value dynamically.
So the extra parenthesis were to differentiate between a normal method call (“x”) and a ValueBinding (“x()”).
By popular demand at the earlier SvJugFx Event, I also added in some new content demonstrating usage of the Fantom language for coding JavaFX. Besides being extremely easy to create DSLs in, it also has a built-in Duration operator, making the end result extremely similar to the equivalent JavaFX Script:
Here is the full talk on alternative languages with all the updates for the latest conceptual JavaFX 2.0 APIs:
If you are going to be at JavaOne Brazil, please drop me a line and I will be happy to meet up and chat about JavaFX futures.

























