1

Often people talk about cross-platform compatibility, but is it possible to write such "universal code" that would work both in browser, in desktop, on opengl, on webgl, and on html5 canvas-object? I'm thinking about writing a c-to-javascript compiler that would allow running desktop applications in browser. This utility would parse c/c++-code and generate javascript-code, and somehow replace all opengl-calls with webgl-calls. Something similar to Emscripten, but without assembly-like code (functions and statements would be converted one to one). Of course there will be some severe limitation on such c++ code. It will not support templates, dynamic polymorphism, etc. Also all libraries would have to be more or less substituted with javascript-implementations, so for example std-namespace will have to have javascript counterpart.

Do you think this is worth the trouble? Or should we just optimize better desktop-application download and execution, and except users to press "download" on our site? Google earth seems to be pretty popular even though it has a mandatory installation-step.

2 Answers 2

1

Unless writing C++ code is a requirement, maybe the Monkey programming language could be of interest? It works as an abstraction language, and can provide output code in at least C++, C#, Java, Javascript and Actionscript, which could make your application work on a wide range of platforms. The syntax is fairly lightweight and approachable, you can see a quick demonstration here.

Regarding the second part of your question: From a business' point of view, covering more platforms is definitely a benefit, but you'll have to ask yourself whether the extra cost is worth it. In any case, more and more applications are being browser-based, so personally I think that at least being able to run in a browser easily would make the effort worthwhile.

1
  • Wow, monkey code idea sounds great (supporting so many platforms and environments). Not sure if I'm willing to learn completely new language, but will definitely take a look.
    – AareP
    Commented Apr 29, 2011 at 8:54
0

If you're willing to develop in Java, see http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideJavaToJavaScriptCompiler for an already built compiler. See http://code.google.com/p/gwtgl/ for webgl support.

2
  • Java is not as fast as c++ applications :)
    – AareP
    Commented Apr 29, 2011 at 8:47
  • @AareP: Typically not, but in some cases it is actually faster. Anyways if the compiled JavaScript version that runs in the browser is fast enough, you'll have no complaints about the native version. So I'd focus more on what produces better JavaScript with the least work. (I say this as someone who does not like Java.)
    – btilly
    Commented Apr 30, 2011 at 13:08

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.