c++qtweb-applicationsgoogle-nativeclientppapi

Porting c++ code (native client) to browser (Web app)


I have a c++ module written using Qt-creator SDK. I want to port this code to run on any webpage without compromising the source-code to end user. User should be able to see the output of this module on any browser(Chrome, Firefox, Safari, Explorer) without having to install any additional browser plugin. What are the better options available to achieve this. I have googled and found few such options:

  1. Google Native client (NaCl) - But it runs only on Chrome. Is this the future of web applications??
  2. PPAPI - Not sure if it is same as NaCl
  3. NPAPI - almost depricated
  4. Emscripten - It converts c++ to js. So source-code is visible to user.
  5. WebAssembly

Are there any other options to achievce waht I am looking for? If not which one I should pick from the above options!? Many thanks in advance. a


Solution

  • Some clarification:

    1. NaCl will not be supported by browsers other than Chrome. We (Google's NaCl/WebAssembly team) are more focused on WebAssembly for the future.
    2. PPAPI is the set of APIs used by NaCl.
    3. NPAPI: on the way out, and needs a plugin installation anyway.
    4. Emscripten. It does compile C++ to JS, but I would not say that it reveals your source code to the user. It has been significantly transformed through the usual compilation and optimization process, and I would say it's closer to machine code than source code. In addition we are adding WebAssembly support to emscripten, so that with the same source you can produce WebAssembly for those browsers that support it, and asm.js for those that don't yet.
    5. WebAssembly is the future, and will meet all of your criteria, with the caveat that the browser APIs and capabilities available to wasm are the same as those available to JavaScript. So you won't be able to get unlimited access to the user's filesystem, for example. All 4 major browser vendors are implementing webassembly, but it should appear in Chrome and Firefox first, because the release schedules of those browsers are uncoupled from their respective operating systems.

    My suggestion would be to try porting your code with emscripten. You can start that today and use asm.js, and when WebAssembly launches, you can target that with minimal extra effort. In the future there will be other toolchains and languages that support wasm, but today emscripten is really the only ready-to-go option.