5

I am trying to write a library which can be used from multiple programming languages, for example:

  • CLR languages (C#, F#..)
  • JVM languages (Java, Kotlin, Scala..)
  • Native languages (C/C++, Rust, Objective-C, Swift..)
  • JavaScript/TypeScript

The basic way I know to achieve this is to write it in C/C++ and maintain my own bindings for each language, or to maintain separate copies of the library for each language (like Reactive extensions does). Either way, that's O(n) work for n languages.

Is there a language or tool that I can use to write the library in one language and have bindings automatically generated for other languages?

Jesse
  • 6,725
  • 5
  • 40
  • 45
  • 1
    Did you consider using webservices? – uday Feb 07 '18 at 11:58
  • Of course you have to write some accessor that is able to deal with the input and output for your program. Having said this, that accessor is different for every language. – MakePeaceGreatAgain Feb 07 '18 at 11:59
  • Look at SWIG. This is is goal. Keep in mind, however. That SWIG interfaces are never as good as a native library. – Jonathon Reinhart Feb 07 '18 at 12:01
  • If it is not heavy usage, it might be easier, to write it as a separate executable, or script, and then call it - as a system call - from the other languages. Defined the API as the command line args – developer Feb 07 '18 at 12:03

0 Answers0