# Natural language programming

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Natural_language_programming
> Markdown URL: https://mediated.wiki/source/Natural_language_programming.md
> Source: https://en.wikipedia.org/wiki/Natural_language_programming
> Source revision: 1304292549
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Language-oriented programming paradigm

Not to be confused with [neuro-linguistic programming](/source/Neuro-linguistic_programming), [literate programming](/source/Literate_programming), or [natural language processing](/source/Natural_language_processing).

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages) This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (December 2014) (Learn how and when to remove this message) This article needs to be updated. Please help update this article to reflect recent events or newly available information. (April 2023) (Learn how and when to remove this message)

**Natural language programming** (**NLP**) is an [ontology](/source/Ontology_(information_science))-assisted way of [programming](/source/Programming_language) in terms of [natural language](/source/Natural_language) sentences, e.g. [English](/source/English_language).[1] A structured document with Content, sections and subsections for explanations of sentences forms a NLP document, which is actually a [computer program](/source/Computer_program). Natural language programming is not to be mixed up with natural language interfacing or voice control where a program is first written and then communicated with through natural language using an interface added on. In NLP the functionality of a program is organised only for the definition of the meaning of sentences. For instance, NLP can be used to represent all the knowledge of an autonomous robot. Having done so, its tasks can be scripted by its users so that the robot can execute them autonomously while keeping to prescribed rules of behaviour as determined by the robot's user. Such robots are called *transparent robots* [2] as their reasoning is transparent to users and this develops trust in robots. Natural language use and [natural language user interfaces](/source/Natural_language_user_interface) include [Inform 7](/source/Inform#Inform_7), a natural programming language for making interactive fiction, [Shakespeare](/source/Shakespeare_(programming_language)), an [esoteric](/source/Esoteric_programming_language) natural programming language in the style of the plays of [William Shakespeare](/source/William_Shakespeare), and [Wolfram Alpha](/source/Wolfram_Alpha), a computational knowledge engine, using natural-language input.[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed)*] Some methods for [program synthesis](/source/Program_synthesis) are based on natural-language programming.[3]

## Interpretation

The smallest unit of statement in NLP is a sentence. Each sentence is stated in terms of concepts from the underlying ontology, attributes in that ontology and named objects in [capital letters](/source/Capital_letter). In an NLP text every sentence unambiguously [compiles](/source/Compiler) into a [procedure call](/source/Procedure_call) in the underlying [high-level programming language](/source/High-level_programming_language) such as [MATLAB](/source/MATLAB), [Octave](/source/GNU_Octave), [SciLab](/source/SciLab), [Python](/source/Python_(programming_language)), etc.

Symbolic languages such as [Wolfram Language](/source/Wolfram_Language) are capable of [interpreted](/source/Interpreted_language) processing of queries by sentences. This can allow interactive requests such as that implemented in [Wolfram Alpha](/source/Wolfram_Alpha).[4][5] The difference between these and NLP is that the latter builds up a single program or a library of routines that are programmed through natural language sentences using an ontology that defines the available data structures in a high level programming language.

An example text from an English language natural language program is as follows:

If U_ is 'smc01-control', then do the following. Define surface weights Alpha as "[0.5, 0.5]". Initialise matrix Phi as a 'unit matrix'. Define J as the 'inertia matrix' of Spc01. Compute matrix J2 as the inverse of J. Compute position velocity error Ve and angular velocity error Oe from dynamical state X, guidance reference Xnow. Define the joint sliding surface G2 from the position velocity error Ve and angular velocity error Oe using the surface weights Alpha. Compute the smoothed sign function SG2 from the joint sliding surface G2 with sign threshold 0.01. Compute special dynamical force F from dynamical state X and surface weights Alpha. Compute control torque T and control force U from matrix J2, surface weights Alpha, special dynamical force F, smoothed sign function SG2. Finish conditional actions.

that defines a feedback control scheme using a [sliding mode control](/source/Sliding_mode_control) method.

## Software paradigm

Natural-language programming is a top-down method of writing software. Its stages are as follows:

- Definition of an [ontology](/source/Ontology_(information_science)) – taxonomy – of concepts needed to describe tasks in the topic addressed. Each concept and all their attributes are defined in natural-language words. This ontology will define the data structures the NLP can use in sentences.

