Sunday, May 31, 2009

JavaFX is statically typed. Scala is statically typed.

Sometimes people are suprised when they read or hear that Scala and JavaFX are statically typed languages. Probably it is because in this languages you can declare variables without explicitly telling the type, like this:
//It looks exactly the same in JavaFX and Scala
var a = "string";
No type is given, yet compiler knows a is String (at compile time). How does it know? Well, we just assigned value of type String to it, didn't we? When declaring some variable and immediately assigning value to it, you don't have to add type to the declaration.

No comments: