Chapter 1: Scientific programming languages
What is a scientific programming language?
Scientific programming languages…
… are programming languages optimized for the use of mathematical formulas and matrices. en.wikipedia.org
Why should we learn a scientific programming language?
Statistical tools like Prism and Excel do already a very good job regarding statistical analysis and visualization. And: They are easy- and ready-to-use.
Scientific programming languages perform the same job, the mathematical background behind them is the same (with some exceptions in the numerical implementation). But: There is no Graphical User Interface (GUI), we have to write each analysis step by our own.
So, why should we learn Python, MATLAB, R …? The answer is:
- Automatization
- At the beginning it takes a little longer to get where you want to go.
- But when you’re done, you have a powerful tool to process all of your current (and future) data, without manually repeating your analysis steps!
- Standardization and Reproducibility
- By pipelining your data through an automatized analysis, you ensure, that each of your data sets is processed and analyzed the same way (if it makes sense!).
- This standardization ensures reproducibility of your results for you and for others and enables inter- dataset/-group comparisons.
- Perform more complex tasks
- You can go beyond the scope of any black-boxed suite-solution.
Time is what you invest for the automatization
Efficiency in analysis, reproducibility and reliability in your results is what you gain
But caution: One should always ask at the beginning: Will I get my results faster with, e.g., Prism? Or is it worth to invest the time for automatizing my analysis steps? Do not limit yourself in the choice of your tools and methods: If you just want a quick plot of your data, why shouldn’t you use Prism or ImageJ?.
Why Python?
- Open-source: “free” + continuously improved by a worldwide community
- Portable: You can install Python wherever you want to (PC, Mac, Linux, or Laptop, Workstation, on your desk, in the Lab or at home), your code will work everywhere.
- “Interpreted”: Your code (“instructions”) is directly executed without previously being compiled into the actual machine-language instructions (i.e. machine-code, the language, your computer is operating with).
- “High-level” programming language: use natural language elements to “tell” the computer what you want (e.g., mean([1, 2, 3, 4]) instead of using cryptic/abstract machine code)
- More than “just” scientific programming: You can also program your coffee machine, a Mars rover or a virtual reality environment for your mice behavior experiments.
- Extensive support of libraries: install as much additional modules as and when you need to. E.g., a wavelet toolbox, fancy plotting toolboxes, statistics toolboxes … they are all free (in other programming solutions you have to pay for such add-ons).
- Collaboration: collaborate and exchange with your local or worldwide colleagues, who also use Python.
Where to find help?
The official developers’ documentation websites act as a glossary paired with very good examples and often tutorials:
- https://www.python.org/doc/, https://docs.python.org/3/
- https://matplotlib.org
- https://numpy.org/doc/
- https://pandas.pydata.org/docs/
- https://pingouin-stats.org/api.html
Another and fast way to look up Python commands and their syntax is to use the built in help system via the help(your_command or or object)
command. For example, to look up the help of the list()
command, type into the console:
help(list)
Please find more references in the Further readings chapter.
Acknowledgement
The sources and licenses of the logos used on this page are:
- C++ logo source: commons.wikimedia.org, license: public domain
- Excel logo source: commons.wikimedia.org, license: public domain
- Fortran logo source: commons.wikimedia.org, license: public domain
- Julia logo source: commons.wikimedia.org, license: public domain
- Mathematica logo source: commons.wikimedia.org, license: public domain
- MATLAB logo source: commons.wikimedia.org, license: public domain
- Python logo source: commons.wikimedia.org, license: GPL
- R logo source: commons.wikimedia.org, CC BY-SA 4.0
- Visual Studio logo source:commons.wikimedia.org, license: public domain