Ask HN: With emscripten, can C++ developers write web app without JavaScript

2 points by shanwang ↗ HN
Today is it possible to build a reasonably complicated single page web application, currently requires AngularJs or ReactJs, using C++ only (together with css and html)? How can you do data binding between html and compiled javascript like in AngularJS? Is there any tools to support this?

Is this also one of the goals of WebAssembly? ie. to enable non-web developers to write web application in their own language.

6 comments

[ 2.5 ms ] story [ 23.7 ms ] thread
Why would you want to do this? It doesn't make it faster than JavaScript. You'd still need to interface with JavaScript Web API bindings, which means you'd need C++ bindings to JavaScript bindings, which... use C++...

You can _currently_ do this without WebAssembly, but there's zero point to it.

ok, so the main usage of emscripten is to compile C++ to javascript and then call them from the "normal" frontend javascript code? ie. most UI related frontend job will still be coded in javascript?

As to the question why, C++ is not only about runtime performance, it's a more mature language than javascript/typescript and there are powerful data structure/design patterns/algorithms that are missing from javascript. Of course I see it this way because I'm way more competent in C++ than javascript.

I definitely appreciate that being a C and C++ developer, but you're sorely misled if you think that runtime carries over. Emscripten just translates the language to something usable through asm.js with a similar execution flow, but you end up running JavaScript. That's what it compiles to. Even WebAssembly is designed to run something that is consumed by the very same JavaScript runtime.
Are you sure about WebAssembly? I thought it's a new byte code standard and a completely new runtime on its own.
Yeah, it's designed to pass through the same mechanisms that handle JavaScript. It's a new byte code standard afaik, too, but one that's used in those systems.
I think you can use (x)inetd.

It's a linux wrapper, it listens to port X and calls an application everytime it gets a new connection.

The application will receive the HTTP requests in stdin. You'll need a parsing library to parse the request and generate a valid answer.

It's really old and deprecated technology but it's rather simple.