Cling – An interactive C++ interpreter built on top of LLVM and Clang
root.cern.ch
root.cern.ch
In fact, those of you that are into slightly bizarre code archaeology, have a look at the CINT and pre ROOT code prior to ROOT 6. We used to joke that ROOT was the then primary developer's learning project for migrating from FORTRAN to C++... Despite that, virtually every major contemporary particle physics experiment/analysis relies on ROOT!
Unfortunately the previous interpreter (CINT) was a unpredictable mess of hacks with vast code bases dependent upon it. Cling has now taken over for most experiments and is much better.
For interactive work more and more people are using alternatives like python, but C++ and ROOT are deeply ingrained. Almost all data is stored in the ROOT file format and can only be read using ROOT. The library itself supports many common tasks which don’t have mature alternatives. Both of these points are slowly improving and benefiting from the wider data science community but ROOT will continue to be used for decades to come (the LHC experiments will run until at least mid 2030 with data being analysed for many years after).
I'd be interested to hear what tasks don't have good alternatives. ROOT can plot histograms, but matplotlib does it much better. ROOT files are a halfway decent file format, but HDF5 is much better. ROOT has a cross-platform socket library, but boost::asio is much better.
The main reason I see for ROOT's continued usage is to compensate for the difficulty in adding new dependencies to a C++ project. With ROOT already being used in physics experiments, starting to use another of its submodules is simpler to do than pulling in a better-designed library.
https://indico.cern.ch/event/567550/contributions/2628878/at...
As much as I prefer matplotlib, quickly combining histograms with uncertainties and no regard for formatting is quicker with ROOT. 2D/3D/Profile histograms are also easier to quickly make.
> ROOT files are a halfway decent file format, but HDF5 is much better.
I believe the ROOT format is more generic and also does a good job of serialising generic objects, but this isn't really my area of expertise.
I also find that for all its many (many) faults, RooFit/RooStats doesn't have a generic alternative.
I understand your point, but HDF5 isn't better. For one, HDF5 files tend to be considerably larger.
[1] https://root-forum.cern.ch/t/memory-leak-using-interpreter/2...
The live demo is here: https://mybinder.org/v2/gh/QuantStack/xeus-cling/0.0.7?filep...
One thing that I think is under-appreciated in this kind of thing is that a proper C++ repl is significantly less frustrating than a debugger. GDB's C++ mode is at best a poor emulation of the C++ language. LLDB does better because it reconstructs an actual C++ AST and runs it through clang but there's still a ton of limitation (e.g. you can't call any templates or inline functions from header files).
Interactive C++ is pretty fun, especially for prototyping. The biggest problem I generally run into is that APIs in C++ are not really designed to be used in that way (esp in libraries whose user's don't use these kinds of tools). Libraries in languages with interactive prompts tend to have APIs designed in such a way that you can get the simple thing done with very little code (one call, only the arguments you need, etc), while in C++ it's a lot more common to expect user's to copy/paste a snippet from the doc and adjust all the options they want to change. That works fine in an editor, but is pretty annoying in a prompt. The other thing I often run into is error handling. A lot of C++ libraries' error handling is to just call abort() (at best) or segfault, which again is mostly fine for a compiled problem, but is annoying in an interactive setting. You can work around that of course by catching the error/resetting state, but even then you often leave libraries in the wrong state.