Natural language programming instructions, or intentional programming

    This topic is likely to cause a rather negative reaction due to the fact that most developers are its opponents. This is because intentional programming, compared to classical, has significant drawbacks:
    • weak determinism of natural language instructions
    • a significant length of each instruction, which forces you to enter a rather voluminous code
    • the code looks consistent, which may make it difficult to understand and search
    • reduced program speed by analyzing more characters

    But he has significant advantages:
    • all instructions are intuitive to a person, there is no need for a preliminary study of a new language
    • each instruction clearly reflects the intention of the developer who wrote it
    • the natural ability of a natural language to generalize and create new levels of abstraction (both for objects and for methods of manipulating them) based on existing
    • the process of programming in a natural language is possible not only in a purely imperative form, but also in the form of communication

    Of greatest interest to me is the last point, which allows you to change the behavior of a mechanized system on the fly in the communication process. In this case, the language can act both as a means for manipulating data and as a means for exchanging data. This gives intentional programming the ability to realize its potential in niche areas, such as robotics, when the mechanism can receive a description of behavioral algorithms, as well as any other information through a single communication interface, using a single language.

    In fact, in the headline I was deceiving and it will be all the same about a planned language, but based on the elements of a natural language, and which, in the process of development, has the ability to transform almost into a natural one.

    As for the shortcomings of programming in a natural language, the problem of speed is solved to some extent by preprocessing during loading the instruction into memory, so that when it is called again, it will exclude resource-intensive procedures. The problem of instruction length when typing is solved by smart predictive input in the development environment. The problem of uniformity of the source code is solved by colorizing the instructions. For example, like this:


    To solve the problem of weak determinism of the natural language, it is proposed to introduce a rule for constructing a program instruction based on the so-called valencies and triads based on them. The idea is to build all the instructions from the triads - building blocks, which consist of three components:


    The triad consists of two concepts, interconnected by a semantic connective. Such a semantic connective in linguistics is called valency. The concepts can be tangible and intangible objects, actions, properties, numerical values, etc. As an example, consider the artistic phrase: "He put the book there." In this construction, the verb “put” has three filled valencies: who put what put, where they put. Valencies potentially allow the formation of semantic connections of one concept with others. So, in this example, the concept of "put" forms a connection with the concept of "He" through the valency of "who", with the concept of "book", through the valency of "what", with the concept of "there" through the valency of "where." The concept of “He” is called the actor (who performs the action), and the concept of “book” is called the actant (over which the action is performed).

    Different verbs have a different number of open valencies, usually from 1 to 7. For example, the verb “move” as compared to the verb “put” has an additional valency “from”. Also, valencies can be not only in the verb, but also in other concepts. For example, in the sentence "He put a big book there." the concept of “book” filled valency “what” thanks to the concept of “large”.

    Correct determination of potential (unfilled) valencies is not always easy to implement, especially if the construction of the sentence is quite complicated. Therefore, at the initial stage, it would be nice to indicate all valencies in the instructions. Based on an example, this would look like this:
    Он ?кто положил (?что книгу, ?куда туда).

    This sentence is a frame - it contains one verb, therefore it is the verb that is the origin, from which valencies extend in both directions.

    But the introduction of obligatory valencies creates a problem which consists in the fact that the sentence has a linear form, and the valence structure of the sentence has the form of a branched tree with one root - a verb. To solve this problem, parentheses are introduced into the proposal. Since without brackets the valency “where” would connect the concept of “there” with the concept of “book”, and not with the concept of “put”.

    This can be explained in more detail with another, more technical example. Suppose there is a variable, Variable1, to which you need to assign the value "1". In natural language, such an instruction would look like this:
    присвоить переменной Переменная1 значение 1.


    In a language with explicitly indicated valencies, this instruction will look like this: In this example, the concept of the “assign” action has two valencies explicitly assigned: assign what and assign what. The brackets here are necessary in order to be able to define a tree structure in a linear sentence:
    присвоить (?чему Переменная1, ?что 1).



    to assign
             ? what
                  Variable1
             ?what
                  1
    

    The transfer of information using such constructions with an explicit indication of semantic relationships is also possible. For example, a sentence: can be decomposed as follows: We get a tree structure:
    Земля это планета солнечной системы.


    Земля ?что есть ?что планета ?чего системы ?какой солнечной.



    there is
        ?what
            Land
        ?what
            planet
                   what?
                        the system
                               what
                                     solar
    

    Another example: you can transform it like this: We get a tree structure:
    Атом водорода имеет один электрон.


    водорода ?чего атом ?что имеет (?что электрон, ?сколько 1).



    It has
         ?what
             atom
                 what?
                      hydrogen
         ?what
             electron
         ?how much
                 1
    

    It turns out something like a “human” assembler, which has the communicative and intuitive visual functions of a natural language (as it uses all the same words from a natural language) and is at the same time simple to implement. For a person, to perform such preliminary transformations of labor is not. In the future, it will be possible to try to make a software preprocessing of a truly natural language with automatic detection of all valencies. The proposed method introduces some additional restrictions that are not yet fully understood, but it also makes the recording of instructions more formal.

    Also popular now: