Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Cross-Language Interoperability

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    Comment on it

    Language interoperability is the ability of code to interact with code that is written by using a different programming language. Language interoperability can help maximize code reuse and improve the efficiency of the development process.Because developers use a wide variety of tools and technologies, each of which might support different features and types, it has historically been difficult to ensure language interoperability. However, language compilers and tools that target the common language runtime benefit from the runtime's built-in support for language interoperability.

    It is defined as the sharing of components of one language with other languages.

    Example:

    • A routine written in a language L1 may call another routine written in a different language L2.
    • A module in L1 may declare a variable whose type is a class declared in L2, and then call the corresponding L2 routines on that variable.
    • If both languages are object oriented, a class in L1 can inherit from a class in L2. Exceptions triggered by a routine written in L1 and not handled on the L1 side will be passed to the caller, whichif written in L2will process it using L2's own exception-handling mechanism.

    In most programming environments, code written in one language can communicate with code written in another language only if established binary standards are followed. For example, you could write a COM DLL in C++, create an instance of it, and call methods on it from a component written in Visual Basic. Your ability to do so is possible, however, only because both pieces of code follow the COM binary standard. The downside of this type of interaction is that these two separate components can't share functionality via simple inheritance. With the .NET Framework, you can write classes in two different languages that fully interact with each other. For instance, an object written in C# can call methods and properties on an object written in VB.NET. That same C# object could even inherit functionality directly from the VB.NET object.

    .NET supports cross language interoperability, but it does not mean that every program written in one language can be used by other language.For cross language interoperability a language must enable cross language specification. 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.

    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 we 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 we do not know which language the calling code will be written in, we are unlikely to know whether the features our component exposes are accessible to the caller. For example, if our language of choice provides support for unsigned integers, we might design a method with a parameter of type UInt32. However that method would be unusable from a language that has no notion of unsigned integers. To ensure that our managed code is accessible to developers who are using other programming languages, the .NET Framework provides the Common Language Specification (CLS), which describes a fundamental set of language features and defines rules for how those features are used. To fully interact with other objects regardless of the language they were implemented in, objects must expose to callers only those features that are common to all the languages they must interoperate with. For this reason, the Common Language Specification (CLS), which is a set of basic language features needed by many applications, has been defined. The CLS rules define a subset of the Common Type System; that is, all the rules that apply to the common type system apply to the CLS, except where stricter rules are defined in the CLS. The CLS helps enhance and ensure language interoperability by defining a set of features that developers can rely on to be available in a wide variety of languages. The CLS also establishes requirements for CLS compliance; these help you determine whether your managed code conforms to the CLS and to what extent a given tool supports the development of managed code that uses CLS features.

    If our component uses only CLS features in the API that it exposes to other code (including derived classes), the component is guaranteed to be accessible from any programming language that supports the CLS. Components that adhere to the CLS rules and use only the features included in the CLS are said to be CLS-compliant components.

    Limitations

    • Types are limited to value types and interface types
    • Metadata generation is often optional
    • Proxy objects generally allow for cross language method calls only
    .Net-Cross-Language Interoperability CLS

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: