# Computer glossary

Here you will find a glossary with some of the computer terms used throughout the book.
You can **choose** to either read them in detail now to learn what these terms mean, skim over them, or skip this page altogether and return at a later point in time when and if needed.
Most of the terms will also be explained later in the book, so you can think of this page as an overview place.

You will notice, both here and throughout this book, that **some terms are not unique to the computational world** (e.g., terms such as *function* or *library*).
Therefore, a part of the learning process will be to understand the meaning of the words within a given context.

````{admonition} Programming
:class: note, dropdown
Programming is the **process of writing computer programs** (sets of instructions that a computer can follow), to perform specific tasks. It involves using a programming language to create code.
````

````{admonition} Programming language
:class: note, dropdown
To write instructions in such as way that a computer can understand them (i.e., to write code, or to program), we use a **programming language**.
Python, which we will use in this course, is an example of a **programming language**.
While there are thousands of programming languages developed and available to use, some of the most popular today are Python, C, C++, C#, Rust, Java, JavaScript, PHP, R, Ruby, and Scala, among others.
Once you master one language, switching to another is relatively easy because the underlying logic is usually very similar.
Therefore, it is *mostly* a matter of learning a new **syntax** - the rules that structure a language.
````

````{admonition} Syntax
:class: note, dropdown
Syntax refers to the **set of rules that define how code must be written** in a programming language. It determines the correct structure and order of words, symbols, and punctuation so that the computer can understand and execute the instructions. **Each programming language has its own unique syntax**. Here are some examples of doing the same thing in a couple of different languages.

Python
```python
print("Hello, world!")
```
JavaScript
```JavaScript
console.log("Hello, world!");
```
C
```C
printf("Hello, world!\n");
```
C++
```C++
std::cout << "Hello, world!" << std::endl;
```
Ruby
```ruby
puts "Hello, world!"
```
Java
```java
System.out.println("Hello, world!");
```

Each language uses a different syntax to achieve the same result. Although the code looks different in each example, they all have the same purpose: to display the message `"Hello, world!"` on the screen.
````

````{admonition} Algorithm
:class: note, dropdown
An algorithm is a **step-by-step procedure** for solving a problem using computer code.
In other words, with an algorithm you are sketching what your approach to solving a problem will be.
It is useful to think of the steps that will be needed before starting to write your code.

```{figure} images/Algorithm_example.svg
---
height: 250px
name: algorithm
---
Scheme of an algorithm for solving the problem of *lamp not working*.
```

````

````{admonition} Script
:class: note, dropdown
A Python script is a **file containing Python code**.
You can recognize scripts by specific file **extensions** - just as you would recognize a Microsoft Word file by its `.doc` or `.docx` extension, you can spot a Python script by the `.py` extension.
To actually perform the task you programmed, you need to **execute** the script using Python.
````

````{admonition} Debugging
:class: note, dropdown
Finding errors in computer code is often referred to as *catching bugs*, and fixing them as *fixing bugs* or *debugging*.
Debugging, therefore, means correcting errors in the code.

