Some programming shortcuts offered by JavaFX, nice when taken separately, can be a deadly combination when used together...
JavaFX tries hard to look as friendly/easy to use as, say, JavaScript.
So it doesn't require you to always declare the type of variables, function parameters or return values.
But since it is a statically typed language, it must guess these types at compilation time; unlike dynamically typed languages which do that at runtime (much easier!) and sometime (depends on the language) even allow to change the type (store a string in a variable holding an int).
Sometime it fails to guess and issue a compiler error, asking you to be explicit.
Sometime it fails badly and the compiler crashes! (see my bug report at Jira / Kenai for example).
And sometime it can just make a wrong guess, bitting you in the back!
Another attempt to be easy/good looking is to allow omitting the return keyword in functions: JavaFX can take the last expression in the function as return value.
It is nice in a create() method of CustomNodes where you just put the Group {} declaration, or a for () loop building a sequence, each expression result becoming a new sequence item.
It looks a bit odd when you just leave a foo; value or even a literal value, and might be surprising when the last expression is an assignment!
Then it can lead to unexpected results, particularly when combined with the automatic type inference...
I saw that in the JavaFX forum: a programmer declared a simple function, omitting the return value as it returned nothing. But actually, he was returning a value, without knowing... In a conditional branch, next to the end of the function, there was a last assignment, so the compiler took the type of the assigned value as return type for the function. Not a major problem as the returned value will be just discarded at the call.
But in the other branch of the condition, he used a break; to stop early the loop he was in. The compiler was confused, thought break was an expression and reported it wasn't compatible with found type...
Actually, it was so much confused that it issued an internal error (hence the above bug report), but that's anecdote, without that it could have given a semi-cryptic error message. I know I was confused a couple of time by these errors until I thought of giving an explicit return type.
And that's the moral of the story: not specifying types is a nice facility that I don't plan to give up, but for these reasons and some others, like plain readability, I will try and always specify return type, and even parameter types (ie. the whole signature) for functions.
And you?
Pour une fois j'ai écrit l'article directement en anglais, je l'ai traduit dans Attention au système de déduction de type de JavaFX !