Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I heard some people program in multiple languages in one project. I can't imagine how the languages interact with each other.

I mean there is no Java method like

myProgram.callCfunction(parameters);

never happens or am I wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
426 views
Welcome To Ask or Share your Answers For Others

1 Answer

Having multiple languages in one project is actually quite common, however the principles behind are not always simple.

In the simple case, different languages are compiled to the same code. For example, C and C++ code typically is compiled into machine assembler or C# and VB.Net is compiled into IL (the language understood by the .NET runtime).

It gets more difficult if the languages/compilers use a differnt type system. There can be many different ways, basic data types such as integer, float and doubles are represented internally, and there is even more ways to represent strings. When passing types around between the different languages it must be sure that both sides interpret the type the same or - if not - the types are correctly mapped. This sort of type mapping is also known as marshalling.

Classic examples of interoperability between different program languages are (mostly from the Windows world):

  • The various languages available for the .NET platfrom. This includes C#, VB.Net, J#, IronRuby, F#, XSLT and many other less popular languages.
  • Native COM components written in C++ or VB can be used with a huge variety of languages: VBScript, VB, all .NET languages, Java
  • Win32 api functions can be called from .NET or VB
  • IPC (inter process communication)
  • Corba, probably the most comprehensive (and most complex) approach
  • Web services and other service-oriented architectures, probably the most modern approach

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...