```{admonition} Historical note
:class: tip, dropdown
Term debugging is attributed to Admiral Grace Hopper, who worked at Harvard University in the 1940s.
Her co-workers found a moth stuck in the computer, thereby impeding its functioning.
She famously remarked that *the system needs debugging*.

```{figure} images/bug.webp
---
height: 250px
name: bug
---
The first case of a computer bug ([photo source](https://www.history.navy.mil/content/history/nhhc/our-collections/photography/numerical-list-of-images/nhhc-series/nh-series/NH-96000/NH-96566-KN.html), image from the public domain).

```

````

````{admonition} Package / Library
:class: note, dropdown
Packages are building blocks of programming.
They consist of reusable pieces of code, so that you do not have to program everything from scratch (and thereby avoid "reinventing the wheel").
Sometimes, we refer to published packages as **libraries**.
Examples of Python libraries are <a href="https://numpy.org/doc/stable/user/whatisnumpy.html">NumPy</a> for scientific computing and <a href="https://matplotlib.org/">Matplotlib</a> for visualization.
````

````{admonition} Function
:class: note, dropdown
A Python function is a piece of **reusable code** that performs a specific task.
You can either define functions by yourself (in your code) or use predefined ones, e.g., functions that come as part of Python packages (libraries).


Function that adds two numbers
```python
def add_numbers(a, b):
    return a + b
```

Calling (i.e., using) the function
```python
result = add_numbers(3, 5)
print(result)  # Output: 8
```

You will learn more on this in a [later chapter](../chapter-11-functions/functions-intro.md).
````

````{admonition} Computer program and code
:class: note, dropdown
A computer program is an **implementation** of computer code which instructs the computer how to execute the algorithm.
A program can consist of many parts, such as multiple functions, variables, and instructions working together.

```python
def greet(name):
    print("Hello, " + name)

def display_length(name):
    print("The lenght of your name is:", len(name))

name = "Alice"
greet(name)
display_length(name)
```
Output:
```text
Hello, Alice
The lenght of your name is: 5
```
This simple program consists of two **user-defined** functions: `greet()` and `display_length`. They both use Python's **built-in** `print()` function to display output, and one of them also uses the **built-in** `len()` function to obtain the length of the name.
````

````{admonition} Package management
:class: note, dropdown
Like many things in computer world, Python packages get improved over time.
As a consequence, new **versions** of packages are regularly released.
Because a part of one package can depend on a part of another package, it is very important to keep track of used packages, their specific versions, and their **dependencies**.
There are specialized tools for Python package management - <a href="https://pypi.org/project/pip/">pip</a> and <a href="https://conda.io/projects/conda/en/latest/user-guide/getting-started.html">conda</a> - which help us to avoid package version conflicts and ensure that the packages we use when working on a piece of code are compatible.
````

````{admonition} Environment
:class: note, dropdown
A Python environment is a **setup** in which a Python script is executed. 
For instance, if you use functions from the NumPy package in your code, (a specific version of) NumPy has to be present in the environment.
Because packages can depend on each other, and because details of functions can change between versions, your code may stop working ("break") upon package update. 
It is, therefore, good practice to work within environments that contain specific versions of packages needed in your code.
There are also different types of Python environments: system environment, conda environment, virtual environment, and containerized environment.

```{figure} images/environments.png
---
height: 250px
name: environment
---
Illustration of two separate Python environments, each containing a different version of Python and different packages.

````

````{admonition} Version control system
:class: note, dropdown
Version control system **keeps track of changes** in your code. 
It is extremely useful, as it allows for effective collaboration on your code and tracking changes (seeing everything that was modified in the past by you and/or your collaborators) between two **commits**.
The most popular version control system is called <a href="https://git-scm.com/">Git</a>. 
````

````{admonition} Terminal, Command Line Interface (CLI), and Bash Shell
:class: note, dropdown
The Terminal is an application that allows **communication with the operating system** using Command Line Interface (CLI), which is  useful for saving time and automating repetitive tasks.
Unlike applications with graphical user interfaces (GUIs) - which contain buttons, sliders, and other interactive elements (think, e.g., of working on a Word file) - using the terminal requires us to enter lines of code (**commands**) in CLI in order to perform tasks.
These commands are then executed by a **shell**, which is a user interface to the operating system.
Different shells can be used to run commands.
A default shell program used by macOS and Linux is **BASH** (Bourne-Again SHell), while Windows uses PowerShell.

```{figure} images/terminal.png
---
height: 250px
name: terminal
---
Terminal on macOS.
```
````

````{admonition} Large Language Model (LLM)
:class: note, dropdown
**Large Language Models** are advanced **AI (Artificial Intelligence)** models capable of performing a wide range of tasks, including interacting with users by answering their questions, generating text, translating languages, and summarizing information. They are trained on large datasets and can both process and produce natural human language. Well-known examples of LLMs include GPT-5, Claude, and Gemini.
````
