Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just wondering how API's can be shared between different Programming languages.

I mean, MS have .Net which uses C# and various other technologies.
I doubt .Net is written for each programming language.
How are structs and classes shared between languages?

Also the same for Unity3D - Javascript shares API's with C# and BOO.

share|improve this question
This topic may be relevant:… – Anderson Green Jul 26 '12 at 17:06
up vote 6 down vote accepted

They're based on the Common Language Infrastructure, or CLI. It's basically a virtual machine where all of these languages compile to the same bytecode and read out assemblies which are in terms of the CLI. This provides an abstraction over the source and target language.

share|improve this answer

There are two basic approaches. One is to compile to virtual machine bytecode, so you basically need a compiler for every targeted language. The other is to create what's called a language "binding" using a native interface. Most languages have a way to link with native code, so you make an implementation in C, for example, then make a wrapper API in the target language that translates the calls and data structures to the C API.

share|improve this answer
There's no reason at all to implement in C- every language can export to a C interface as well as import them. – DeadMG Apr 23 '12 at 10:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.