JavaFX: statically typed javascript

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


again add type information


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

2 Responses

  1. Those examples are action script 3. Or is it that JavaScript, JavaFX and Actionscript 3 are all ECMA Script compliant?

  2. I think this is great, if it wasnt intended, still its good news. Anyone that ever developed a website, once in their life, had to understand javascript. Your explanation also made feel good about the syntax, i will look at the javafx code with different eyes now….

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: