Live data from Hacker News

Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

allievi.sssup.it

11–20 of 63 posts

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#11
post #2

Are there any tutorials on this so that we can compare it to emscripten?

We will publish extensive tutorials soon, for now you can find some examples on http://leaningtech.com/duetto/examples/ In addition, the full source code of Nontetris ( http://allievi.sssup.it/jacopone/cnontetris/ ) will be published in a couple of days, with a 'guide' on porting a C++ game to Javascript with duetto. Stefano of Leaningtech

For games I think you need to show that duetto is just as fast as emscripten when running. emscripten-generated code is very light on the garbage collector (inside emscripten generated code no garbage is produced at all, only in some wrapper code which needs to talk to JS libs), and having the "heap" in a plain typed array usually also gives a performance advantage, since as in C++ you have exact control of the memory layout of your data structures. Not having to construct and destroy JS objects all the time, and keeping all data in typed arrays is essential for performance I think. This is even true without diving into asm.js.

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#12
That cnontetris example seemed to be having dire effects on Firefox's memory usage. It was using 21% of my 4GB, but then when I started that it went jumping up to over 80% and back down again and back and forth. Is it really causing the allocation and freeing of over 2GB of RAM just like that every so often?

Oh, by the way—the game was entirely unplayable for reasons likely to be related to this memory thrashing.

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#14

I'm not sure why you would want something like that, unless you really have a lot of existing code C++ business code you want to reuse, or you really love C++.

Being able to use the web as "just another platform" and use a single unified codebase across all platforms is a killer feature, especially for games. Also, maybe I'm old-fashioned, but I'd rather do a team-project with a "million-lines-of-code" in a compiled language with static type system which gives me compile and linker errors if someone adds a new function arg or changes the type of an arg. Of course also with other "compiled-to-JS" languages, but the killer-feature is multi-platform from the same codebase.

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#16
post #5

I'm not sure why you would want something like that, unless you really have a lot of existing code C++ business code you want to reuse, or you really love C++.

I really love C++ and I bet with the currently developing standard (C++11, C++14) more people will start loving C++ again :-)

"I bet with the currently developing standard (C++11, C++14) more people will start loving C++ again"

I doubt it. C++11 takes C++ even further from where it needs to be. Every high-level feature is bogged down by low-level annoyances. Do you capture variables by value or by reference? Do you need a weak pointer to break this cycle, or can you use a weak pointer somewhere else (or maybe just not both with smart pointers at all?)? Your destructor has an error to report -- now what?

The reason nobody likes C++ is that it is overly complicated for low-level programming and too low-level and annoying for high-level programming. At best the only thing people can say about C++ is that it is "good enough" and popular.

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#19

That cnontetris example seemed to be having dire effects on Firefox's memory usage. It was using 21% of my 4GB, but then when I started that it went jumping up to over 80% and back down again and back and forth. Is it really causing the allocation and freeing of over 2GB of RAM just like that every so often? Oh, by the way—the game was entirely unplayable for reasons likely to be related to this memory thrashing.

Our memory management approach is still not tuned and optimized. There are quite a few low hanging fruits that should provide great improvements, but we have not yet implemented them - Alessandro of Leaningtech

Re: Duetto: a C++ compiler for the Web going beyond Emscripten and Node.js

#20

That cnontetris example seemed to be having dire effects on Firefox's memory usage. It was using 21% of my 4GB, but then when I started that it went jumping up to over 80% and back down again and back and forth. Is it really causing the allocation and freeing of over 2GB of RAM just like that every so often? Oh, by the way—the game was entirely unplayable for reasons likely to be related to this memory thrashing.

Our memory management approach is still not tuned and optimized. There are quite a few low hanging fruits that should provide great improvements, but we have not yet implemented them - Alessandro of Leaningtech

Would you mind if I suggested that arbitrarily using a couple of gigabytes of memory like that was a fairly severe problem? :-)

Seriously, I would like to see a warning put on links to that example to the effect that at present it will make your browser use up to 2½ GB more RAM and will thrash your memory. Because it did render my browser (and to a lesser degree my system) unresponsive for a couple of minutes while things swapped.

Post reply on HN