News for hackers. Stuff that matters.
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by angersock on Thursday October 31, 2013 @12:17PM (#6647679)
Downvoting comes around 500 maybe? Not actually sure.

Anyways, lest you think my observation is just a "non-constructive comment":

The great thing about the browser is that it is free of a lot of garbage we have to deal with in C++. The antics required to make C++ work in the browser, while laudable, are absurd.

If you need cross-platform code, write in Java and avoid native extensions.

If you need cross-platform code that has to be fast (i.e., you actually need to have inline assembly), write in C or C++ and actually do your proper cross-platform work (proper abstraction of I/O, proper defines, proper selection of types, etc.).

If you need to draw shit in the browser, use the wonderful ecosystem of tools that have evolved using the standard affordances of Javascript and CSS.

Here are the bits I take issue with:

"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."

Why? What type of code is worth reusing? What type of performance is this going to get me?

Most C++ codebases are janky and sad--game engines being some of the worst offenders.

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

Why the fuck would you ever want to use C++ as that language? It's terrible, so much so in fact that it lost out to PHP and Perl.

Let that sink in for a second.

People said, "I would really like a language that's easier to work in!" and then picked PHP and Perl. PHP and Perl.

Moreover, go look at their docs:

http://www.leaningtech.com/duetto/examples/

" Duetto does not attempt at emulating numerical types which are not supported by JavaScript float is supported with 64-bit precision, like double. long long is defined as a 32-bit integer. 64-bit integers are not supported at all in JavaScript and duetto does not attempt to emulate them."

Well thank Christ we never will need numerical types not in Javascript--I mean, I've never used bit-twiddling in my engine code, or my decompression code, or my audio code.

~

Look, it's a really cool use of LLVM, but we don't need C++ in the browser.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by flohofwoe on Thursday October 31, 2013 @12:26PM (#6647747)
Have you ever had to maintain a code base with more then a few hundred thousand lines of code across Flash, Javascript, iOS, Android, PC, OSX, Xbox, PS, Wii, Vita, NintendoDS, ...and whatever other gaming platform is popular at the moment? The "popular platform of the day" changes a lot faster then being able to write new code for it. You need to support that new platform within 3 months or less. Good luck rewriting your entire code base into another language in that time ;)
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by tomkludy on Thursday October 31, 2013 @12:48PM (#6647897)
Frankly, I've had to maintain a huge C++-only codebase, and that's why I hope to never write another app in C++.

Yours is an argument for a high-level, typesafe, compiled-to-native and compiled-to-javascript language. But IMO the argument falls down when applied to C++, because it is not high-level, it is only marginally typesafe, and it doesn't compile to javascript well at all (tradeoff of either massive performance, or missing basic functionality like 64 bit ints).

It is very possible that no language will fit this role exactly for some time to come. But, to me at least, it is very clear that C++ is NOT the language for the job.

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by flohofwoe on Thursday October 31, 2013 @01:11PM (#6648053)
Yes I see your point to a degree, in a way we're working in a sort of "highlevel C++" most of the time at some performance cost: We have strict coding conventions in place which forbid low-level C/C++ stuff in high-level code (no raw pointers, no C-style arrays, no pointer arithmetics, no C library functions, etc...). Plus static code analysis and tons of runtime asserts. I can't remember the last time we had a buffer overflow or pointer-gone-wild. The performance hit of C++ compiled to JS is surprisingly small (1.5x native performance in Firefox, a bit slower in Chrome, but the gap is getting smaller, this is in the same ballpark as strongly typed bytecode languages like C# or Java).
Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by angersock on Thursday October 31, 2013 @12:39PM (#6647842)
http://fabiensanglard.net/anotherWorld_code_review/index.php

This was well-solved a long time ago so...uh...yeah I guess? With much worse hardware?

Maybe Lua?

Do you actually have a real example, or were you just listing off all the magical platforms?

EDIT:

Ha, you do some pretty cool work.

Anyways, put more mildly, is there a case you've seen where you actually have to support all the platforms you've mentioned?

(I seem to be making all sorts of friends today. :| )

Re:Duetto: a C++ compiler for the Web going beyond Emscripte... by flohofwoe on Thursday October 31, 2013 @12:53PM (#6647936)
;) We've been an independent dev studio (Radon Labs) before being bought by Bigpoint, and the only way to survive was to support a wide range of platforms (we weren't big or successful enough to have the luxury to pick our target platforms). So our engine basically scaled from the NintendoDS to PCs. Being able today to just cross-compile our engine to JS+WebGL or mobile platforms(between 150k and 500k of C++ code, depending what modules you link) is very nice. Plus, for browser games, Flash and plugins as a whole are on the way out, so we need a solution to bring our games into the browser without plugins. A solution like emscripten or duetto to compile C++ (or maybe later other languages) to JS with a relatively small (and predictable!) performance hit is definitely "good enough" for us.