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.
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.
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!”.
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:
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.