-2

Im going to be rewriting a library from .net to something that can be used on different platforms (Mac, Linux, Windows, Android). But i am also hoping that it can be used accross languages (c#, python, java). My initial thought was that c++ would be the best option. But ive never done something like this so im not sure. Is there a standard way this kind of thing is done?

165plo
  • 117

2 Answers2

2

The "lowest common denominator" language is usually C. Because so much historical code was written in C, including operating systems, many other languages have the facility to call C functions.

That doesn't necessarily mean you have to write in C. In C++, functions can be labelled extern "C" and are linked as if they were written in C.

Other languages may also have the ability to export functions as if they were written in C.

Simon B
  • 9,772
0

One bigger product I know which targets different languages is AlgLib. According to their FAQ, they use a programming language named AlgoPascal which is cross-translated to C++, C# or Delphi, and supports also different platforms.

(Disclaimer: I have no connections or relationships to that company, and I cannot tell you anything about the quality of their software.)

Unfortunately, the AlgoPascal translator is not publicly available, but at least it shows a way of how such a cross platform/language library can be build. However, I guess this can only be a sensible way if the lib based on such a common source does not need any other platform- or language specific dependencies like some specific UI framework. A math lib like AlgLib is probably well suited for such an approach.

Doc Brown
  • 218,378