
Runtime-Compiled C++ - luu
https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus
======
gavanwoolery
In case anyone is wondering how the magic works, I am guessing it is using
shared libraries (but on top of that a lot of syntactic sugar). Also a good
teaser video of it here (although I think it is older):
[http://vimeo.com/26224634](http://vimeo.com/26224634)

Also, you can find the author here, who is also working on some interesting
stuff outside of RCC:
[https://twitter.com/dougbinks](https://twitter.com/dougbinks)

~~~
McP
"The runtime-modifiable classes use a macro that registers the files
themselves to be monitored. Whenever one of those files changes, we pick it up
and recompile it into a DLL. By linking that DLL we can switch over to the new
code, leaving the original EXE file untouched. This way we avoid any
interpreter and use native compiled C++ throughout."

(from
[http://www.runtimecompiledcplusplus.blogspot.co.uk/2011/07/t...](http://www.runtimecompiledcplusplus.blogspot.co.uk/2011/07/teaser.html))

~~~
amelius
Is that really necessary? I mean, we have JIT compilers nowadays, and they all
produce native code at runtime, without such tricks.

~~~
gavanwoolery
Yes, there are JIT compilers, see (not just first answer):
[http://programmers.stackexchange.com/questions/29344/jit-
com...](http://programmers.stackexchange.com/questions/29344/jit-compiler-for-
c-c-and-the-likes)

I'm not sure why these solutions have not caught on yet (seemingly).
Performance? Code complexity (i.e. invalidated pointers from recompile)?

~~~
grundprinzip
I think the biggest challenge is compilation time. With the lack of
incremental compilation modifying more complex classes can result in long
compilation time. Same is true for modifying templates that are widely used
within the code base.

If you look for example at runtime compilation of queries in database systems,
compiling can take significant amount of time, at least enough so it doesn't
feel instant anymore.

To get incremental compilation, one would need fully dynamic dispatched
invocation which would be probably horrible slow.

This said, I'm a strong believer in runtime code generation, just with a
reduced scope rather than full c++.

~~~
dougbinks
A lot of the complexity of the RCC++ solution over others (I listed those I
can find on the wiki
[https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledC...](https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus/wiki/Alternatives))
is about compiling the minimum possible code quickly in a platform independent
way. I'd love to see C++ get modules in the spec, along with introspection to
make this easier.

Compiling C++ code at runtime is less about end-user code than about improving
developer workflow for those who use C++ and want rapid iteration (game
developers for example), so avoiding extra languages and VMs is one of the
goals.

As for full dynamic dispatch, RCC++ does use virtual functions. I advocate
using a 'data oriented approach' so the function table pointer lookup should
be amortized by having expensive functions process multiple data items. In
practice in my own code I see no detectable overhead.

------
mc_hammer
really cool; would love it more if it was just 1 or 2 files. i think it needs
a bit more docs too.

~~~
dougbinks
Yes, I do need to add more docs - work is getting in the way a bit at the
moment though I'm using RCC++ for that so am maintaining and improving it as I
go.

