Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Cling : C++ REPL using Clang and LLVM (cern.ch)
58 points by mm_mm on Feb 18, 2012 | hide | past | favorite | 12 comments


"C++ REPL using Clang" gets me thinking...

I wonder if it'd be possible to compile Clang and Emscripten with Emscripten and make an (albeit slow) in-browser REPL for C.


Not exactly what you're suggesting, but https://github.com/jterrace/js.js is in a similar vein: SpiderMonkey -> LLVM -> emscripten -> JS to run a JS within JS.


Might be more doable to make a nacl plugin


Does this work for C too? I notice that it mentions replacing CINT, which is C & C++.

I'm a scrub to C and it'd really bum me out if I find out about an interpreter to play with just in time for it to no longer be viable.


CINT was designed to be a scripting language for the ROOT analysis environment. CINT is neither C nor C++ -- it departs subtly from both, but there is no exhaustive documentation of these departures from the respective standards (see http://root.cern.ch/root/html/cint/limitati.html for a few of them).

From their own site, one of the main goals of Cling is to be backward compatible with CINT. This will also mean propagating CINT's numerous idiosyncracies, reducing Cling's scope considerably.


CINT is really rather silly as the main interface to ROOT. ROOT is awesome, and huge, and you do need to use C++ to take full advantage of it, but it is also accessible from Python which is a far more sensible language to use in a REPL or in small scripts. I always did C++ for longer scripts or to integrate with other C/C++ work, but Python for quick scripts and REPL exploration.

Nice to see CINT evolving and using clang for better conformance (and performance, presumably), and hopefully this will free some time that was being spent on CINT but if you find yourself using this more than once for physics analysis, do yourself a favor and try python instead.


Is ROOT awesome? It is also full of base classes with a million member functions, home-built introspection, strings for every option instead of enums.


It may not be awesome. But it works.


To be clear: the python interface does use CINT underneath; it's just that the user is less exposed to the subtle "features" that give CINT it's unique character.


Nobody, and I mean nobody, likes CINT.


Things may have changed, but last time I looked at Cling you were limited in what you could do in the REPL. The main way I think it is used in practice is to slurp in a pile of C++ from files, and then inspect values in the REPL. As I say, this may have changed now.

The other thing to consider is that C is not really designed for use in a REPL. I personally use it more than any other language, but I don't personally feel that I would get much more out of it if I had a C REPL.

Having said that, C has no realtime features, and there are a lot of interesting potential applications if you have the ability to eval C code at runtime.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: