Files
JuliaKurs23/chapters/entwicklungsumgebungen.qmd

143 lines
4.6 KiB
Plaintext

# Development Environments
For this course, we will use the web-based development environment [Jupyterhub](https://en.wikipedia.org/wiki/Project_Jupyter). It is available to all participants for the duration of the course.
For long-term work, a personal installation is recommended.
## Installation on Personal Computer (Linux/MacOS/MS Windows)
1. Install Julia with the installation and update manager **juliaup**: <https://github.com/JuliaLang/juliaup/>
2. Install **Visual Studio Code** as editor/IDE: <https://code.visualstudio.com/>
3. Install the **Julia language extension** in VS Code: <https://www.julia-vscode.org/docs/stable/gettingstarted/>
Entry point:
- Create a new file with the extension `.jl` in VS Code
- Write Julia code
- `Shift-Enter` or `Ctrl-Enter` at the end of a statement or block starts a Julia-REPL, code is copied to the REPL and executed
- [Key bindings for VS Code](https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference)
and [for Julia in VS Code](https://www.julia-vscode.org/docs/stable/userguide/keybindings/)
### The Julia-REPL
When Julia is started directly, the [Julia-REPL](https://docs.julialang.org/en/v1/stdlib/REPL/) (*read-eval-print* loop) starts, where one can work interactively with Julia.
```default
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.12.5 (2026-02-09)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia>
```
## Working on the [Jupyterhub Webserver](https://misun103.mathematik.uni-leipzig.de/)
### Jupyterhub & Jupyter
- [JupyterHub](https://de.wikipedia.org/wiki/Project_Jupyter) is a multi-user server for Jupyter notebooks.
- Jupyter is a web-based interactive programming environment that
- was originally written for and in Python, but now supports many programming languages
- In Jupyter, one works with so-called *notebooks*. These are structured text files (JSON), recognizable by the file extension `*.ipynb`.
Our Jupyterhub server: <https://misun103.mathematik.uni-leipzig.de/>
After logging into Jupyterhub, a file manager appears:
::: {.content-visible when-format="html"}
![](../images/notebook001.png)
:::
::: {.content-visible when-format="pdf"}
![Jupyterhub file manager](../images/notebook001.png){width=50%}
:::
This can be used to:
- open existing *notebooks*,
- create new *notebooks*,
- upload files, e.g., notebooks, from a local computer,
- end the session with `Logout` (please don't forget!).
### Jupyter notebooks
::: {.content-visible when-format="html"}
![](../images/notebook003.png)
:::
::: {.content-visible when-format="pdf"}
![Jupyter Notebook](../images/notebook003.png){width=50%}
:::
*Notebooks* consist of cells. Cells can contain
- code or
- text/documentation (Markdown)
In text cells, the markup language [Markdown](https://en.wikipedia.org/wiki/Markdown) can be used for formatting and LaTeX for mathematical equations.
::: {.callout-tip }
Please check the `User Interface Tour` and `Keyboard Shortcuts` topics in the `Help` menu!
:::
The cell currently being worked on can be in `command mode` or `edit mode`.
:::{.narrow}
| | *Command mode* | *Edit mode* |
|:-------|:---------------:|:-----------:|
| Activate mode | `ESC` | Double-click or `Enter` in cell |
| New cell | `b` | `Alt-Enter` |
| Delete cell | `dd` | |
| Save notebook | `s` | `Ctrl-s` |
| Rename notebook | `Menu -> File -> Rename` | `Menu -> File -> Rename` |
| Close notebook | `Menu -> File -> Close & Halt` | `Menu -> File -> Close & Halt` |
| *run cell* | `Ctrl-Enter` | `Ctrl-Enter` |
| *run cell, move to next cell* | `Shift-Enter` | `Shift-Enter` |
| *run cell, insert new cell below* | `Alt-Enter` | `Alt-Enter` |
: {.striped}
:::
::: {.content-visible when-format="html"}
![](../images/notebook002.png)
:::
::: {.content-visible when-format="pdf"}
![Julia working...](../images/notebook002.png){width=50%}
:::
When a cell is working, its cell number becomes a `*` and
the `kernel busy` indicator (solid black dot at the top right next to the
Julia version) appears. If this takes too long (an *infinite loop*
is quickly programmed), then
- click `Menu -> Kernel -> Interrupt`; if this is ineffective,
- click `Menu -> Kernel -> Restart`.
::: {.callout-important }
After a `kernel restart`, all cells containing the required definitions,
`using` statements, etc. must be executed again.
**At the end of work, please always:**
- `Menu -> File -> Save & Checkpoint`
- `Menu -> File -> Close & Halt`
- `Logout`
:::