Version 7 of Thoughts on OO, Natural language, human thinking

Updated 2006-02-17 12:47:39

Why we need to understand Natural language-? . Natural languages evolved. The ability to express something is in a language has high correlation with brain structure. Natural language studies revealed that nearly all languages have a similar structure/grammar but superficial differences. This I remember based on some chomsky's findings but don't have reference off-hand.The evolution of natural language was based on the cognitive limits of human mind.

This insight may help in the design of programming language so that the man-machine interaction does not cause too much cognitive load and the resulting stress.

Most of the interaction of man-computer would fall under imperative statement type. Typically computer languages are classified as imperative and declarative . XML is more of declarative language. The general thought is imperative languages are like procedural languages and object oriented languages are different.

In imperative statements, there are three entities involved. Subject, Object, predicate. "John! close the door".- is an example of an imperative statement. Here "john" is the subject. "door" is the object. "close" is the predicate.

More simply, the subject acts on the object, the predicate denotes the action. Most of the time, the state of the object gets changed as a result of the action. One could see an analogy here. The new Security-enhanced linux gives more fine-grained access control in linux. There, when writing authorisation rules, we talk of 3 entities, subject, object, action. A joe user opens a file for reading. "joe user" is subject , file is object, reading is action.

Most of the times, when we are programming, the subject is the computer. We ask the computer to do xyz things.So instead of saying "computer open this file", "computer close this file", we simply say "open this file" , "close this file" etc.

Th order in which subject,object, predicate appears varies in different natural languages. In English, it is "subject,predicate,object". For example, in the asian language Tamil, it is "subject,object,predicate". But what is important is a language consistently adopts one style.

Now let us see how object orientation comes in natural language. It is instinctive to see that predicates are like verbs and the equivalent in programming languages is a "command" or "procedure". But there is a slight difference. A "procedure" maps to unique sequence of sub-actions/actions. But natural language verbs need not . To understand this. Let us take the statements. "open the door" , "open the letter" , "open the computer". Let us say, we are instructing a robot to do this. Then the robot needs to know the sequence of actions for "open". But the sequence of actions for "open the door" , "open the letter" , "open the computer" are very different. For clarity, we can consider two kinds of verbs, specific verbs and generic verbs. specific verbs map to unique sequence of actions / But generic verbs do not. In this case, let us have these additional verbs, "open_door" , "open_letter", "open_computer" which maps to unique sequence for door,letter,computer. Now it is clear that open is kind of generic verb . Now, the robot to accomplish the task, will map the generic verb to specific verb based on the type of object on which it has to act.

Now a new entity is introduced, object-type. This is what is happening implicitly in our mind, when we speak. We use generic verbs. The subject to carry out his action, determines the object,object-type and maps the generic-verb to the right sequence of action(or specific-verb).

Therefore many new products keeps flooding the world but the verbs in the language do not explode. An imperative language like Tcl natively supports specific verbs with procedures (they map to unique set of sub-actions). If they support generic verbs/commands, then we accomplish the same effect as object-oriented paradigm. To do this, the language needs to support object-types, and a way to determine the object of a command.

To accomplish this see OO libraries

Now most OO languages seems to have gotten it wrong. They all try to simulate smalltalk, which views things differently. Instead of subject acting on object like natural languages. In smalltalk, one passes messages to objects and it acts on them. "door open" - one requests the door to open .Basically objects receives commands and act on them and change their state accordingly. I believe smalltalk way of viewing is inconsistent with our natural viewing. In smalltalk, there is no subject.( Or may be you are the subject)

I feel there is no need for Tcl to emulate Smalltalk notion of objects. Tcl could emulate natural language way of viewing objects . "open door", "open computer" etc. By doing this Tcl can consistently maintain the "predicate-object" sequence rather than "predicate-object" for non-OO and "object-predicate" for OO.