Click here to Skip to main content
15,884,629 members
Articles / All Topics

Multi Language Programming: Object as Medium

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 Oct 2011CPOL3 min read 14.4K   4  
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:

Image 1

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:

Image 2

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:

Image 3

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.

Conclusion

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 was originally posted at http://blog.yahoo.com/srplab/articles/54800

License

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


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --