HN
Today

Show HN: Toy controlled English to Golang code

Introducing Stated, a novel programming language translating 'controlled English' into deterministic Go code. This project tackles programming ambiguity head-on with strict grammar and typed vocabulary, compiling to human-readable Go that ensures clarity and eliminates hidden behavior—a fascinating dive for language design enthusiasts.

6
Score
2
Comments
#27
Highest Rank
1h
on Front Page
First Seen
Dec 3, 1:00 AM
Last Seen
Dec 3, 1:00 AM

The Lowdown

Stated is a new programming language designed to bridge the gap between human language clarity and programming precision by compiling 'controlled English' directly into deterministic Go code. It champions an approach where every phrase is rigorously checked against a predefined grammar and typed vocabulary, aiming to eradicate the ambiguities often inherent in more flexible natural language interpretations.

  • Controlled Source: Employs an English-shaped syntax enforced by strict programming language rules, ensuring that every accepted phrase has a singular, unambiguous meaning or results in a compiler error. This eliminates arbitrary interpretations and hidden behaviors.
  • Deterministic Output: The compiler pre-resolves all operations, bindings, branches, and data movement before emitting code, guaranteeing stable lowering from the same source. It includes features like checked integer arithmetic and explicit ownership/traversal order.
  • Inspectable Translation: The generated Go code is not a black box; it's a readable artifact that can be reviewed, diffed, and compiled using standard Go tooling. Source locations are preserved, definitions are structurally inlined, and any unsupported semantics are explicitly rejected.
  • Example: Demonstrates translation of a simple "filter and double" program, showcasing how Stated's natural language input yields explicit, functional Go code, including error handling for operations like checkedAdd.

Ultimately, Stated presents an intriguing vision for programming where the source code reads like English but behaves with the unflinching determinism of a machine. It's a bold attempt to bring unprecedented clarity and reliability to software development through a unique language design.