- Definition of one or more top-level sentences in terms of concepts from the ontology. These sentences are later used to invoke the most important activities in the topic.

- Defining of each of the top-level sentences in terms of a sequence of sentences.

- Defining each of the lower-level sentences in terms of other sentences or by a simple sentence of the form **Execute code "...".** where ... stands for a code in terms of the associated high-level programming language.

- Repeating the previous step until you have no sentences left undefined. During this process each of sentences can be classified to belong to a section of the document to be produced in HTML or Latex format to form the final natural-language program.

- Testing the meaning of each sentence by executing its code using testing objects.

- Providing a library of procedure calls (in the underlying high-level language) which are needed in the code definitions of some low-level-sentence meanings.

- Providing a title, author data and compiling the sentences into an [HTML](/source/HTML) or [LaTeX](/source/LaTeX) file.

- Publishing the natural-language program as a webpage on the Internet or as a [PDF](/source/PDF) file compiled from the LaTeX document.

## Publication value of natural-language programs and documents

A natural-language program is a precise [formal](/source/Formal_system) description of some procedure that its author created. It is human readable and it can also be read by a suitable software agent. For example, a web page in an NLP format can be read by a software [personal assistant](/source/Personal_assistant) agent to a person and she or he can ask the agent to execute some sentences, i.e. carry out some task or answer a question. There is a *reader agent* available for English interpretation of HTML based NLP documents that a person can run on her [personal computer](/source/Personal_computer) .

## Contribution of natural-language programs to machine knowledge

An ontology class is a natural-language program that is not a [concept](/source/Concept) in the sense as humans use concepts. Concepts in an NLP are examples (samples) of generic human concepts. Each sentence in a natural-language program is either (1) stating a relationship in a world model or (2) carries out an action in the environment or (3) carries out a computational procedure or (4) invokes an answering mechanism in response to a question.

A set of NLP sentences, with associated ontology defined, can also be used as a [pseudo code](/source/Pseudo_code) that does not provide the details in any underlying high level programming language. In such an application the sentences used become high level abstractions (conceptualisations) of computing procedures that are computer language and machine independent.

## AI in natural language programming

