December 19th, 2005, 01:59 AM
.NET Framework IL: What is Language Interoperability?
Q: What is Language Interoperability?
A: Language Interoperability is the ability of code to interact with code that is written using a different programming language. Language Interoperability can help maximize code reuse and, therefore, improve the efficiency of the development process.
Microsoft intermediate language (MSIL) is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the Common Type System, MSIL allows for true cross-language integration. Prior to execution, MSIL is converted to machine code. It is not interpreted.
- Who benefits from Language Interoperability?
Developers use a wide variety of tools and technologies, each of which might support different features and types, Language compilers and tools that target the common language runtime benefit from the runtime's built-in support for language interoperability.
- How is Language Interoperability possible?
The common language runtime provides the necessary foundation for language interoperability by specifying and enforcing a Common Type System and by providing metadata. Because all languages targeting the runtime follow the Common Type System rules for defining and using types, the usage of types is consistent across languages. Metadata enables language interoperability by defining a uniform mechanism for storing and retrieving information about types. Compilers store type information as metadata, and the common language runtime uses this information to provide services during execution; the runtime can manage the execution of multilanguage applications because all type information is stored and retrieved in the same way, regardless of the language the code was written in.
- How does managed code benefit from Language Interoperability?
Managed code benefits from the runtime's support for language interoperability in the following ways:
- Types can inherit implementation from other types, pass objects to another type's methods, and call methods defined on other types, regardless of the language the types are implemented in.
- Debuggers, profilers, or other tools are required to understand only one environment — the Microsoft intermediate language (MSIL) and metadata for the common language runtime — and they can support any programming language that targets the runtime.
- Exception handling is consistent across languages. Your code can throw an exception in one language and that exception can be caught and understood by an object written in another language.
Even though the runtime provides all managed code with support for executing in a multilanguage environment, there is no guarantee that the functionality of the types you create can be fully used by the programming languages that other developers use. This is primarily because each language compiler targeting the runtime uses the type system and metadata to support its own unique set of language features. In cases where you do not know what language the calling code will be written in, you are unlikely to know whether the features your component exposes are accessible to the caller. For example, if your language of choice provides support for unsigned integers, you might design a method with a parameter of type 'UInt32'; but from a language that has no notion of unsigned integers, that method would be unusable.
- How do I ensure that managed code is accessible to any language?
To ensure that your managed code is accessible to developers using any programming language, the .NET Framework provides the Common Language Specification, which describes a fundamental set of language features and defines rules for how those features are used.
Last edited by Andreas Masur; December 22nd, 2005 at 05:35 PM.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!