Read-Eval-Print-Loop (REPL) in C++

A Read-Eval-Print-Loop enables to leverage very rapid application development. This kind of environment is normaly reserved to scripting languages (python, nodejs) and to functional languages (lisp, haskell).

Cling realizes the read-eval-print loop (REPL) concept for the C++ language. Thus, you can gain in speed of development while the compiler (clang) still checks your code and guarantees a native speed of execution.

REPL in the console C++ REPL in a console             REPL in the jupyter notebook C++ REPL inside jupyter notebook


REPL interactive shell session

You can run a full C++ REPL from your console. In order to test this, the easiest way is to install the provided docker container. Refer to the docker instructions

See an example of an interactive C++ session here.


How to navigate in these notebooks

if you are reading this inside jupyter notebook

  • Click on the "Run" button at the top in order to run each cell (or type "Shift + Enter" in order to run it, and go to the next cell)
  • For a better undertsanding, it is better to clear the outputs below: click on the "Kernel" menu, and select "Restart & Clear Output"

If you are viewing a slideshow

  • navigate forward using the space bar
  • also use the arrows in the bottom right corner

A session of REPL / C++ with opencv

Load, display and manipulate images with opencv. Demonstrates how to load an external library and display advanced items.

View this document:

A REPL session of C++ functional programming, using fplus

A Read-Eval-Print-Loop makes functional programing very proficient. This notebook demonstrates it. If you are new to functional programming, it is recommended to view it as a slideshow.

View this document:

Advices and Gotchas when using cling and jupyter

The cling and xeus docs are good, but some informations are missing : this notebook adds more details.

View this document:

Installation : how to test these examples on your computer

Docker : quick test without modifying your machine

If you do not want to modify your machine, you can use the docker image provided inside this repo.

Refer to the docker instructions.

Full installation on your machine

Refer to the instructions on the xeus cling web page

I don't want to install anything!

As mentioned before, these demos are available online on

About cling

Cling is an interactive C++ interpreter, built on top of Clang and LLVM compiler infrastructure. Cling realizes the read-eval-print loop (REPL) concept, in order to leverage rapid application development. Implemented as a small extension to LLVM and Clang, the interpreter reuses their strengths such as the praised concise and expressive compiler diagnostics.

It is based on the Root data analysis framework, and originates from the CERN. Cling is stil under heavy development and might fail (for example a segfault in your program will exit cling REPL). However it is quite useful, and used everyday at the CERN.

About xeus cling

Xeus cling is a Jupyter kernel for the C++ programming language based on cling.

Read the docs here.

Intro to jupyter notebook

If you do not know jupyter notebook, take some time to familiarize yourself with the concept here: