开发者

creating a library in a single language with interfaces to everything else

Our business currently revolves around the development of a library, which can be used in a wide spectrum of industries (desktop, mobile, web and embedded). At the moment we only have customers within the desktop and web world and we already see that we are basically having to duplicate our code across multiple languages (c#, java and c++). How is this typically managed in other companies, 开发者_JAVA技巧do we really have to settle for having our middleware written in multiple languages to meet very different industries.

We have tried c# interop along with with java jni but the results where not as good as we had expected and it didn't seem like a good and professional solution.

Anyone have any ideas how we could keep the core in a single language but develop interfaces in different languages allowing for the different industries.


I have not a lot of ideas when it comes to industry, but I guess that the problem is similar to other not-so-strict scenarios. It is unclear also what do you mean by "middleware". Anyway, I would souggest you to not duplicate code and effectively have, if needed, multiple interfaces to the other languages.

In an ideal scenario, it would be very convenient to have one isolated process with your application logic, written in whatever language you feel more comfortable, and have this process to communicate using some inter-process-communication mechanisms (e.g., pipes, sockets, shared memory, files) with thin client-libraries which could be use by the clients in the other languages. That way, you are forced to create a very clean communication/usage protocol and to have some separation of concerns (because all the communication has to be serialized); you gain in robustness (a fatal error in your application process or in your client does not necessarily means a crash in the other one) and you don't have to use ffi mechanisms, but rather things like sockets and pipes. Even more, if you decide to publish your comm. protocol, then third party developers can create wrappers in their exotic predilect language without need of direct linking/importing to your development components.

This kind of paradigm has been in use with success over the years in the unix world and softwares like Mathematica . In a similar move, the developers of java have made the java plugin to work out-of-browser, in a separated process, to reduce interop complexity.


Ah, I forgot, maybe you may use this: ICE (http://www.zeroc.com/overview.html). It is probably the lighter interop layer that you can use to communicate in a clean way java, c++, c#, python and a few others. They even have some embedding solution...


Pick common denominator standards: REST or SOAP/XML over HTTP can be consumed by a lot of languages, including both Java and C#.

You'll be saddled with heavyweight WS-* standards and lots of network latency, but if interoperability is your goal this is one way to achieve it.


Might take a look at the Haxe language. It "compiles" to a dozen other languages.

https://haxe.org/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