Duetto: a C++ compiler for the Web going beyond emscripten and node.js


Today Lean­ing Tech­nolo­gies Ltd. releases duetto, a com­piler designed to develop inte­grated (back­end and fron­tend) web appli­ca­tions in C++. duetto is now avail­able to the pub­lic as FOSS here, and will be offered in a com­mer­cial pack­age with closed-source-friendly licens­ing soon.

Browser-based appli­ca­tions will undoubt­edly play a big role in the future of both con­sumer and busi­ness appli­ca­tions. Web apps have some clear advan­tages com­pared to native appli­ca­tions, like being natively cloud-based and col­lab­o­ra­tive, while also being inher­ently portable, espe­cially thanks to the increased atten­tion that browser ven­dors have ded­i­cated to web stan­dard com­pli­ancy. Mod­ern web stan­dards, that usu­ally go under the umbrella term HTML5, pro­vide incred­i­ble close-to-native capa­bil­i­ties and this gap will be shrink­ing with time.

Sev­eral tools have been devel­oped to help pro­gram­mers in writ­ing large-scale Web appli­ca­tion fron­tends, reduc­ing the lim­i­ta­tions and obsta­cles given by Javascript: Coffe­Script, Microsoft Type­Script, Google Dart, Google GWT and, more recently, emscripten, which com­piles LLVM byte­code (and there­fore C++) to Javascript. On the server side, it is com­mon to use lan­guages such as PHP, Python and Ruby, lead­ing to a sep­a­rate back­end code­base in a lan­guage other than Javascript. This causes dupli­ca­tion of code (and new bugs), hav­ing to deal with RPC man­u­ally, and over­all takes time away from proper devel­op­ment. A very pop­u­lar solu­tion for this has been to use Javascript on the server as well with node.js.

We present duetto, our C++ com­piler for the Web, which is now avail­able to the pub­lic. Our solu­tion inte­grates and sur­passes fea­tures of exist­ing tools, and allows to pro­gram both the fron­tend and the back­end of a Web appli­ca­tion in an inte­grated C++ code­base, com­pil­ing them respec­tively to JavaScript and native code.

Duetto com­bines the advan­tages of emscripten and node.js by allow­ing the pro­gram­mer to:

  • write web appli­ca­tions in C++, reusing exist­ing code and mak­ing port­ing of whole appli­ca­tions and games to the browser plausible.

  • code both the fron­tend and the back­end of a web appli­ca­tion in the same lan­guage and codebase

In addi­tion to this, duetto pro­vides some nice features:

  • Bring the robust­ness and proven scal­a­bil­ity of C++ pro­gram­ming to the Web

  • You can access all browser APIs directly. Duetto inher­its the C++ phi­los­o­phy of expos­ing the plat­form capa­bil­i­ties (and lim­i­ta­tions) to the users. There is no mid­dle man.

  • Duetto is based on LLVM/clang. An indus­try stan­dard C++ com­piler is a programmer’s best friend: code san­ity is ver­i­fied as com­pile time, includ­ing RPC signatures.

  • The LLVM tool­chain also guar­an­tees that a mind-blowing set of opti­miza­tions is run at com­pile time, gen­er­at­ing highly effi­cient code. This decreases the bur­den on JavaScript JIT com­piler at runtime.

  • Con­trar­ily to emscripten we do not try to emu­late a tra­di­tional address space using typed arrays, but directly map C++ objects to JS objects. This reduces mem­ory con­sump­tion since the garbage col­lec­tor can delete unused object.

Are you inter­ested in using duetto? You can now. We have just released the whole tech­nol­ogy as a FOSS project, avail­able here.  Also, we’ve stuck to our promise of releas­ing in six months from our first announce­ment in April

The com­piler itself, derived from LLVM/clang is released with the same license as LLVM/clang (UI/NCSA) and we plan to con­tribute gen­er­ally use­ful code upstream. Accom­pa­ny­ing head­ers and libraries will be released as GPLv2+. We will be also offer­ing closed source friendly licens­ing of such com­po­nents for a fee. Here are links to the var­i­ous repos­i­to­ries on github:

Release tar­balls will be avail­able shortly on the Launch­pad page of the project: https://launchpad.net/duetto. Launch­pad will also be our bug report­ing sys­tem, so please use it to report any prob­lem you might find. We will be also pro­vid­ing builds of duetto for Ubuntu linux using a PPA. We plan to pro­vide binary builds for Mac OS X and Win­dows as well, but we are still work­ing on automat­ing those build.

Please sub­scribe to our Launch­pad group/mailing list to dis­cuss bugs, desired fea­tures and usabil­ity issues on https://launchpad.net/~duetto-users. You can also fol­low us on twit­ter (@leaningtech) and visit our web­site to be updated on duetto related news:

  • Terry A Davis

    My met­ric for com­pil­ers is how fast they can com­pile them­selves.
    I wrote a HolyC com­piler http://www.templeos.org

  • cpt­danko

    not very use­ful comment

  • cpt­danko

    not a, to be gram­mat­i­cally correct

  • FireAtWill

    “Not a very use­ful comment” — to be gram­mat­i­cally and punc­tu­ally cor­rect, the dou­ble quotes actu­ally denote you are refer­ring to some­one else’s post

  • cpt­danko

    i can live with that, i have pub­lished research (in com­puter Sci­ence) so i do not need con­fir­ma­tion about my Eng­lish, tell me does your com­ment have any other pur­pose than blow­ing your own trum­pets i.e. Show-off or some­thing like that

  • Tylor Pater

    Are you get­ting mad at some­one cor­rect­ing your cor­rec­tion? Isn’t that a lit­tle ironic?

    It’s also ironic that you would get mad with a com­ment that has such poor grammar.

    Don’t cor­rect oth­ers incor­rectly. If you do, expect to be criticized.

    Have a nice day :)