PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Fantom

Fantom

Fantom is a pl created in 2005.

#168on PLDB 17Years Old 521Users
0Books 0Papers 176Repos

Try now: TIO

Fantom is a general purpose object-oriented programming language created by Brian and Andy Frank that runs on the Java Runtime Environment (JRE), JavaScript, and the .NET Common Language Runtime (CLR) (.NET support is considered "prototype" status). Its primary design goal is to provide a standard library API 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. Read more on Wikipedia...


Example from hello-world:
// Hello from Fantom! class HelloWorld { static Void main() { echo("Hello World") } }
Example from Linguist:
/* * Author: Robert Koeninger * License: WTFPL (http://www.wtfpl.net/) */ mixin Expr { abstract Obj? eval() } class Constant : Expr { Obj? value new make(Obj? value) { this.value = value } override Obj? eval() { value } } enum class Op { plus, minus } class Infix : Expr { Op op Expr left Expr right new make(Op op, Expr left, Expr right) { this.op = op this.left = left this.right = right } override Obj? eval() { switch (op) { case Op.plus: return (Int)left.eval() + (Int)right.eval() case Op.minus: return (Int)left.eval() - (Int)right.eval() default: throw Err("undefined Op") } } }
Example from Wikipedia:
// Hello from Fantom! class HelloWorld { static Void main() { echo("Hello, World!") } }

Language features

Feature Supported Example Token
Strings
"Hello world"
"
MultiLine Comments
/* A comment
*/
/* */
Print() Debugging echo
Comments
// A comment
Line Comments
// A comment
//
Semantic Indentation ϴ
java-server-pages.html · fantom.html · sparc.html

View source

PLDB - Build the next great programming language · v2022 · Day 31 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com