# Korr documentation

**Simple to write. Safe to run. Ready to ship.**

Read the first three pages in order; after that, jump to what you need.

### Start here

| Page | What you will learn |
|---|---|
| [1. Introduction](01-introduction.md) | What Korr is for, how it runs your code, strengths, current limitations, how it relates to Rust |
| [2. Installation](02-installation.md) | Every way to install on Linux, macOS and Windows, requirements, editor support, updating, uninstalling, troubleshooting |
| [3. Getting started](03-getting-started.md) | Your first program, the REPL, a full-stack project in 30 seconds, reading errors |

### Guides

| Page | What you will learn |
|---|---|
| [4. Language guide](04-language-guide.md) | Every piece of syntax: variables, types, strings, collections, operators, loops, `match`, functions, structs, errors, modules, type annotations |
| [6. Full-stack web](06-web.md) | Routing, requests and responses, templates, forms, cookies, static files, middleware, testing |
| [7. Databases](07-databases.md) | SQLite, PostgreSQL and MySQL/MariaDB: queries, parameters, transactions, type mapping |
| [8. CLI apps & the `korr` command](08-cli.md) | Command reference, writing tools, `korr test`, `korr build` |
| [9. Packages](09-packages.md) | `korr add`, `korr.json`, `korr.lock`, importing and publishing Git-based packages |

### Reference

| Page | What you will learn |
|---|---|
| [5. Standard library (API)](05-standard-library.md) | Every built-in function and method, and the `math`, `json`, `fs`, `os`, `time`, `encoding`, `crypto`, `html`, `http`, `db`, `log`, `re`, `path`, `csv` modules |
| [11. Security model](11-security.md) | What Korr protects against and what is still your job |
| [14. Node.js vs PHP vs Python vs Korr](14-comparison.md) | Feature-by-feature comparison, design choices, gaps and benchmarks |

### Operations and contributing

| Page | What you will learn |
|---|---|
| [10. Deployment](10-deployment.md) | One executable, configuration, systemd/launchd/Windows services, HTTPS with Caddy or Nginx, scaling, Docker, logs, updates, checklist |
| [12. Building from source](12-building-from-source.md) | Compiling Korr, feature flags, cross-compiling, release automation, source layout |
| [13. Extending Korr with Rust](13-extending-with-rust.md) | Writing native functions and modules |

How Korr works inside (for contributors and the curious): [Korr internals](../internals/README.md).

Project documents: [Roadmap](../../ROADMAP.md) | [Contributing](../../CONTRIBUTING.md) |
[Security policy](../../SECURITY.md) | [Changelog](../../CHANGELOG.md)

## Cheat sheet

```korr
// variables
let x = 1
const NAME = "Korr"

// strings
let greeting = "Hello {NAME}, 1 + 1 = {1 + 1}"

// collections
let xs = [1, 2, 3]
let user = { name: "Ana", tags: ["admin"] }
let squares = [n * n for n in xs if n > 1]

// control flow
for i, v in xs
    if v % 2 == 0
        print("{i}: even")
    else
        print("{i}: odd")

// functions
fn area(w: num, h: num = 1) -> num
    return w * h
let double = fn(n) => n * 2

// match
let size = match len(xs)
    0 => "empty"
    1..=3 => "small"
    _ => "large"

// structs
struct Point
    x: num
    y: num = 0
impl Point
    fn norm(self) => math.sqrt(self.x ** 2 + self.y ** 2)

// errors
try
    xs[10]
catch err
    print(err.kind)          // IndexError

// null safety
let city = user.address?.city ?? "unknown"
```
