Live data from Hacker News

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

leaningtech.com

21–30 of 54 posts

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

#21

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 just ran the HelloClient.cpp from their example page [1] and the compiled file was 1.7 Mb

[1] http://www.leaningtech.com/cheerp/examples/

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

#23
post #2

I wonder what advantages choosing C++ to write web apps would bring. At the end of the day it's all JavaScript so performance is rather moot point.

Another major benefit (of emscripten too) is that is you have significant non-presentation client-side logic, it can be shared between iOS, Android, and the Web.

For example take something like Dropbox's Carousel architecture, which shares the client side cache, date model, and sync client between iOS and Android via a C++ library. Something like Cheerp or Emscripten allows you to also use this same library on the web.

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

#26
post #19
post #2

I wonder what advantages choosing C++ to write web apps would bring. At the end of the day it's all JavaScript so performance is rather moot point.

> 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

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

#27
post #2

I wonder what advantages choosing C++ to write web apps would bring. At the end of the day it's all JavaScript so performance is rather moot point.

For me it's portability first, decent performance second and third the 'seamless distribution model' of the web (no installation, no app shops, no code signing, just an URL).

I wouldn't write a web-only app in C++, but if the same code needs to run on other platforms as well (e.g. native mobile, desktop or gaming consoles) then C/C++ is basically the only choice. Also, at least in emscripten, compiled code is faster then hand-written JS for several reasons (asm.js, LLVM optimizer passes, no gc), so it makes sense to write stuff like physics/pathfinding/AI engines in C/C++ and compile it to JS.

Plus, it's fun to write a desktop OpenGL demo, flip a build system switch and run it in the browser ;)

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

#28
post #24

I know C and C++ pretty well; I wonder what this "C/C++" language is like.

The subset that is the interception of both? which would be a subset of C. (Although I am pretty sure that wasn't what the author had in mind)

Bjarne has always maintained that C++ is (mostly) backwards compatible with C. And that's what most people mean by C/C++.

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

#29
post #20
post #14

Earlier quoted context omitted.

You do get some of those performance benefits when you cross-compile. JS VMs have different paths for different types of code and the type of code that Emscripten produces goes through a faster path because more is known about the code ahead of time.

You also get 1.4MB of code, which takes 1 hour to load on a mobile connection, and reimplements functionality that host JS/Browser provides which goes much quicker ;) Most C++ code does not care about compiled size(especially with templates!!!), but JS code often does, so is written in a smaller way.

True, you need to be sensible about compiled code size which traditionally wasn't important for C/C++ code, and it's also true that the C++ std lib or careless use oft templates can bloat the code size. On the other hand, three.js which is basically the standard lib for 3D rendering on the web comes at 0.5 MB minified, which isn't exactly small either ;)

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

#30
post #28

Earlier quoted context omitted.

The subset that is the interception of both? which would be a subset of C. (Although I am pretty sure that wasn't what the author had in mind)

Bjarne has always maintained that C++ is (mostly) backwards compatible with C. And that's what most people mean by C/C++.

I know that C++ is mostly, but not entirely, backwards compatible with C. That doesn't answer the question of what "C/C++" means.

They're two different languages. The problem is that different people mean different things by "C/C++". Some people mean "C and C++"; others just seem to be unaware that they're distinct.

Post reply on HN