Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
    
This topic may be relevant: programmers.stackexchange.com/questions/157536/… –  Anderson Green Jul 26 '12 at 17:06
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.