Hi everybody
I was introducing the JavaFX syntax to some friend, and i told him: “be warned, while it is called JavaFX ,it is NOT Java” , then i thought: ok , if it is not java,what is it? after a while ,a small smile came to my face ,Ohhhh…. it is not Java, it IS javascript, a statically typed version of the javascript language
you don’t believe me…, ok , consider the following java script variable definition
var name="Joe";
then add type information to express that the name variable is actually of String type
var name:String="Joe";
surprise, this is a 100% legal and valid JavaFX syntax,
let’s try another one: function definition
function sum(i,j){
}
again, add type information to variables and to function return type
function sum(i:Integer,j:Integer):Integer{
}
again this is how functions are defined in the JavaFX syntax
need another example? let’s consider the JSON notation
Javascript:
{
name:"joe",
age:30
favourites:[
"java","javafx"
]
}
again add type information
User{
name:"joe",
age:30
favourites:[
"java","javafx"
]
}
and again this is the Object literal notation of JavaFX and it’s really considered their power tool for declarative programming, and the way which make GUI and animation coding a lot easier
also, JavaFX designers doesn’t even try to make the syntax compatible with their primary language:Java
consider the for iteration syntax
for(i:Integer in collection){}
note the in keyword,this is not the java syntax
for(Integer i : collection){}
finally, i would like to ask a question, is this intended? or just by chance? i mean does sun mean to bring a language familiar to designers(javascript) and add type information required by the JVM runtime,does this benefit the platform as a whole by introducing new players (javascript web developers) to the game,or it will make the java developers(the first class target) work in an unfamiliar environment
Filed under: javaFx | Tagged: javaFx | 2 Comments »