5

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

I mean, MS have .Net which uses VB.net 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.
How?

6

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.

| improve this answer | |
1

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.

| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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