Advantages of natural language programming


Computer languages evolve already many decades but still have not approached (put aside surpassed) human language. Comparison is rather interesting. Many programming languages were based on English but took only a minor part of it. Instead of implementing human language in full, they added various advanced features such as mathematics. Also they could exactly specify functions which are rather indefinite in human languages. For example cycles or logic (and, or, not). As a result, they hugely surpass human language in some respects and lag in others. Say, classical Object Oriented Programming requires that you create an object from some class first, only then allow you to manipulate this object. In contrast, human language freely operates with both objects and classes. English articles were introduced specifically so as to distinguish them.

Some think that natural language programming is using raw human language. "Computer will understand you even if you don't know what you want." This is nonsense. For a language to be machine-understandable, it should be completely defined. Received human languages don't possess this feature and this is just one defect out of many. Machine-usable natural language is a more or less close subset of human language. It is preferable to implement only the most important features, that is the language core. Also various defects of human language must be cleaned even if the result is a bit unnatural. When humans start using this with computers, it will quickly become a new norm in everyday life. Thus, the first advantage is that natural language may be used both with machines and for communication between humans. This lays the foundation for the seamless integration of advanced computers into human society.

My implementation of natural language programming in the language of NB is as follows. First of all, the existing English grammar is quite workable. Just parse it, add semantics and pragmatics, and you will get a useful programming language. The system recognizes 4 types of sentences: statements (facts), questions, orders, and rules. The first and last are stored in the knowledge base. The rest are processed accordingly. The language supports both procedural and declarative programming. For the first, just write several orders one after another. The second makes use of the internal inference engine. This is the second advantage. Computer languages were initially specialized for a particular domain. Natural language is all in one.

Meanwhile this is not enough. To create a practically useful language, it is necessary to add some artificial elements. I have added both Prolog and some procedural operators such as cycle. When a program communicates with a user, natural language is employed, but for internal technical purposes 2 elements were added: commands and functions. The first are used to manipulate natural sentences:

forget: box stands on floor.

How to add functionality to natural syntax? You use rules so as to dissect a task into subtasks:


order if order1; order2; order3.


Each of them may be dissected in turn. When the inference engine processes these rules, it creates a tree of solution. To generate some actions, you need to terminate the branches with executable functions:


order32 if #draw("ellipse", "white", 50, 50, 100, 100).


The internal implementation of the language uses comparison on coincidence plus some flexibility characteristic for natural language. That is, the system returns literal answers to questions. If you need indirect meaning and similar advanced functions, you can implement them yourself using rules and automatic reasoning.

The third advantage of natural language is that it produces human-like performance. Our computers were designed on different principles, but they are universal so can implement functions normally performed by live neural nets. Using natural language, we can call these functions in any implementation.


Copyright (c) I. Volkov, February 4, 2020