Live data from Hacker News

Cheerp – A C/C++ compiler for web applications

leaningtech.com

31–40 of 54 posts

Re: Cheerp – A C/C++ compiler for web applications

#31
Interesting although if you want massive performance on a web application i'd probably vie for erlang unless you're doing something computationally complex on the backend. It would be nice to be able to write code once and use in multiple places but theres often so much extra work involved in that, that for many applications it makes more sense to just use interfaces etc.

Neat project either way.

Re: Cheerp – A C/C++ compiler for web applications

#32

If anyone from Cheerp reads this, I use emscripten ( https://github.com/kripken/emscripten ) at the moment, is Cheerp any better ? Specifically does it compile faster, generates a smaller final .js output, or produce "faster" code ?

I'm not from Cheerp, but it looks like the main difference is this (taken from their front page):

Dynamic memory management. C++ objects are translated directly to JS objects, without the proxy of an emulated, flat memory space. Allow your applications to exploit the JavaScript VM garbage collector and co-exist with fair, on-demand memory allocation.

I don't think that's a good thing though, since the reason why emscripten compiled code is fast is because it has a flat memory space and doesn't create expensive JS objects.

Only advantage IMHO is that you don't need to allocate a big chunk of memory ahead of time (although I think emscripten still allows a growable heap as an option, but with a performance penalty).

Re: Cheerp – A C/C++ compiler for web applications

#33
post #26
post #19

Earlier quoted context omitted.

> it's all JavaScript so performance is rather moot point If that was the case, http://asmjs.org/ wouldn't be a thing.

According to the Chrome guys...it isn't a thing [0][1], and I tend to agree. They've kept up, and often exceeded FF, IMO, for real code by making a better JIT compiler. They still haven't implemented asm.js and yet their "naive" approach to asm.js style code is on par. [0] https://code.google.com/p/v8/issues/detail?id=2599#c53 [1] http://mrale.ph/blog/2013/03/28/why-asmjs-bothers-me.html

The links you pasted show Firefox currently being 3x faster than Chrome when running asm.js code, so I'm not sure what your point is. V8 is good at generating fast code without the hints, but obviously the extra restrictions help the optimizer. Even Google admits this when they try to promote Dart.

asm.js does little for you if you write "real JS", but this thread is about cross-compiling other languages, which clearly has real world use.

Re: Cheerp – A C/C++ compiler for web applications

#35
post #11
post #6

Earlier quoted context omitted.

That's actually not true. Emscripten compiles to code that is much faster than hand-written JavaScript. In this case they are not using Emscripten or a similar technique but are compiling to regular old JavaScript, so performance probably is the same, rather this might be for people who just like C++, like what GWT is for Java devs.

You misunderstood. People mostly write with C++ when performance is critical. Why? C++ offers deterministic memory management, Specialize to CPU instruction set and better use of CPU caches etc. Those performance benefits would not translate when you cross compile to something like JavaScript. I get the point about converting the legacy desktop apps to web apps, but how would it handle the architectural differences (…

At least when compiled with emscripten, the same memory-access-related optimizations used in native code also apply to cross-compiled JS code since the memory layout is exactly the same. emscripten uses a big linear memory buffer (a single big JS typed array) as heap and dlmalloc for dynamic memory management within this heap. If your code is cache-friendly in the natively compiled version of the code it will also be cache friendly in emscripten compiled code. Cheerp seemt to use a different approach though and seems to generate 'traditional' high level JS objects (which also means it requires garbage collection, which emscripten generated code doesn't).

Re: Cheerp – A C/C++ compiler for web applications

#36
post #17

Earlier quoted context omitted.

That was going to be my response..

I was replying to the statement: "For example, people also write C++ when correctness is critical". And I say if someone writes C++ in a correctness critical system, he must not know what he is doing. Even if you're using only STL, RAII and following all the good coding practices, there are still so many ways to screw things up, that C++ is among the worst choices in this regard.

Nasa and military don't know what they're doing? C++ is the go to language in mission critical systems.

Re: Cheerp – A C/C++ compiler for web applications

#37

Interesting although if you want massive performance on a web application i'd probably vie for erlang unless you're doing something computationally complex on the backend. It would be nice to be able to write code once and use in multiple places but theres often so much extra work involved in that, that for many applications it makes more sense to just use interfaces etc. Neat project either way.

If you want massive performance, you most likely want to avoid erlang; if you want massive scalability, erlang might very well be a great fit. I think it's quite different.

Re: Cheerp – A C/C++ compiler for web applications

#38

If anyone from Cheerp reads this, I use emscripten ( https://github.com/kripken/emscripten ) at the moment, is Cheerp any better ? Specifically does it compile faster, generates a smaller final .js output, or produce "faster" code ?

The Emscripten author wrote a blog post when Cheerp (then called duetto) was first announced:

http://mozakai.blogspot.co.uk/2013/11/c-to-javascript-emscri...

Re: Cheerp – A C/C++ compiler for web applications

#39
"Cheerp compiles to native binary code backend, JavaScript frontend, and automatically generates RPC communication code"

The RPC feature sounds like it could be immensely useful for day-to-day web development. But the C/C++ is a deal-breaker for most web developers. Are there any projects that only do the RPC autogeneration stuff?

Also can frontend/backend code be shared (if there are no dependencies to the browser/unix system)?

Post reply on HN