Fantom (programming language)

From Wikipedia, the free encyclopedia
DeveloperBrian Frank, Andy Frank
First appeared2005[1]
Stable release
1.0.78 / April 26, 2022; 13 months ago (2022-04-26)[2]
Typing disciplinestatic, dynamic
LicenseAcademic Free License version 3.0[3]
Filename, .fwt, .pod
Influenced by
C#, Java, Scala, Ruby, Erlang

Fantom is a general purpose object-oriented programming language created by Brian and Andy Frank[4] that runs on the Java Runtime Environment (JRE), JavaScript, and the .NET Common Language Runtime (CLR) (.NET support is considered "prototype"[5] status). Its primary design goal is to provide a standard library API[6] that abstracts away the question of whether the code will ultimately run on the JRE or CLR. Like C# and Java, Fantom uses a curly brace syntax. 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 aspects of both static and dynamic typing.


All variables in Fantom are statically typed. Fantom does not have generic types, but it does have a set of built-in generic types: List, Map, and Func. Fantom can also take on the feel of a dynamically typed language through dynamic calls and automatic downcasting. Fantom has a reflection API and metaprogramming capabilities.

Fantom is open source under the Academic Free License 3.0 and is available for Windows and Unix-like platforms (including Mac OS X).[7]

IDE and Tools[edit]

F4 is the main publicly available IDE for the Fantom language, officially supported by one of the main open source contributors to the language - Steve Eynon. The F4 IDE is available on GitHub

More free tools and information are also available at


In Fantom, the unit of deployment is called a pod. Pods take on the role of namespaces, packages, and modules. They are stored as .pod files, which are zip files containing the FCode (the Fantom bytecode), the documentation, and resource files necessary to run the pod. A pod can define any number of types for use in other libraries and applications. A pod name fully qualifies as a type name. For example, fwt::Widget is distinct from webapp::Widget. If a pod contains a type named Main, then it can be executed on the command line with fan <podName>

The Fantom build system can package a set of Pods into a JAR archive through build::JarDist.

Fantom Widget Toolkit[edit]

Fantom ships with a standard windowing toolkit called the Fantom Widget Toolkit, or FWT for short.[8] Like Fantom, FWT was designed to be portable across several platforms. It is currently implemented on the JVM using the Standard Widget Toolkit as a backend. The JavaScript implementation is backed by the canvas element and JavaFX, allowing FWT applications to be run in a web browser. There are plans for a CLR implementation using Windows Forms.

"Hello World" example[edit]

Here is the classic Hello world program written in Fantom:

// Hello from Fantom!
class HelloWorld
  static Void main()
    echo("Hello, World!")

Notice that "Void" is capitalized. This is because Void is a class, not a primitive type in Fantom.

Name change[edit]

The original name of the Fantom programming language was Fan, named after the neighborhood where the creators live in Richmond, Virginia. After the language gained some popularity, members of the community raised concerns about the searchability of the name. In November 2009,[9] the name of the project was officially changed from Fan to Fantom.[10]

Other features[edit]

Fantom has other useful features:

  • Fantom supports imports of Java Classes and modules with some limitations.[11]
  • Integer is 64-bit. Unlike Java and C#, Fantom does not have Long or Short integer types.
  • Serialization and deserialization of classes to/from strings.[12]
  • Fantom does not support tuples (that is, types which are the Cartesian product of other types)[13]

A game - in Fantom?[edit]

Escape the Mainframe is a browser game (just like the Google t-rex dinosaur) completely written in Fantom by Steve Eynon:

See also[edit]


  1. ^ Blog post about history of Fantom
  2. ^ "Fantom". 26 March 2020.
  3. ^ FAQ of Fandoc language website
  4. ^ Fantom FAQ: Contact Us
  5. ^ "Fantom FAQ: Roadmap". Archived from the original on 2015-12-11. Retrieved 2012-03-29.
  6. ^ Fantom FAQ: Why Fantom?
  7. ^ McAllister, Neil (2012-01-03). "10 programming languages that could shake up IT". InfoWorld. Retrieved 2015-10-30.
  8. ^ "fwt – Fantom". 2015-01-08. Retrieved 2015-10-30.
  9. ^ History of Fantom programming language
  10. ^ Fan is officially now Fantom
  11. ^ Java FFI at Fantom home page
  12. ^ Serialization at
  13. ^ Tuples question at Fantom official page

Further reading[edit]

External links[edit]