C++ or Python?

Up until this point, the commands for ROOT/C++ and Python/ROOT were nearly identical.1 I presented them in the context of using cling, ROOT’s C++ environment.

From this point forward, using ROOT/C++ is different from using Python with ROOT extensions (“pyroot”). You have to decide: in which language do you want to use ROOT? My initial advice is to ask your supervisor. Their response, in ascending order of likelihood, will be:

  • A clear decision (C++ or Python).

  • “I don’t know. Which do you feel like learning?”

  • “I have no idea what you’re talking about.”

If it’s up to you, this may help you decide:2

In favor of Python:

  • Learning Python is easier and faster than learning C++.

  • Python can be more appropriate for “quick-and-dirty” analysis efforts, if that’s the kind of work you’ll be doing this summer.

In favor of C++:


See here for the differences when using Python versus ROOT/C++.


Here are the areas in which neither has a clear advantage:

  • Both C++ and Python are used worldwide, so knowing either one is useful.

  • Python’s interactive development is usually cited as an advantage over C++, but ROOT offers the interactive C++ interpreter, cling.

  • Both languages have substantive numerical computing libraries (e.g., SciPy in Python, GSL in C++).

  • Rivals to C++ and Python include (respectively) the Julia programming language and the Ruby scripting language. As far as I know none of the particle-physics groups connected with Nevis use them.


There are various tricks for making Python run faster; e.g., the %pypy cell magic, the Cython extension, list comprehensions, clever use of numpy. You’ll learn about them if you choose to become a Python expert.