Friday, August 27, 2010

OO Hello World - JavaFX



The Hello World version of the program in JavaFX!  

Better late than never!!! JavaFX was already included in the list of most active JVM and CLR languages around as well as its keywords in the keywords page of this blog. Now I'm adding here below the OO Hello World program that I will also add to the how many keywords and lines comparison posts :)

And of course I will include it in the newest series "Basics by Example" but later on :) 


By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.

class Greet {
    var name: String;
    init {
        name = "{name.substring(0,1).toUpperCase()}{name.substring(1, name.length())}";
    }
    function Salute(){
        println("Hello {name}!")
    }
}

// Greet the world!
var g = Greet{name: "world"};
g.Salute();

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.

package greetprogram;
import javafx.*;

public class Greet {
    var name: String;
    init {
        this.name = "{name.substring(0,1).toUpperCase()}{name.substring(1, name.length())}";
    }
    public function Salute(){
        println("Hello {this.name}!")
    }
}

// Greet the world!
public function run() {
    var g = Greet{name: "world"};
    g.Salute();
}

The Program Output:









JavaFX Info:
“JavaFX apps developers use a statically typed, declarative language called JavaFX Script; Java code can be integrated into JavaFX programs. JavaFX is compiled to Java bytecode, so JavaFX applications run on any desktop and browser that runs the Java Runtime Environment (JRE) and on top of mobile phones running Java ME.” Taken from: (http://en.wikipedia.org/wiki/JavaFX)

Appeared:
2008
Current Version:
Developed by:
Sun Microsystems
Creator:
Chris Oliver
Influenced by:
Java (James Gosling)
Predecessor Language

Predecessor Appeared

Predecessor Creator

Runtime Target:
JVM
Latest Framework Target:
JDK 6
Mono Target:
No
Allows Unmanaged Code:
No
Source Code Extension:
“.fx”
Keywords:
70
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
No
Standard:
?
Latest IDE Support:
NetBeans
Eclipse
IntelliJ IDEA
Language Reference:
Extra Info:



No comments:

Post a Comment