Dual Syntax Philosophy
Principle
Every construct in Forge has two spellings: a classic form familiar to programmers coming from C, Rust, or JavaScript, and a natural form that reads closer to English. Both forms compile to the exact same AST and execute identically. There is no performance difference, no feature difference, and no hidden cost.
Why Dual Syntax?
Programming languages force a false choice: be accessible or be powerful. Forge rejects this tradeoff.
- Classic syntax serves experienced developers who think in
fn,let, andelse. It is terse and precise. - Natural syntax serves learners, scripters, and domain experts who prefer
define,set, andotherwise. It reduces the cognitive barrier to writing code.
Neither form is “training wheels.” Both are first-class citizens of the language.
Rules
- Both forms are always available. No mode switches, no compiler flags, no feature gates.
- They can be mixed freely. You can use
leton one line andseton the next. A file can usefnfor one function anddefinefor another. - The AST is identical. The parser recognizes both spellings and produces the same node.
let x = 5andset x to 5produce an identicalLetDeclAST node. - Error messages normalize. Runtime errors use the classic form regardless of which syntax the programmer used.
- Formatting preserves choice.
forge fmtdoes not convert between forms. Your stylistic choice is respected.
Example: Mixed Syntax
// Classic variable, natural function
let name = "Alice"
define greet(person) {
say "Hello, " + person
}
// Natural variable, classic function
set age to 30
fn is_adult(a) {
return a >= 18
}
// Both work together seamlessly
if is_adult(age) {
greet(name)
} otherwise {
say "Too young"
}
Design Guideline
When in doubt, use whichever form your team agrees on. For library code shared publicly, classic syntax is conventional. For scripts, tutorials, and learning materials, natural syntax often reads better.