Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Cling Aims to Provide a High-performance C++ REPL

Cling Aims to Provide a High-performance C++ REPL

This item in japanese

Cling is an interactive C++ interpreter that is built on top of LLVM and Clang and promises to provide a leap in productivity by going beyond the usual code-compile-run-debug C++ workflow.

Cling provides a read-eval-print loop (REPL) that is similar to common Unix shells and supports Emacs bindings. By using Cling, it is possible to test a C++ snippet bypassing the need to create a file, include headers, etc. The main advantage of using a REPL comes from the possibility of testing an idea in a fraction of second, without having to wait for the build system to compile the code. A REPL is also very useful when learning a language since it makes it easier to try out language features.

Cling is developed by the group behind Cern's ROOT data analysis framework as an alternative to their existing CINT command line C/C++ interpreter. ROOT is famously behind many current experiments in particle physics, including the Large Hadron Collider.

Cling can parse everything that Clang can do, while also supporting a few CINT-specific C++ extensions. Among the main advantages provided by Cling, the ROOT dev team lists the use of a production-grade parser, JIT allowing to call into libraries without wrappers, and the use of separate parser and execution engine.

Cling is available on GitHub and can be either installed from nightly binaries or built from source. The official all-in-one build script supports Unix-based systems while manual build is possible on Windows through CMake. Gallagher Pryor additionally describes a procedure to build Cling for the ARM platform, which is significantly more convoluted than building for x86, since the development team does not directly support this option through their build scripts.

Rate this Article