Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

The Faber language

Everything you need to read Faber is on this page. The pages beneath it go deeper on each part, but nothing here is a placeholder — if you read this far and stop, you can read a Faber program.

A whole program#

reader locale
faber convert --to en — English reader surface
fn saturate(int x) → int {
    if x ≺ 0 then return 0
    if x ≻ 255 then return 255
    return x
}

main {
    let int v ← saturate(300)
    print v
}
faber convert --to la — canonical Faber
functio saturate(numerus x) → numerus {
    si x ≺ 0 ergo redde 0
    si x ≻ 255 ergo redde 255
    redde x
}

incipit {
    sit numerus v ← saturate(300)
    nota v
}
faber convert --to th-TH — Thai
ฟังก์ชัน saturate(จํานวน x) → จํานวน {
    ถ้า x ≺ 0 ดังนั้น คืน 0
    ถ้า x ≻ 255 ดังนั้น คืน 255
    คืน x
}

เริ่ม {
    กำหนด จํานวน v ← saturate(300)
    บันทึก v
}
faber convert --to zh-Hans — Simplified Chinese
函数 saturate(整数 x) → 整数 {
    如果 x ≺ 0 则 返回 0
    如果 x ≻ 255 则 返回 255
    返回 x
}

入口 {
    设 整数 v ← saturate(300)
    显示 v
}
faber convert --to zh-Hant — Traditional Chinese
函式 saturate(整數 x) → 整數 {
    若 x ≺ 0 則 傳回 0
    若 x ≻ 255 則 傳回 255
    傳回 x
}

入口 {
    設為 整數 v ← saturate(300)
    註記 v
}
faber convert --to vi — Vietnamese
hàm saturate(số x) → số {
    nếu x ≺ 0 do_đó trả 0
    nếu x ≻ 255 do_đó trả 255
    trả x
}

bắt_đầu {
    đặt số v ← saturate(300)
    ghi_chú v
}
faber convert --to ar — Arabic
دالة saturate(عدد x) → عدد {
    إذا x ≺ 0 إذن أعد 0
    إذا x ≻ 255 إذن أعد 255
    أعد x
}

بداية {
    ليكن عدد v ← saturate(300)
    اعرض v
}
faber convert --to hi — Hindi
फलन saturate(संख्या x) → संख्या {
    यदि x ≺ 0 अतः लौटाओ 0
    यदि x ≻ 255 अतः लौटाओ 255
    लौटाओ x
}

आरंभ {
    बैठा संख्या v ← saturate(300)
    दिखाओ v
}

That is a complete, compilable package entry point. Reading it left to right:

PieceWhat it is
fndeclares a function
int xthe type comes before the name — always, everywhere
→ intthe return type
if … thena compact single-branch conditional
returnreturn
mainthe program entry point
leta fixed name (mut is the writable one)
←bind this value to that name
printprint

Type before name, always#

This is the single rule that makes the rest of the grammar small:

reader locale
faber convert --to en — English reader surface
main {
    # a declaration
    let int count ← 0
    # another
    let string name ← "Marcus"
    # a generic
    let list<int> scores ← [1, 2, 3]
    # a nullable
    let int ∪ none maybe ← null
    print count, name, scores, maybe
}
faber convert --to la — canonical Faber
incipit {
    # a declaration
    sit numerus count ← 0
    # another
    sit textus name ← "Marcus"
    # a generic
    sit lista<numerus> scores ← [1, 2, 3]
    # a nullable
    sit numerus ∪ nihil maybe ← nulla
    nota count, name, scores, maybe
}
faber convert --to th-TH — Thai
เริ่ม {
    # a declaration
    กำหนด จํานวน count ← 0
    # another
    กำหนด ข้อความ name ← "Marcus"
    # a generic
    กำหนด รายการ<จํานวน> scores ← [1, 2, 3]
    # a nullable
    กำหนด จํานวน ∪ ไม่มี maybe ← ขาดหาย
    บันทึก count, name, scores, maybe
}
faber convert --to zh-Hans — Simplified Chinese
入口 {
    # a declaration
    设 整数 count ← 0
    # another
    设 文本 name ← "Marcus"
    # a generic
    设 列表<整数> scores ← [1, 2, 3]
    # a nullable
    设 整数 ∪ 无 maybe ← 缺失
    显示 count, name, scores, maybe
}
faber convert --to zh-Hant — Traditional Chinese
入口 {
    # a declaration
    設為 整數 count ← 0
    # another
    設為 文字 name ← "Marcus"
    # a generic
    設為 列表<整數> scores ← [1, 2, 3]
    # a nullable
    設為 整數 ∪ 無 maybe ← 缺失
    註記 count, name, scores, maybe
}
faber convert --to vi — Vietnamese
bắt_đầu {
    # a declaration
    đặt số count ← 0
    # another
    đặt văn_bản name ← "Marcus"
    # a generic
    đặt danh_sách<số> scores ← [1, 2, 3]
    # a nullable
    đặt số ∪ hư_không maybe ← vắng
    ghi_chú count, name, scores, maybe
}
faber convert --to ar — Arabic
بداية {
    # a declaration
    ليكن عدد count ← 0
    # another
    ليكن نص name ← "Marcus"
    # a generic
    ليكن قائمة<عدد> scores ← [1, 2, 3]
    # a nullable
    ليكن عدد ∪ لاشيء maybe ← غائب
    اعرض count, name, scores, maybe
}
faber convert --to hi — Hindi
आरंभ {
    # a declaration
    बैठा संख्या count ← 0
    # another
    बैठा पाठ name ← "Marcus"
    # a generic
    बैठा सूची<संख्या> scores ← [1, 2, 3]
    # a nullable
    बैठा संख्या ∪ कुछनहीं maybe ← अभाव
    दिखाओ count, name, scores, maybe
}

There is no name: type form to learn. A declaration is a type followed by a name, whether it is a parameter, a local, or a field. Four binding words say how a name is bound: let is a fixed name, mut is re-pointable and writable, ref is re-pointable and read-only, and const is a compile-time fact set with =. Every one writes its type slot, and _ asks the compiler to infer the type. See Types and values.

Six glyphs, and what they mean#

Faber uses a small fixed set of symbols for structure. They never localize — they are the same in every reader locale, which is what keeps a program recognizable across languages.

GlyphMeaning
←bind a value to a name
→function return type
∪union type, most often T ∪ none for nullable
⇥alternate exit — the error channel
∴closure joint, connecting a signature to its body
≡equality

Two more appear when you convert between types: ∷ for a compile-time ascription and ↦ for a runtime conversion that can fail. Full table in Glyphs and Latin.

The words you write, and the compiler's Latin#

The words in the program above — fn, if, return, let, int — are the spellings an English reader writes; every page on this site teaches the English reader surface. Latin is one reader locale like the rest; the pack files are keyed by Latin spellings, so the grammar document prints its Latin identity rendering beside the others. faber convert --to la prints any program in Latin, and reader locales render the same program in seven other languages. The glyphs and the type-first shape survive every rendering untouched — and identifiers like saturate are never translated.

Where the rest lives#

PageWhat it covers
Types and valuesprimitives, collections, strings, nullability, conversion, bindings
Functions and control flowparameters, returns, branching, loops, generics
Errors and testingthe ⇥ error channel, and inline describe/test/assert suites
Glyphs and Latinthe full glyph table, vocabulary rationale, canonical vs sugar
Reader localeshow one program renders in eight surfaces
Capabilities and framescall dispatch and the host I/O boundary
Tensor computationreductions, reduce via first, grouping, scans, edge policies, kernel, do batch, do device and do eligible