How to develop many-language / multi-platform lib?

554 views Asked by At

Background: I want to develop a component therefore building a class library.

  1. This component should be usable with many higher-order languages such as C, C#, C++, VB, Java, Haskell, Ruby, Erlang, ... I do not want to exclude any users which are not using my development language. Are there principles or tools which supports my project? I searched a little bit and found Haxle for compiling into different languages, but it supports very few of them. I would even develop parallel in all n languages to be supported, but if I want to change or fix something I have to maintain all other n-1 and the code is possibly distributed... This is not what I know about clean code design and maintainability. So how to manage edits on code for the different languages? What is the proper way to solve this? I am surely not the first one which want to build a library for multiple languages.

  2. I want to develop this library (in this case for complexity reduction) in one target language but this time for multiple platforms (Unix, Win, Mac ...). How to manage this? In fact there will be appreciated about 90% of code which is platform independent and 10% which differs for every OS. What is the best way to control the changes in the platform dependent code? (The independent is easy ...) What if I change so things in the part which uses Unix dependent code, then I have to trail all other platform and the code is possibly distributed. I think #IFDEF is no option ...

Are there any experiences or hints?
I would be delighted if there are existing solutions to these problems, which are quite similar.

4

There are 4 answers

0
jcklie On

For 1), I would use an interface that all these languages can use. A common approach is something based on networking/TCP, like protobuffer, REST, SOAP. Many languages support these in their standard libraries, and interfaces designed with that are normally language agnostic.

2
Andrey Chaschev On

There are basically two options - you could develop a network server or you could develop a JVM-based library which could be shared between some of the JVM languages like JRuby or Jython.

Update from @millimoose: you could also develop your library in C and create bindings for all other languages.

0
Diversity On

What you want is only possible if you provide interfaces for every language you want to support. Some kind of wrapper which transforms between the client language and ypu library. This is possible but not practical in most cases for standalone libraries.

Take a look at webservices or or message orientad middleware. In this case your application will be provided within a special container which itself provides interface mechanism e.g. SOAP, XML-RPC to call your application.

0
Richard Weidenweg On
  1. For multi-language: I thought about TCP/middleware/webservices/REST/ which seems to be the recommended proceeding. But I think it's all to much at runtime for only using a library. Also the functionality is a little bit time-critical and so direct procedure calls are more fitting (instead of networking even on localhost). And the library user hasn't to construct an access component only to use the library functions. So I think the way to go seems to be developing the library in a core language which is widely supported (C/C++, ...) and provide wrapper interfaces for the different target languages.

  2. For multi-platform (mono-language): No real answer has been provided also not in my mind. Of course I could simply use Java (what I am familiar with) but what about other languages?

I am surely not the first one having this/these problem(s) ...