Intentional programming is the name given to a collection of concepts in computer programming which attempt to make the tasks of writing and maintaining computer programs easier. The name refers to the way the systems attempt to capture additional meaning, the programmer's intentions, as opposed to the source code representing those intentions. In doing so the system allows the programmer to more easily follow lengthy code. The term was introduced by Charles Simonyi, the long-time Microsoft employee who led a team in Microsoft Research to develop a working system known as IP.

In "normal" programming systems the program is represented by a series of text files known as source code. The source code is collected together by a program known as an [[interpreter (computing) |interpreter]] or compiler, which creates a running computer program. In a gross sense, the source code captures the intentions of the programmer, but does so at a very low level.

For instance, let's say you wanted to write a program to write out the numbers from 1 to 10. Using a Java-like syntax, such a program could be written like this:

for (int i = 1; i <= 10; i++) {

 System.out.println("the number is " + i);
}

The code above contains one of the more common constructs of most computer languages, the bounded loop, in this case represented by the for construct. The code, when compiled and run, will loop 10 times, incrementing the value of i each time and then printing it out.

However this code does not truly capture the intentions of the programmer, which was, simply, "print the numbers 1 to 10". If you were asked to maintain this code you could likely figure out what it is trying to do, but this is not always the case.

In intentional programming systems the above loop would indeed be represented, at some level, as "print the numbers 1 to 10". The system would then use the intentions to generate source code, likely something very similar to the code above. The key difference is that the source code has lost the semantic level that the intentional programming systems maintain, and in larger programs this can dramatically ease readability.

Key to IP is the concept of identity. In the code above you will see the object i, which in this case is an "index" in a loop. In larger programs the symbol i may be used numerous times, and not always for the same task. For instance, consider this code:

String i = "am canadian";

for (int i = 1; i <= 10; i++) {

 System.out.println(i);
}

System.out.println(i);

This is perfectly valid, if somewhat poorly written, code. The meaning of i varies, at the top and bottom it refers to the String object holding the value "am canadian", while in the loop it refers to the integer value index as before. The identity of "i" varies, a common feature of most programming languages, which define identity based on the file the symbol is in, the "scope", and various other rules. In code that spans several pages, it can become very difficult to tell what symbol refers to what actual object. If you decide to change the name of one, you have to carefully examine the code to see where it is being used.

In an IP system, both of the "i"'s above would be represented by a separate, private, identifier. The IP system would track each, and could tell you at any time what object refers to what definition. If you decided to rename one, say the poorly named String, IP "knows" all of the uses of that identifier and could change them all to "myString" without problems.

IP systems also offer several levels of detail, allowing the programmer to "zoom in" or out. In the example above, the programmer could zoom out to get a level that would say something like:

<>
<>

Thus IP systems are self-documenting to a large degree, allowing the programmer to keep a good high-level picture of the program as a whole.

Physically IP systems consist of a database of symbols and their definitions, and the manipulations on them. The system then generates source code from this database, which is then compiled as normal. The system can generate any sort of source the user desires as long as they have an appropriate translator. In this respect IP systems are a type of code generator.

Microsoft never released the system, but Simonyi has since set up his own company to continue development.

External links:

Intentional Software
- Charles Simonyi's new company
Intentional Programming FAQ
Lutz Roeder, Talks and Papers