Saturday, July 3, 2010

OO Hello World - Fantom



The Fantom version is here. Fantom is one of the newest languages out there targeting the Java JVM and the .NET CLR runtimes! It is also a C#/Java – Like language with lots of interesting features.


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
{
 Str? name
 new make(Str name) 
 { 
  this.name = name.capitalize()
 }
 Void salute()
 {
  echo("Hello $name!")
 }
}

// Greet the world!
class GreetProgram
{
 static Void main()
 {
  Greet g := Greet("world")
  g.salute()  
 }
}

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

internal class Greet
{ 
 private Str? name
 new make(Str name) 
 { 
  this.name = name.capitalize()
 }
 Void salute()
 {
  echo("Hello $name!")
 }
}

// Greet the world!
public class GreetProgram
{
 public static Void main()
 {
  Greet g := Greet.make("world")
  g.salute()  
 }
}

The Program Output:












Fantom Info:
“Fantom is a general purpose object-oriented programming language that runs on the JRE, .NET CLR, and Javascript. The language supports functional programming through closures and concurrency through the Actor model. Fantom takes a "middle of the road" approach to its type system, blending together aspects of both static and dynamic typing. Like C# and Java, Fantom uses a curly brace syntax.” Taken from: (http://en.wikipedia.org/wiki/Fantom_(programming_language))

Appeared:
2008
Current Version:
Developed by:
Brian Frank, Andy Frank
Creator:
Brian Frank, Andy Frank
Influenced by:
Java (James Gosling) and C# (Anders Hejlsberg)
Predecessor Language

Predecessor Appeared

Predecessor Creator

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


No comments:

Post a Comment