2012-04-15

The scripting story for .NET

Update 2014-08-16:

Promising references:

  1. Make your .NET application support scripting - a practical approach
  2. Scripting for .NET
  3. Script Happens .NET  "Writing applications that host a script engine to enable people to write scripts to customize and extend applications has proven to be very successful" 
  4. Using .NET to make your Application Scriptable  "The Object Model, Host Application & Script Editor"




Finding the scripting story of .NET (and what to actually do in order to implement scripting in a .NET application) turns out to be very hard. Part of the reason may be that scripting is not in vogue anymore, even though it is (still) important for any successful desktop or server application - sooner or later there will be a need to automate things, instead of tediously doing things only through the user interface.
An indication of the sad state of affairs is that Stack Overflowers will completely misunderstand a question of this kind and think it is about choosing a particular scripting language (PowerShell, Iron Python, etc.) when the question is about how to make an application scriptable and define/implement an object model. They will completely fail to understand what an object model is, even if it is explained in the question (often they will not read such an explanation, but immediately associate "scripting" or "scriptable" with "scripting language").
In the 1990s both Apple and Microsoft had focus on scripting. Apple with the Open Scripting Architecture (OSA) and Microsoft with COM. Both had "object models", a term that is often misunderstood by the ignorant or those that think in terms of a programming language for implementing an application. An object model is how an external application or script (internal or external) sees and interact with the application. A class in the object model represent something in the application and roughly represent the same thing as from the user interface.
For instance, in many cases there is a document class that represent a document in the application. The document class will often have a property named "title" (property is also an object model term and is not to be confused with, say, properties in binary components in COM or .NET). Changing the "title" property of a document in an external script will have the side effect of changing the title in the running instance of the application, corresponding to (in this case) of the user doing a Save As operation to save the document in a new file and as a result changing the title of the document.
Microsoft has implemented object models in their Office Suite of applications.
With the advent of .NET there was not much fanfare regarding scripting, but the scripting story for .NET may actually have been summarised by the MSDN Magazine article "Scripting and .NET: Visual Studio for Applications Provides Customized Scripting Facilities for Your .NET Project" (2002-08):
In the past, the Microsoft Active Scripting architecture has allowed you to make your applications extensible. But it came with some drawbacks. You couldn't call into DLLs; you had to use COM interfaces. The scripts were not compiled, so they ran more slowly than they otherwise might, and a number of objects had to ride along with the script. To solve these problems and make extensibility easier to attain, Visual Studio for Applications (VSA) was introduced.
The Microsoft® Active Scripting architecture was a COM-based solution that met many of these criteria, but it wasn't perfect."
The Microsoft .NET platform has a set of classes that offers the benefits of Active Scripting without the drawbacks. This set of classes, named Visual Studio® for Applications (VSA), provides a pluggable IDE and debugger for Visual Basic® .NET."
But that is 10 years ago, so where are we now?
VSA, though, is not even contained in Wikipedia.
Further reading:


To Be Continued...