Researchers have started to experiment with natural language programming environments that use plain language prompts and then use AI (specifically large language models) to turn natural language into formal code. For example Spatial Pixel [created a natural language programming environment](https://www.youtube.com/watch?v=Uaos-g1TBKU&ab%20channel=spatialpixel) to turn natural language into P5.js code through OpenAI's API. In 2021 OpenAI developed a natural language programming environment for their programming large language model called [Codex](https://openai.com/blog/openai-codex).

## See also

- [Controlled natural language](/source/Controlled_natural_language)

- [Context-free language](/source/Context-free_language)

- [Domain-specific language](/source/Domain-specific_language) (or DSL)

- [End-user programming](/source/End-user_programming)

- [Knowledge representation](/source/Knowledge_representation)

- [Natural-language processing](/source/Natural-language_processing)

- [Source-code generation](/source/Automatic_programming#Source-code_generation)

- [Very high-level programming language](/source/Very_high-level_programming_language)

- [Vibe coding](/source/Vibe_coding), a method of performing natural language programming using a large language model

### Programming languages with English-like syntax

- [AppleScript](/source/AppleScript)

- [Attempto Controlled English](/source/Attempto_Controlled_English)

- [COBOL](/source/COBOL)

- [ClearTalk](/source/ClearTalk)

- [FLOW-MATIC](/source/FLOW-MATIC)

- [HyperTalk](/source/HyperTalk)

- [Inform 7](/source/Inform_7)

- [JOSS](/source/JOSS)

- [SenseTalk](/source/SenseTalk)

- [Software AG](/source/Software_AG)

- [Transcript](/source/Transcript_(programming_language))

- [Structured Query Language](/source/Structured_Query_Language) (or SQL)

- [xTalk](/source/XTalk)

### Programming languages with other natural language-like vocabulary or syntax

- [Non-English-based programming languages](/source/Non-English-based_programming_languages)

## References

1. **[^](#cite_ref-1)** Miller, L. A. (1981). "Natural language programming: Styles, strategies, and contrasts". *IBM Systems Journal*. **20** (2): 184–215. [doi](/source/Doi_(identifier)):[10.1147/sj.202.0184](https://doi.org/10.1147%2Fsj.202.0184).

1. **[^](#cite_ref-2)** Development of reliable and trustworthy robots. "[transparent robots](http://www.transparentrobots.org)" }

1. **[^](#cite_ref-3)** Desai, Aditya, et al. "[Program synthesis using natural language](https://arxiv.org/abs/1509.00413)." Proceedings of the 38th International Conference on Software Engineering. ACM, 2016.

1. **[^](#cite_ref-4)** [Wolfram Alpha – how it works (part 2)](https://www.computerweekly.com/Articles/2009/06/04/236293/wolfram-alpha-how-it-works-part-2.htm) Computer Weekly, 4 June 2009

1. **[^](#cite_ref-5)** [Wolfram Alpha computes answers](https://techcrunch.com/2009/03/08/wolfram-alpha-computes-answers-to-factual-questions-this-is-going-to-be-big/) Tech Crunch, 8 March 2009

## Bibliography

**Books**

- *Natural Language Programming of Agents and Robotic Devices: publishing for agents and humans in sEnglish* by S M Veres, [ISBN](/source/ISBN_(identifier)) [978-0-9558417-0-5](https://en.wikipedia.org/wiki/Special:BookSources/978-0-9558417-0-5), London, June 2008.

- Dijkstra, Edsger W. (1979). ["On the foolishness of "natural language programming""](https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD667.html). *Program Construction*. Lecture Notes in Computer Science. Vol. 69. pp. 51–53. [doi](/source/Doi_(identifier)):[10.1007/bfb0014656](https://doi.org/10.1007%2Fbfb0014656). [ISBN](/source/ISBN_(identifier)) [3-540-09251-X](https://en.wikipedia.org/wiki/Special:BookSources/3-540-09251-X).

- Lieberman, Henry; Liu, Hugo (2006). ["Feasibility Studies for Programming in Natural Language"](https://archive.org/details/enduserdevelopme0000unse/page/459). *End User Development*. Human-Computer Interaction Series. Vol. 9. pp. [459–473](https://archive.org/details/enduserdevelopme0000unse/page/459). [doi](/source/Doi_(identifier)):[10.1007/1-4020-5386-x_20](https://doi.org/10.1007%2F1-4020-5386-x_20). [ISBN](/source/ISBN_(identifier)) [978-1-4020-4220-1](https://en.wikipedia.org/wiki/Special:BookSources/978-1-4020-4220-1).

- Halpern, Mark (1990). "Natural Language and Redundancy in Programming". *Binding Time: Six Studies in Programming Technology & Milieu*. Ablex series in computational science. Intellect Books. [ISBN](/source/ISBN_(identifier)) [9780893916916](https://en.wikipedia.org/wiki/Special:BookSources/9780893916916).

**Papers at conferences**

- Veres, S.M.; Molnar, L. (2010). "Documents for Intelligent Agents in English". *Artificial Intelligence and Applications*. [doi](/source/Doi_(identifier)):[10.2316/p.2010.674-122](https://doi.org/10.2316%2Fp.2010.674-122). [ISBN](/source/ISBN_(identifier)) [978-0-88986-817-5](https://en.wikipedia.org/wiki/Special:BookSources/978-0-88986-817-5).

- *Sliding mode control of autonomous spacecraft.* (half written in sEnglish) by S M Veres an N K Lincoln, *Proc. TAROS’2008, Towards Autonomous Robotic Systems*, Edinburgh, 1–3 September 2008.

- Veres, Sandor M. (2010). "Mission Capable Autonomous Control Systems in the Oceans, in the Air and in Space". *Brain-Inspired Information Technology*. Studies in Computational Intelligence. Vol. 266. pp. 1–10. [doi](/source/Doi_(identifier)):[10.1007/978-3-642-04025-2_1](https://doi.org/10.1007%2F978-3-642-04025-2_1). [ISBN](/source/ISBN_(identifier)) [978-3-642-04024-5](https://en.wikipedia.org/wiki/Special:BookSources/978-3-642-04024-5).

- Pulido-Prieto, Oscar; Juárez-Martínez, Ulises (2017). "A Survey of Naturalistic Programming Technologies". *ACM Computing Surveys*. **50** (5): 1–35. [doi](/source/Doi_(identifier)):[10.1145/3109481](https://doi.org/10.1145%2F3109481). [S2CID](/source/S2CID_(identifier)) [2078759](https://api.semanticscholar.org/CorpusID:2078759).

**[Program synthesis](/source/Program_synthesis) from natural language specifications**

- Raza, Mohammad, Sumit Gulwani, and Natasa Milic-Frayling. "[Compositional Program Synthesis from Natural Language and Examples](http://www.aaai.org/ocs/index.php/IJCAI/IJCAI15/paper/download/11280/10773)." IJCAI. 2015.

- Green, Cordell. "[A Summary of the PSI Program Synthesis System](http://www.ijcai.org/Proceedings/77-1/Papers/067.pdf)." IJCAI. Vol. 5. 1977.

## External links

- [English Script](https://github.com/pannous/english-script/) (dormant since 2016)

- [Plain English Programming](https://OsmosianPlainEnglishProgramming.blog/) Programming language using English sentences in ASCII.

- [SEMPRE](http://www-nlp.stanford.edu/software/sempre/) – a toolkit for training semantic parsers

- [sysbrain.com](http://sysbrain.com) – sEnglish Editor in C++/ROS for robot programming to develop transparent robots.

- [wy-lang.org](https://wy-lang.org) – "Programming Language for the ancient Chinese"

- [How natural should a natural interface be?](https://mitcho.com/blog/projects/how-natural-should-a-natural-interface-be/) – thoughts on how "natural" the [Ubiquity](/source/Ubiquity_(Firefox)) interface (dormant since 2009)

- [Metafor turns English to code](http://www.trnmag.com/Stories/2005/032305/Tool_turns_English_to_code_032305.html) (dormant since 2005)

- [Computer knowledge representation format, system, methods, and applications](https://patents.google.com/patent/US7860815) – US patent re: hyperlinking to .who/what/where/when/how XML files that embed NL

v t e Programming paradigms Imperative Structured Jackson structures Block-structured Modular Non-structured Procedural Programming in the large and in the small Design by contract Invariant-based Nested function Object-oriented Class-based, Prototype-based, Object-based Agent Immutable object Persistent Uniform function call syntax Declarative Functional Recursive Anonymous function (Partial application) Higher-order Purely functional Total Strict GADTs Dependent types Functional logic Point-free style Expression-oriented Applicative, Concatenative Function-level, Value-level Monad Dataflow Flow-based Reactive (Functional reactive) Signals Streams Synchronous Logic Abductive logic Answer set Constraint (Constraint logic) Inductive logic Nondeterministic Ontology Probabilistic logic Query Domain- specific language (DSL) Algebraic modeling Array Automata-based (Action) Command (Spacecraft) Differentiable End-user Grammar-oriented Interface description Language-oriented List comprehension Low-code Modeling Natural language Non-English-based Page description Pipes and filters Probabilistic Quantum Scientific Scripting Set-theoretic Simulation Stack-based System Tactile Templating Transformation (Graph rewriting, Production, Pattern) Visual Concurrent, parallel Actor-based Automatic mutual exclusion Choreographic programming Concurrent logic (Concurrent constraint logic) Concurrent OO Macroprogramming Multitier programming Organic computing Parallel programming models Partitioned global address space Process-oriented Relativistic programming Service-oriented Structured concurrency Metaprogramming Attribute-oriented Automatic (Inductive) Dynamic Extensible Generic Homoiconicity Interactive Macro (Hygienic) Metalinguistic abstraction Multi-stage Program synthesis (Bayesian, by demonstration, by example, vibe coding) Reflective Self-modifying code Symbolic Template Separation of concerns Aspects Components Data-driven Data-oriented Event-driven Features Literate Roles Subjects Comparisons/Lists Comparison (multi-paradigm, object-oriented, functional), List (OO, by type)

---
Adapted from the Wikipedia article [Natural language programming](https://en.wikipedia.org/wiki/Natural_language_programming) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Natural_language_programming?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
