« Return to Thread: "Scala FX" and properties

"Scala FX" and properties

by Scot McSweeney-Roberts-6 :: Rate this Message:

Reply to Author | View in Thread

did I understand it correctly, that Scala couldn't be used as a direct alternative to Java FX Script?

I think there are a couple of problems with using Scala as direct alternative to JavaFXScript. The biggest problem I can think of (and which affects both desktop and mobile JavaFX profiles) is that there doesn't appear to be any documentation for how Java code can access the JavaFX runtime. I haven't been able to find any such docs, but if they existed then it might be possible to just use Scala in place of Java, at least on the desktop. The mobile profile presents even more of a challenge as it's meant to run on top of JavaME. I don't think Scala has ever worked on JavaME (I could be wrong, but that was the last thing I heard) and if 2.8 is dropping JDK 1.4 support then it certainly won't be possible.

 I think that Scala is powerful enough so it should be possible to wrap properties into a class that allows you to bind them; i.e. when one property of one object changes (e.g. a check box is toggled) then another property of a different object changes as well (e.g. a boolean property of a business model object). In Java FX Script, this feature is a very fundamental part of the language, automatically enabled for all properties, but not so in Scala. 

I haven't been able to replicate JavaFXScript's binding style in Scala - no matter what I try the variable/value on the LHS of the bind takes the value of the variable on the RHS at the time of binding and never changes. Maybe somebody else can come up with a way to do it - if so I'd love to see how to do it, as I'm stumped. And that was just variable binding - bound functions and replace triggers are probably even more of challenge. To be honest though, I haven't yet found any real use for JavaFXScript's data binding - but that could be because the docs don't really show it being used in any meaningful way.

As an aside, I really wish the JavaFXScript developers would have used Scala style syntax for things like vals (which in JavaFXScript are "def"s) and traits (which are defined by preceding class with "mixin"), had made semicolons optional and had used any other syntax than the one chosen for appending values to sequences ("insert x into xs;" - yuck). Had they done so, then JavaFXScript might have been a good stepping stone to Scala. 

 « Return to Thread: "Scala FX" and properties