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?

gnat
20.5k29 gold badges117 silver badges308 bronze badges
asked Apr 22, 2012 at 18:44
1

2 Answers 2

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.

answered Apr 22, 2012 at 18:49
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.

answered Apr 22, 2012 at 22:28
1
  • There's no reason at all to implement in C- every language can export to a C interface as well as import them. Commented Apr 23, 2012 at 10:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.