Features · Polyglot

Polyglot

A program is defined once and rendered into many languages, and back into Program itself.

One source, every target

The ultra-simple syntax of Program has been especially designed to transpile on an individual, line-by-line basis using simple text processing. The compiler stores each module in a canonical command form and renders it per target. The logic, the names and the order stay the same; only the punctuation each language needs is added.

LET Maths.Integer sum = Maths.Integer.Add 2 3
LET Text text = Maths.Integer.ToString sum
Console.Line text

Those three lines become idiomatic JavaScript, Dart, Swift, Go, Rust or Zig, with the shape unchanged. See the same counter rendered across every target on the targets page.

Minding the target

When rendering Program to its different targets, the conventions and limitations of each target have to be taken into account: some languages allow deep nesting of namespaces, and some have firm conventions for capitalisation. The table below gathers the specifics for each target; each target page also lists the reserved keywords it must steer clear of.

TargetNamespacesCapitalisation
JavaScript No real namespaces; nested objects stand in for modules. No enforced casing.
TypeScript Object-nesting like JavaScript, plus a real namespace keyword. No enforced casing; types in PascalCase.
Dart No nested namespaces; libraries are flat. lowerCamelCase members, UpperCamelCase types.
Swift No namespaces; enums and structs nest as containers. UpperCamelCase types, lowerCamelCase functions.
Go One flat package per directory; no nesting. Semantic: uppercase is exported, lowercase is private.
Rust Real nestable modules, reached by ::. snake_case values, UpperCamelCase types.
Zig Structs and files are containers, nested by .. No enforced casing; camelCase functions, TitleCase types.
JSON Canonical form; stores the full path verbatim. Names kept exactly as written.