Click here to Skip to main content
13,301,619 members (66,773 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 13 Oct 2011

Multi Language Programming: Object as Medium

, 13 Oct 2011
Rate this:
Please Sign up or sign in to vote.
Using objects as a medium and developing a common object environment and interface libraries or middle-ware is one way to simplify multi-language programming.

Software developers develop applications with multiple languages, for efficiency, simplicity, saving marketing time, or for reusing libraries developed with other programming languages. There are many methods that can be used for this , for example, if you want an application mixed with Java, you may use the JNI interface; mixed with Python, you may use the cpython interface; mixed with C#, you may use the CLR, and so on. Developers can also use libraries or middlewares to simplify programming, such as use ironPython for C# when interacting with Python, jcob/webservice for Java/PHP calling C#, Jpype for python calling Java, luajava for lua calling Java, lupa for Python calling lua, luainterface for lua calling C#, phplua for PHP calling lua, and so on. See the figure below:

It can be seen from the above figure, libraries or middle-wares for multi-language programming are very chaotic. Development will be complicated if three or more different languages are used in one application. Is there a more general way for multi-language programming?

For any language, no matter C++/C, Java, Python, or C#, the concept that is common is the object: Python object, Java object, C/C++ object, C# object, etc. These objects locate within the scope of a special language, and are opaque to other languages. Thus, if the application needs to access objects defined in other languages, it can only do that through the low-layer of interface calls presented by the corresponding language.

No matter what language, objects have similar features. They have attributes, functions, may trigger events, and process events. For objects, their behavior is the same no matter what language we choose to describe them. If we construct an environment to manage the objects which will be accessed by other languages, and a special programming language is used to describe these objects, we might find a common and simple method to realize multi-language programming. As shown below:

A common object environment manages interface objects. It can present a common object interface for different languages in which functions and access modes are similar and the difference for languages is only in the syntax.

The common object interface presents methods to define object attributes, functions, and events, methods to create and destroy objects, and methods to call an object’s functions and trigger their events. For different languages, the common object interface is mapped with a specific syntax of the language. This is further illustrated as follows:

Using the common object environment and interface is a common and simplified method for multi-language programming. It has the following advantages:

  1. For the programmer, the common object interface for different languages is very easy to master, the difference is only the syntax.
  2. The complexity does not increase with the number of languages.
  3. Components or libraries developed in one language can be called by other languages. The programmer need only create the interface objects instead of rewriting for different languages.
  4. Applications or products can use a number of languages freely.
  5. A common languages environment can present the most common functions of languages, such as libraries, distributed functions, etc.


Using objects as a medium and developing a common object environment and interface libraries or middle-ware is one way to simplify multi-language programming.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

China China
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 13 Oct 2011
Article Copyright 2011 by li9705
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid