In this module we have a brief look at (probably) the most important stage in the development cycle: debugging.

Print statements

The first and foremost debugging technique is simply outputting the values of the variables in the region where the error occurs. This allows you to “see” what the program is doing to the variable and (hopefully) spot the error. This seemingly stupid “technique” is almost always the best first step in trying to debug a problem.


Most programming languages also provide a way of imposing so-called assertions (or asserts for short). See for instance the implementation in Python or in C++. These are expressions that we require to be true. If a certain assertion turns out to be false, the program will (usually) terminate with an error. See the language specific implementations above for further details.

Debugging tools

Alternatively, there are also dedicated tools that can help you debug a piece of code. The most popular free and open-source debugger is gdb. This tool allows you to see what is going on inside the program at the moment it crashes.

For specific problems regarding memory usage, for instance to detect memory leaks, there are also specialised tool such as valgrind.

Finally there are also some proprietary tools such as for instance DDT, which is part of ARM Forge. These are often very expensive, but can be very helpful if they happen to be available on your system.

Compile scripts

Compile scripts


The following webpage provides a basic introduction to compilation scripts using Make.


CMake (by Kitware)  is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.

The software for CMake can be downloaded here.

The CMake website also has a nice tutorial which should get you started to build your first project.


Jupyter notebooks

Notebooks are an increasingly popular and neat tool to organise your workflow. It is combination of text (including Markdown and LaTeX), code blocs, and output (such as plots and animations) that allow you capture and present your workflow.

Currently the most popular implementation is the open source and freely available Jupyter notebook.

A nice introduction to the Jupyter notebook can be found on DataCamp.


Scripting languages

In this module we introduce two popular scripting languages (Python and Bash) that can help you organise and optimise your workflow.


Python is the most popular first programming language and thus the go-to language for scripting. There are plenty of online resources to learn Python. Currently there are two versions of Python around (Python2 and Python3). Although they are very similar in many respects, we highly recommend to learn Python3, since Python2 is no longer maintained since the first of January 2020.

Since it is such a popular language, Python is one of the best documented subjects on the internet. As such, whenever you encounter a problem or are unsure about how to tackle a certain task, the immediate first response should always be to simply “Google” it. This will almost always lead you to a blog, tutorial or answer on a forum exactly explaining what to do. Most of the time you will even be able to simply copy-paste the solution into your own code. Once you have confirmed that it actually works, however, you should go back and try to understand why and how it works. This is probably the quickest and most widely used way that people learn python nowadays.

Getting started

Python is a great language to start to learn programming. It is quite close to regular English and helps you to get a lot done with a minimal amount of code. To familiarise yourself with the language and get yourself started we recommend one of the two tutorial platforms below:

Both start with the very basics but you can go further and dive in as deep as you want.

To really learn a programming language it is key to try things for yourself and start using the language in your own work. Therefore we suggest you try at least all the following things before continuing:

  • Check out the Anaconda package manager. If you actively want to use Python and its various existing packages, we highly recommend to use this package manager to alleviate the burden of installing and updating various (versions of) packages and their dependencies.
  • Check out Matplotlib and use it to create a plot of an exponential function. Then give the plot logarithmic axes.
  • Check out Numpy and use it to multiply to matrices. Then plot the resulting matrix by representing its values by a coloured tile in a grid.

Going beyond

Corey Schafer has a whole range of great videos from introductory tutorials to advanced topics in Python and related subjects.


Bash is a bit older but still widely used scripting language, mostly because it is the default shell on GNU operating systems (Linux) and Apple’s OS X. As a DiRAC user, Bash is an essential tool to effectively and efficiently use our systems.

Although not as popular as Python beyond scripting, there is still plenty of online material and examples on how to use Bash, thus also here the mantra remains: “whenever in doubt or trouble: Google it!”.

Getting started

To get you started with Bash we can recommend the following tutorial

or having a look at the following website

Again, the best way to familiarise yourself with a new language is start using it yourself. Therefore we suggest you try at least all the following things before continuing:

Going beyond

Also for Bash, Corey Schafer has a whole range of great videos from introductory tutorials to advanced topics.

The most comprehensive resource for Bash is the reference manual.

Intermediate Level Content


The DiRAC intermediate level training is the second stage in our training program. At this stage you will learn best practices to write scripts to organise and optimise your workflow. We start by introducing the most common scripting languages: Bash and Python. Furthermore, we introduce the popular concept of notebooks to organise your workflow. Finally, we introduce two languages: Make and CMake, specifically designed to write scripts for compiling code.

Course Content

The intermediate level course is split into 4 modules:

Currently there is no test for this course.