This is a mirror of official site: http://jasper-net.blogspot.com/

Fantom

| Tuesday, September 21, 2010
Hello World

We start our whirlwind tour of Fantom's features, with the quintessential hello world:

class HelloWorld
{
 static Void main()
 {
   echo("hello world")
 }
}

Minor differences from Java or C# include:

  • all type names are capitalized including Void (Fantom doesn't have primitives nor primitive keywords).
  • Class and method protection scope default to public.
  • Fantom sports the echo method for writing to the console or you can use Env.cur.out.
  • Statements can be terminated with a newline (you can use a semicolon too)
  • You can declare Str[] args or access them from Env.args

Overview

Do we really need another programming language? Well obviously we thought so, or we wouldn't have built Fantom! Fantom is designed as a practical programming language to make it easy and fun to get real work done. It is not an academic language to explore bleeding edge theories, but based on solid real world experience. During its design we set out to solve what we perceived were some real problems with Java and C#. Our background is heavily Java, but many of Java's problems are shared by C# and .NET also.

Portability

The primary reason we created Fantom is to write software that can seamlessly run on both the Java VM and the .NET CLR. The reality is that many software organizations are committed to one or the other of these platforms. Even dynamic languages like Python and Ruby are getting hosted on one of these VMs. Whether your business is in-house software or building software components to sell to other companies, you tend to pick one camp or the other.

We built Fantom from the ground up to tackle portability between these VMs. Fantom's source language compiles into fcode - a bytecode representation that can be translated into both Java bytecode and IL easily. This translation is typically done at runtime, which enables you to deploy Fantom modules as a single file and have them run on either VM.

But getting a language to run on both Java and .NET is the easy part - in fact there are many solutions to this problem. The hard part is getting portable APIs. Fantom provides a set of APIs which abstract away the Java and .NET APIs. We actually consider this one of Fantom's primary benefits, because it gives us a chance to develop a suite of system APIs that are elegant and easy to use compared to the Java and .NET counter parts.

But portability means much more than just Java or .NET. We also support compiling Fantom to JavaScript for use in browsers, including support for many of the standard libraries.

Because Fantom is designed from the ground up to be portable, targeting new platforms is reasonably easy. Future targets might include Objective-C for the iPhone, the LLVM, or Parrot.

Read more: Fantom

Posted via email from .NET Info

0 comments: