Add Working with code
parent
33a51f6a5c
commit
0ba8fd73b8
|
@ -0,0 +1,18 @@
|
|||
Writing code is essential in scientific simulations: be it to automate the running of a task, to do complex calculations for a simulation, or to post-process results. A properly configured code editor can be a productivity boost in these tasks. Other software, such as a compiler, package manager, script interpreter, notebooks, are equally essential.
|
||||
|
||||
# Code editor
|
||||
A code editor is a program specialized in writing *plain text*, as opposed to the *rich text* of software like LibreOffice Writer or Microsoft Word. Good code editors give a lot of functionality to move around code, edit it, re-factor it, search it, compile and run it, etc.
|
||||
|
||||
There are code editors on Linux that can run in the CLI: it is worth spending some time to get familiar with them, as you can use them to edit code on remote machines (e.g. adjusting a script running on a cluster). The main three are:
|
||||
|
||||
- [nano](https://www.nano-editor.org/) super simple editor (with powerful features nonetheless), easy to learn, almost always available by default on Linux machines
|
||||
- [vim](https://www.vim.org/) a rather difficult editor to use at first because it differs from the standard experience of editing text, but extremely efficient when mastered. Highly customizable, and almost always installed by default on Linux machines. Type `vimtutor` in a terminal for a quick introduction
|
||||
- [emacs](https://www.gnu.org/software/emacs/) perhaps easier to learn than vim, endlessly customizable with thousands of plugins (you can read your emails in emacs, or manage a git repository). Can be made to emulate vim's editing style with the `evil` package. Not installed by default on most Linux distributions, but can be founds on clusters.
|
||||
|
||||
Some code editors can allow remote editing of code, this is the case of emacs and [Visual Studio Code](https://code.visualstudio.com/). While the latter is now widely popular, I would advise spending some time learning one of the three editors above, as they can be used entirely without a mouse (which can be very useful) or a GUI (which can happen easily if a graphical driver issue arises). All of the "nice" features of VS Code (completion, syntax check, code formatting, etc.) can be configured in emacs or vim (although they likely require more time to set up than VS Code).
|
||||
|
||||
# Compilers
|
||||
`sudo apt install build-essential` should set you up nicely with the basic tools to write C/C++ code. `cmake` is also a staple of C/C++ development. I use `scons` to compile Tamaas.
|
||||
|
||||
# Python
|
||||
Python is ubiquitous in scientific computing thanks to its very large offer of third-party libraries dedicated to computation (most famously Numpy and Scipy). Python is however notoriously bad with dependency management. I would advise manually installing a specific Python version separate from the system's Python (which can sometimes be very outdated) using a tool like `pyenv`, and using [virtual environments](https://docs.python.org/3/library/venv.html) for each "project". This limits the risks of custom or manually installed packages interacting with the system packages and causing trouble. This includes Jupyter Notebooks.
|
Loading…
Reference in New Issue