This is our first post on this forum, so we hope that we are not breaking any rule!
First, we wanted to thank the authors of Cling, and more generally the broader community at CERN for producing this amazing software stack. We have been working on this, and building on Cling for a few months now, and we are really convinced that these technologies should be promoted beyond the high-energy-physics community.
xeus, a native C++ implemnetation of the Jupyter kernel protocol.
The first piece of software that we want to announce, is
xeus. Xeus is modern C++ implementation of the Jupyter kernel protocol. While it is not a kernel itself, it is meant to facilitate the work of kernel authors, who don’t want to depend on the
ipykernel Python implementation of the protocol.
We used xeus to develop a number of simple kernel, but the simplest on is the xeus-based cling kernel, which offers a number of features. Another kernel making use of
xeus is the Juniper, a kernel for the R programming language.
xeus-cling: a Jupyter kernel for cling based on the Xeus library.
Xeus-cling is a new Jupyter kernel for the cling interpreter. Unlike the kernel currently shipped with cling, xeus-cling makes use of cling as a library and directly uses the C++ API of the interpreter. This allows greater control over it than the current approach consisting in spawning the interpreter as a separate process and capturing the text output.
xeus-cling comes with batteries included. Some cool features include
- live quick-help from the Jupyter notebook with a simple question mark.
Help for the functions and classes from the STL is retrieved from cppreference. This can also be enabled for user-defined types.
- Making use of the rich display features of the Jupyter stack, for user-defined types.
This can be enabled simply by overloading mime_bundle_repr in the namespace of the class for which we wish to have a rich representation in the front-end. The overload is picked up by the display system through argument-dependent lookup (ADL).
- but also a complete implementation of the Jupyter widgets protocol and a backend for (most of) the widgets available in the reference
This is an aspect of our implementation of the Jupyter protocol that we intend to develop much more in the future, to enable backends for popular Jupyter interactive widget libraries built upon ipywidgets such as ipyleaflet, bqplot, pythreejs.
Conda packaging for
To build this software stack, we had to work on the packaging of cling and xeus in a way that would make installation easier on a broad variety of platforms.
We decided to go with the
conda package manager.
You can now install cling and the xeus-cling kernel from a simple miniconda installation by typing
conda install xeus-cling notebook -c QuantStack -c conda-forge
on both linux and OS X. An experimental build is also available for windows but it is not in a usable state.
Unlike the official nightly builds of cling, the one made available on conda is shipped with the C runtime that was used to link it (in the form of a conda dependency) making it truly portable.
A binder for
cling, the widgets and more.
Now that we have a conda package for cling it is easy to package it for binder and make it available to anyone on the internet.
To try out
xeus-cling, the quick help and the rich display mechanism, click on the following binder link:
To try out out
xwidgetsinteractive widgets, click on the following binder link
We hope that the binders will help promulgate cling beyond the HEP community.
A numpy-like library for array-based computing in pure C++
xtensor is a C++ library meant for numerical analysis with multi-dimensional array expressions.
- an extensible expression system enabling lazy NumPy-style broadcasting.
- an API following the idioms of the C++ standard library.
- tools to manipulate array expressions and build upon xtensor.
xtensor exposes an API similar to that of NumPy covering a growing portion of the functionalities. A cheat sheet can be found in the documentation.
However, xtensor internals are very different from NumPy. Using modern C++ techniques (template expressions, closure semantics) xtensor is a lazily evaluated library, avoiding the creation of temporary variables and unnecessary memory allocations, even in the case complex expressions involving broadcasting and language bindings.
Still, from a user perspective, the combination of xtensor with the C++ notebook provides an experience very similar to that of NumPy in a Python notebook.
In addition to the core library, the xtensor ecosystem has a number of other components
- xtensor-blas: the counterpart to the numpy.linalg module.
- xtensor-fftw: bindings to the fftw library.
- xtensor-io: APIs to read and write various file formats (images, audio, NumPy’s NPZ format).
- xtensor-ros: bindings for ROS, the robot operating system.
- xtensor-python: bindings for the Python programming language, allowing the use of NumPy arrays in-place, using the NumPy C API and the pybind11 library.
- xtensor-julia: bindings for the Julia programming language, allowing the use of Julia arrays in-place, using the C API of the Julia interpreter, and the CxxWrap library.
xtensor-r: bindings for the R programming language, allowing the use of R arrays in-place.
Detailing further the features of the xtensor framework would be beyond the scope of this post.
Interactive plotting with cling and Jupyter in the Jupyter notebook.
Xplot is an experimental C++ back-end for the bqplot 2-D plotting library. It enables an API following the constructs of the Grammar of Graphics in C++.
In xplot, every item in a chart is a separate object that can be modified from the back-end, dynamically.
Changing a property of a plot item, a scale, an axis or the figure canvas itself results in the communication of an update message to the front-end, which reflects the new state of the widget visually.
Warning: xplot is still at an early stage of development, and its API and behavior may change rapidly.
Beyonds the binders, we have been working with the University of Orsay to deploy
xeus-cling as part of they university-wide JupyterHub deployment, and it has been used for teaching C++ for all first-year CS students in September 2017, which is more than 300 student.
In general, we have found that starting C++ in the Jupyter notebook helps students a lot in the very beginning as it helps them getting familiar with the language syntax before having to set up a project and deal with other aspects such as compilation and linking.
There is a lot more to come. We hope that this will prove useful for the community. There is a number of known issues that we know of already, and we are reporting back to the upstream cling developers the issues that we encounter while using the APIs of cling.
Should you be interested in this, don’t hesitate to contact us, on one of the GitHub repository, or our gitter chat https://gitter.im/QuantStack/Lobby.
Sylvain, on behalf of the larger xeus and xtensor development team.