Interface Definition Language (IDL)

IDL is used heavily by such technologies as CORBA and COM. In most cases, the fact that you’re using IDL will be transparent to you; it’s usually integrated into the tools and development platform you work with.

The smallest units that an IDL specification consists of are called lexical elements. In IDL, there are five classes of lexical elements:

connet white space

connet identifiers

connet keywords

connet literals

connet operators and separators

However, it can be handy to have a working knowledge of IDL in case you need to work some up on your own or need to read it to understand how to use someone else’s component. (For example, the W3C’s DOM specification documentation makes extensive use of IDL.) If nothing else, IDL is important for historical perspective, since it could be viewed as paving the way for technologies such as SOAP and WSDL, which make Web services possible

IDL started out as part of the Open Group’s Distributed Computing Environment (DCE). The DCE created a standard way of carrying out remote procedure calls (RPCs), or calling a function across a network. This entails a process called marshalling, which involves gathering the data needed to make that function call to the remote computer.

At that time, most programmers who needed to reuse code simply compiled C header files into an application to statically link the app with the reused code. When the DCE developers began looking for ways to automatically provide the needed marshalling code for RPC, they naturally adapted these header files—which most people were creating anyway—into a format useful for this task. (So, if you’re versed in any of the C-like language families, including Java, C++, and C#, IDL's very C-like syntax will be familiar to you.)

Later, when work began on dynamic component reuse standards, such as CORBA and COM, those developers looked to the work done earlier with RPC for a standard. So, IDL eventually came into widespread use as a way to define object interfaces in a language-neutral manner.

The particular primitive types supported in a flavor of IDL depend somewhat upon the vendor’s implementation of the language. Usually, though, the basic types (int, short, long, char, float, bool) are supported. How these types translate into your chosen programming language is, once again, dependent upon the particular flavor of IDL you are using. However, common sense and a good reference to C variable types will usually carry you through.

One thing I’ve glossed over up until now is attributes. The [in] and [out] keywords preceding the function parameters in the order interface example are attributes, which indicate some special handling of the parameter they decorate. The [in] attribute indicates pass-by-value handling—you won’t be modifying variables decorated by the [in] attribute. The [out] attribute, on the other hand, not only indicates pass-by-reference but also specifies that the value of that parameter will not be passed to the called function. It’s a one-way return parameter.