Universal CLI Metadata - Bridging different worlds


I’ve been thinking of cross-platform and how to bridge the gap between platforms, both managed and unmanaged (native).

CLI Metadata serves its purpose well as a way of describing code, as seen in the case of .NET and Windows Runtime. I think that there should be efforts in pushing it as a standard for interop between languages, and not just those that are targeting managed code like in a CLR (.NET or Mono). I really would like to see standardized and open ways of breaking the boundaries between, for instance, C++ and C# or Visual Basic.NET. Both directions.

My idea (in short): Enable more platforms to use CLI metadata. For instance, in C++, as a complement to header-files.

In practice, it would of course mean that some kind of interop layer is required, for loading the code and metadata from each platform and language, possibly language extensions for C++, and, of course, for generating the metadata.

Any thoughts on this idea? Anyone else who has been thinking of this?

Where do we begin?


WinRT was designed with this problem in mind. It tackles the problem of providing a first-class interop experience between JS, C++, and .NET for Windows. (Of course, WinRT isn’t the cross-plat solution you’re looking for, but it’s an example of a similar problem.) It uses CLI metadata to describe the ABI between components, but that doesn’t mean the ABI itself is built on CLI concepts. The ABI is COM with some modifications. CLI metadata just provides the encoding.

There are a couple lessons from WinRT that I think are worth mentioning.

Finding common ground between .NET, C++, and JS required everyone to restrict certain features. You only can only include the intersection of features in the languages/runtimes from the ABI. For example, you can’t overload operators on a .NET type exposed via WinRT because that would conflict with JavaScript’s behavior. So, each supported language/runtime is going to add some type of restrictions. I think it’s always easier to create a great interop story between n languages vs. between n+1 languages.

Of course, you can add features back into the language if it lacks them. With C++, we introduced C++/CX to make WinRT a 1st-class citizen in the environment. However, any new language feature also creates a barrier to entry. So, there’s a balance here that can be tough to get right.


I am a Linux developer that writes high performance radar applications. Hopefully, the guys on
this post are interested in these comments.

I have been following .NET for years, but I have not incorporated it into our systems.
Please ignore any ignorance I have on this subject. I am considering using .NET instead
of Java based systems for some of our software. I have developed some meta-data facilities
for our C-based radar applications that is similar in concept to the CLI, but it assumes C deserves
it’s own meta-data. It comes with a higher performance, flexible, self-descriptive serialization format that is used between our applications and could be mapped to .NET languages using meta-data.

I felt from the beginning that
The concept of CLI is a good idea, but some languages may warrant their own
meta-data. Languages that are dynamically typed (ie. smalltalk, MATLAB) and
native languages seemed like candidates.
MATLAB being an example of a language that either deserves it’s own meta-data or
some of the concepts in matlab ( flat multi-dimension arrays and vectorized language processing
features) need to be incorporated into the CLI.

              Pure C++ with templates instead of generics being another example.
              Unlike generics, C++ meta data for template instantiated classes would be 
               instantiated at compile time.  In some situations, this can provide efficiency
              C, which still has many customers in the UNIX world, deserves a different set of meta-data.

 I doubt all languages can/should conform to CLI meta data unless it is very flexible and/or has
 some concept of dynamic properties that can be customized for language differences.

Seamlessness and re-use between native, .NET, and other languages is the main difference
**between .NET and Java. Right now, it seems like this deserves a grade of a C **

C++/CLI and C++/cx seemed to have figured out that object references are needed in both worlds,
Neither works cross-platform and this is the key for people to move from Java to .NET.
There are high performance things that still can not be done in Java and C#. It would be nice
if there was a way to make native things available to other .NET languages in a relatively simple

I like STL and C++, but the direction of C++/CLI and C++/cx these languages seems to
suggest that moving away from templates to generics might be the right thing for native languages
or possibly something called C#/native that has C++/cx generics, object references, and
developer written memory allocation schemes instead of garbage collection built into the language.
Possibly keep something like smart pointers from C++.

I guess the primary reason for hanging onto C++ templates is backward compatibility.
Is there enough performance gain in templates vs. generics?

Any comments?

.NET Foundation Website | Blog | Projects | Code of Conduct