Official tutorial Language syntax Static typing

# Klyn Tutorial

This tutorial is meant to teach Klyn as a language, not just to list keywords. It starts with source-file rules and builds progressively toward classes, generics, exceptions, and reflection. Use it as the main path when you want to become productive in Klyn.

What This Tutorial Covers

### Foundations

Running scripts, understanding file structure, indentation, comments, packages, imports, and Klyn coding conventions.

### Core Syntax

Typing, expressions, operators, control flow, functions, collection literals, and iteration.

### Types and OOP

Classes, constructors, properties, inheritance, interfaces, enums, annotations, and generics, plus typed exceptions and resource safety.

### File Handling

Text files, folders, CSV, JSON, XML with SAX or DOM, XLSX spreadsheet files, and archive containers with the `klyn.io` family of packages.

### GUI

Native desktop applications, signals and events, KSS themes, forms, sliders, date input, dockable workspaces, terminal tabs, embedded HTML content, and custom painting with `Canvas`.

### Advanced Topics

SQL database access, ORM entity mapping, LLM integration, KAR/KAB distribution, and reflection for larger codebases.

Recommended Reading Order

1. Start with Getting Started.
2. Read Lexical Structure, Packages and Imports, Class Loading, and Coding Conventions before writing multi-file code.
3. Learn the typing model in Typing and Constants before relying on inference everywhere.
4. Move through Expressions, Statements, and Functions.
5. Once the procedural part is clear, continue with Classes, Properties, and Inheritance.
6. After Generics, finish the type model with Exceptions.
7. Then learn file work with klyn.io files, CSV, JSON, XML SAX, XML DOM, XLSX, and archives.
8. Then open the GUI section with Windows GUI Library, Signals vs Events, GUI Themes and KSS, FormLayout, Slider Widget, DatePicker, DockWorkspace, TerminalWidget, BrowserWidget, and Canvas and Custom Painting.
9. Finish the advanced topics with SQL Database Access, ORM and Entities, LLM API and Agents, Reflection, and KAR and KAB Archives.
10. Use Code Examples at the end when you want runnable samples that connect several tutorial topics.

What Klyn Feels Like
Readable surface syntax

    import klyn.math

    const LIMIT as Int = 3

    def classify(value as Int) as String:
        return "small" if value < LIMIT else "large"

    value = Int(Random.random() * 10)
    print(classify(value))

Structured object model

    class Counter:
        public property current as Int = 0

        public tick() as Void:
            this.current++

    counter = Counter()
    counter.tick()
    print(counter.current)

Non-Negotiable Language Rules
Read this before writing real code

- Klyn is always typed. Inference helps you write less, but values do not become dynamically typed later.
- Only the package `klyn` is imported automatically. Any other package or qualified type must be imported explicitly.
- Imports belong at module level. Do not import from inside a function or a class.
- Blocks start after `:` and use spaces. Tabs are rejected.
- A public top-level type must live in a file whose name and package path match the type.

Next Step

Continue with Getting Started if you want your first runnable Klyn program, or jump to Typing and Constants if you already know the execution model and want the language rules first.