I am working on a new version of the following system:

  1. A 'main control' service that runs on Windows Server (C#).
  2. Clients on the following systems, that communicate with the above service via Web Sockets:

    2a. Windows 7 / Windows 10 (WPF C#)

    2b. Android phones (Java)

    2c. iOS phones (Objective C / possibly Swift)

    2d. Embedded PC running Linux (C++, no GUI).

What I've noticed in the past, is that there is a lot of duplicated logic whenever we would add a new feature. It had to be implemented across all 3 platforms, and it just doesn't seem right. What is the right way of dealing with that situation?

I am not interested in solutions like Xamarin, since we'd like to maintain native look/functionality for each platform. So clearly the GUI layer will have to be coded separately on each platform. I am more concerned with the business/model logic that will inadvertently end up being duplicated on each system.

Of course we can push some of it right to the Server machine, making the clients as thin as possible, but there are still cases where I would like to have a library that I just write/test once, and then simply compile/deploy to each client platform.

Is something like that even possible? Am I missing a better approach?


1 Answer 1


You can move the common client code into C/C++ libraries as your "least common denominator" platform. Tools like SWIG can be used to help automate bridging.

Alternatively, you can embed a common interpreter in each client for some language available on all platforms (e.g Python, Lua, etc.) and put your common code in it.

(These are not mutually exclusive, of course - you could employ both methods.)

  • 1
    For reference, this is the approach that is taken by Chrome, which runs on all of the platforms listed in the question.
    – Marq
    Commented Jan 31, 2016 at 14:24
  • @MarkCogan Yes - you are referring to the C/C++ approach, and not the interpreter, I assume. The core Chromium code is C with C++ wrappers for outer code (autogenerated), but I haven't seen Java/WPF/Obj-C++ layers in that codebase or toolchain - is it really doing that as well?
    – holtavolt
    Commented Jan 31, 2016 at 14:29
  • I'm pretty sure Chromium is C++ all the way down.
    – Marq
    Commented Jan 31, 2016 at 14:34
  • Yes - browsed the Chromium site and codebase, and think you're correct re. Chrome being all C++. I was conflating this with the CEF (Chromium Embedded Framework), which has some C/C++ wrapping layers. For those interested in researching more: chromium.org/developers
    – holtavolt
    Commented Jan 31, 2016 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.