Components or libraries provide some functions. Other modules may access these functions through their interface. In some cases, the interface
functions may be simple. The caller constructs input arguments, calls the function, and gets the return value. These type interfaces are easy to define and have no more restrictions. But in other cases, interface
functions may be more complicated. Let’s use an example to explain this in detail.
Suppose that there is a C/C++ component. It provides a function to draw and fill a circle into memory pixel buffer. If the component uses a simple interface, it should take parameters as input arguments, such as line type, color, width, fill color, fill pattern, fill bitmap, etc. We define an interface
object that contains this function in a common object environment. The function may be called by other languages, for example, Java.

In this case, there are some disadvantages. First, the interface function may have many input arguments, and for each call, these arguments should be input although their values do not change. Second, if a new parameter is added, all related functions must be changed. This will increase the burden of software maintenance.
In general, we often define two other objects: pen and brush objects. The draw
function takes pen
and brush
objects as input arguments. The pen
object has attributes color
, type
, and width
, and the brush
object has attributes color
, pattern
, image
, etc. We also define an interface
object that contains the draw
function in the common object environment. As a result, there are three objects defined by C/C++ in the environment, which are pen
, brush
, and the object containing the draw
function. For other languages using the function, for example Java, it should create instances of the three interface class objects. And the instances can be accessed by C/C++ and Java language based on the support of the environment.

In this case, the function call is more complicated. The caller needs to create instances of objects defined in C/C++. The instances can be accessed by the two languages. They are used as input arguments of the draw
function. Without the support of common object environment, it is difficult to realize it in this way, especially to support the call from applications programmed with multiple different languages.
It is clear that the C/C++ service can be called by any other language. Is it easy and concise? You can compare it with traditional methods using the JNI interface.