I'm reasonably good at mental arithmetic, and I want my son to learn to do it as well. I think it's a disadvantage in life if you have to search for a calculator every time you need to add, subtract, multiply, or divide a couple of numbers. For that reason, I've written a number of arithmetic training programs for him. The first one I wrote was written in C# using the GUI building abilities of a cross-platform Java/C# IDE that I used to use, Xdevelop. Actually, I would still be using that IDE if they hadn't stopped supporting it a couple of years ago; I thought it was great.
Eventually, I wanted to write a second version of the arithmetic program, one that adjusts to the user's abilities. This is a fairly simple technique that I learned back in my educational multimedia days. You make the problems harder each time the user gets one correct, you make them easier each time the user gets one wrong. In this way, the program can quickly auto-adjust to the user's current level of skill. For this second version, I decided to use Java and Swing, but I wanted to use something like a GUI builder. You can write a user interface directly in Java, but it's a slow tedious process, and I don't have the time to waste on that. At that time, there was an early version of JavaFX available. JavaFX allowed you to declare the structure of your user interface by defining a simple structure of components within components; a bit like an XML file, but not XML, a hierarchical syntax more akin to Java syntax. It wasn't as good as a full-on visual GUI builder, but still seemed easier and more manageable than writing Swing code directly in Java. If you are writing JavaFX, I strongly suggest you download NetBeans, as its built-in JavaFX support is not bad. There is also a plug-in for Eclipse, but no plug-in (that I know of) for Intellij. There is a slim version of NetBeans now that has just the bits you need for Java and JavaFX development; it's much smaller than the "complete" version of NetBeans.
Anyway, this new arithmetic program has worked very well, but I need to make a few minor improvements, so I thought I should check the latest version of JavaFX. Recently, JavaFX 1.0 was released, and this has changed significantly. The old version was a simpler way to write Swing programs, the actual 1.0 release now has a "Stage" and "Scene" metaphor that is reminiscent of the Macromedia tools I used to use in my multimedia development days, particularly Macromedia Director (Adobe subsequently bought Macromedia). That's a good thing; those Macromedia tools really impressed me because both programmers and artists could use the same tool and usefully contribute to the final product. The same can't be said of most programming IDEs. The Macromedia tools were genuinely inclusive, in a way that so many software development tools are not. There is something wrong when so much software still only targets only the cleverest 5% of users. The other 95% deserve to have a chance to contribute as well, and they tend to be excluded unnecessarily.
Anyway, NetBeans 6.5 has support for JavaFX 1.0, including a new "palette" of visual items that you can drag-and-drop onto your "Stage". What I found, though, is that JavaFX has lost its ability to do Swing GUIs. Instead, a bit like the Macromedia tools I used to use, you have to lay things out yourself based on absolute pixel locations. This kind of user interface development works well when you have a very graphical interface created by an artist, and when you have an IDE that makes it easy to work with images, etc., and lay them out visually in the correct pixel positions. However, I'm not an artist, and NetBeans 6.5's JavaFX facilities are poor when compared to Macromedia's tools from 1996 (yes, over 12 years ago). I would hate to have to use NetBeans to do any serious JavaFX development. If JavaFX is going to compete with Flash, it can't just do the run-time, back-end things properly, it also has to be easy to author. At the moment, it is generations behind, and I really wonder which group, Sun or other, is going to be able to step up and provide the necessary interface, if it is to be a success.
Having discovered how different JavaFX 1.0 is from old JavaFX, it occurred to me that I was better off porting my program to Groovy. Groovy is a Java-based scripting language that compiles to Java byte codes and can use any Java library, so it's easy to learn if you have a background in Java development. Like JavaFX, Groovy provides a syntax for declaring the structure of a user interface (and uses a similar structure for XML, very useful, but a topic for another post sometime). Unlike JavaFX, Groovy uses the normal Swing components, so the conversion was fairly straightforward. It took me about a day, mainly because I was learning Groovy at the same time as doing the conversion.
The only significant difference between Groovy and the old JavaFX is that JavaFX has a neat "bind" keyword that can be used to make the value of a field in the user interface stay synchronised with a particular variable. It's a simple idea, but very powerful. It removes a lot of event handling code that you would normally have to add to a Java program. So, the Groovy version of my application required some new event handling code. Luckily, Groovy provides "closures", essentially "pure" methods that aren't attached to a particular class, and these simplify the writing of event handling code. As compared to converting to JavaFX 1.0, converting to Groovy and adding some event handling code was definitely easier. My son has his new arithmetic program running now, with some new features. Groovy is stable enough that I shouldn't face the same migration problem the next time I want to add some new features.
The more I use Groovy, the more I like it. It's worth the time to learn it, if you write enough code in plain old Java and would like to save some time.