AI Glossary / Natural language and speech / Beginner
Natural language programming
Definition
Natural language programming is the use of human-language descriptions to specify computational behavior that a system turns into an executable program or procedure. Approaches range from controlled, English-like programming languages to systems that generate conventional code from freer descriptions. The central goal is to express program intent through language that people can readily describe and inspect.
What it means
The programmer still needs to specify what the computation should do. Natural wording changes how the specification is expressed; it does not eliminate decisions about inputs, conditions, repetition, outputs, and exceptional cases.
A controlled language restricts permitted constructions so that they have defined computational interpretations. A language-model-based approach may accept more varied wording but must infer details that a formal notation might require explicitly.
This differs from merely issuing a request to an existing application's natural-language interface. Programming defines or constructs behavior, whereas an interface can simply invoke behavior already implemented. The boundary can overlap when an interface lets users build reusable procedures.
How it works
Describe the intended behavior and the available data or operations. State relevant conditions, units, output requirements, and how exceptional inputs should be handled.
The system interprets the description. Depending on the approach, it may parse a controlled language, construct an intermediate representation, or propose code in a conventional programming language.
Inspect the resulting behavior or representation. Resolve ambiguous instructions and check that inferred details match the intended task.
Run suitable examples and tests in an appropriate environment. Review outputs, control flow, and boundary cases, then revise the specification or implementation. Being executable is only one requirement: a program can run without implementing the behavior the author intended.
Three practical examples
- An author defines objects and rules for interactive fiction in a language with English-like syntax, as exemplified by Inform.
- A data worker describes a repeatable transformation and reviews a generated program before using it on a larger dataset.
- A research system converts a novice's description and a set of available application operations into a program whose control flow can be evaluated.
Think of it this way
Think of giving a precise recipe to an assistant who translates it into a sequence of kitchen operations. Familiar wording can make the plan easier to express, but missing quantities and unclear conditions still matter.
The analogy has limits: software executes the interpretation it receives, and generated code may contain errors that sound explanations do not reveal. Natural phrasing does not replace checking the resulting procedure.
Worked example
Use this original specification: “For each item, multiply quantity by unit price. Add these amounts. If the total is strictly greater than 100, apply a 10% discount to the total; otherwise leave it unchanged.”
For two items with quantity 2 at price 30 and quantity 1 at price 50, the amounts are 60 and 50. Their total is 110, so the discounted result is 110 × 0.9 = 99.
At exactly 100, the result must remain 100 because the condition says strictly greater than, not greater than or equal to. At 80, the result remains 80.
These three cases test the high, boundary, and low paths. The specification still needs additional decisions for a real application, such as invalid quantities and rounding. This is a behavioral illustration, not code claimed to have been executed in a particular product.
Illustrative case study
In a fictional project, Maple Automation turns an analyst's description into a small report-preparation routine. The first version interprets “above the threshold” as including equality and produces the wrong result for a boundary record.
The analyst adds explicit boundary examples and revises the wording. The team checks that the generated condition and the expected results agree, then records both the specification and the tested implementation.
The lesson is that plain language can make intent accessible while still requiring precise interpretation. This invented project claims no measured productivity benefit or fully autonomous development result.
Common misconceptions and mistakes
Do not equate natural language programming with unrestricted understanding of any instruction. Every system has constraints, assumptions, and unsupported cases.
Do not confuse it with natural language processing, the broader field, or with neuro-linguistic programming.
Do not assume that code which runs is correct. It can implement the wrong condition, omit a required branch, or misinterpret data.
Do not treat an explanation of generated code as proof that the explanation matches the implementation.
Finally, distinguish a one-off command from a reusable program definition when describing what a system actually enables.
Business use
For a business, the approach can make simple automation specifications easier to discuss between domain specialists and developers. It can also expose assumptions when the system presents an interpretable plan or implementation.
Choose tasks with clear inputs and checkable outputs. Keep examples of normal behavior, boundary conditions, and invalid inputs alongside the description.
Assess the full workflow, including revision, verification, and maintenance. The relevant outcome is dependable automation that people can understand and update, not simply a reduction in the number of conventional code statements they type.
People also ask
Does natural language programming require a large language model?
No. Controlled natural-language systems can use explicitly defined grammar and interpretation rules.
Can a non-programmer use it?
Potentially, but the person still needs enough task knowledge to specify the intended behavior and recognize incorrect results. Ease of expression does not guarantee correctness.
Is an English-like language unrestricted English?
No. It may accept only a defined subset of constructions, even when valid programs resemble ordinary prose.
Check your understanding
Should the toy program discount an input total of exactly 100?
Answer: No. The condition is strictly greater than 100. Discounting equality would implement a different rule, so the boundary test is necessary even if the program produces 99 for the 110 example.
Related terms
- Controlled natural language
- Software testing
- Program synthesis
- Natural-language interface
- Specification
- Control flow
Learn next
Describe a small computation in ordinary language and write expected results for normal, boundary, and invalid inputs. Identify every assumption the description leaves open.
Then compare a controlled-language approach with code generation from freer text. Ask where each system obtains its interpretation rules and how you would verify that its executable behavior matches the specification.
More in Natural language and speech
- Nasal sound - A nasal sound is a speech sound produced with airflow through the nasal cavity because the velum, or soft palate, is lowered.
- Nats - Nats are units of information obtained when information-theoretic quantities use natural logarithms, whose base is e.
- Natural language - A natural language is a human language that develops through use within a community, such as Arabic, English, or American Sign Language.
- Natural-language user interface - A natural-language user interface lets people interact with software using human-language expressions, such as typed questions or spoken requests.
- NER model - The NER model is a framework for assessing the accuracy of live subtitles, particularly subtitles produced through respeaking.
- Neural machine translation - Neural machine translation, or NMT, uses neural networks to produce a translation from one human language into another.
Sources
Inform, official documentation overview of its natural-language-based programming approach: https://ganelson.github.io/inform-website/doc/ Mordechai and colleagues, NoviCode: Generating Programs from Natural Language Utterances by Novices, original research abstract: https://aclanthology.org/2024.tacl-1.73/ The discount procedure is an original arithmetic and boundary-condition illustration, not a tested application or financial recommendation. Independent review: creator-maintained Inform documentation and the original NoviCode abstract consulted.
Previous: Natural language processing Next: Natural language understanding