Natural Language Programming

Much exploration has been done recently to find an alternative way of programming besides traditional programming languages. With the current app boom, an alternative programming method can be useful for those wanting to write a mobile app, but not willing to learn a programming language. A common approach is programming using a visual interface. Pure data is a good example of such a programming method. Although domain specific (writing programs to synthesize and process sound), both its success and the success of its commercial fork (Max MSP) shows that such a method is indeed verry usable. There has also been some development of visual apps on mobile platforms allowing one to program on the device itself. One alternative solution that is largely unexplored is the use of natural language programming.

Natural language programming is the use of natural sentences to write programs. Sentences are processed with rules to derive simpler sentences, until code in a procedural language is produced. This Menes that the sentences does have to conform to a specific structure, but it is easier to learn and understand than traditional coding languages. The program’s source code can also be understood by someone with no coding experience what soever, meaning that it is self-documenting. Another advantage of natural language programming specific to mobile platforms is that programs can be written using speech recognition. It is verry difficult to program in a traditional programming language using speech recognition, as there are so much punctuation involved, more often than not used in an unusual way. NLPs on the other hand, makes use of punctuation in the way it is found in normal text.

One of the most popular NLPs, which I am familiar with, is called Inform7. It was designed for a verry specific kind of program called a text adventure (although the modern ones often contain supplementary graphics as well). Never the less, the concepts of the language are clearly not confined to this domain alone. The following is an example of an Inform7 program:

The work area is a room. The description is “This is the area where you are supposed to work, although naturally a lot of Facebook browsing is happening here.”.
The kitchen is east of the work area. The description is “This kitchen has been stocked for your use, complete with coffee machine.”.
[This is a comment. Quoted text will automatically be taken as the description of the last room.]
The lounge area is north of the kitchen. “This is where numerous demos has been held.”
The upper area is up from the kitchen. “This is also supposed to be a work area.”
A table is a supporter in the upper area. It is fixed in place.
A pair of headphones are things on the table. The description is “The logo says Logitech.”
Instead of taking the pair of headphones:
Say “No, rather not. Remember last time?”.
This source is largely self explanatory. It references several kinds (classes), including room, supporter and thing. It also defines relations between these objects — the kitchen is east of the work area, while the headphones are on the table. The part at the end is called an action definition. Whenever the action of the player is “taking the headphones”, the part after the colon will be executed. In this case it will print a short message.

It is easy to envision a similar language for more general purpose programming, e.g. designing mobile apps. The kinds might be objects usually available to apps, like graphical components, databases, or files. The relations specific to the kind, e.g. the layout of graphical controls. The actions might be actions performed by the user like tapping, or caused by the system. A possible example might be:

The main window is an activity.
The top panel is a panel in the activity.
The bottom panel is a panel in the activity. It is below the top panel.
The play button is a button on the top panel.
The stop button is a button on the top panel. It is right of the play button.
The status text is a label. It is on the bottom panel. The text is “stopped”.
Instead of pushing the play button:
Now the text of the status text is “playing”.

No comments yet.

Leave a comment

Leave a Reply