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, the standard library, GUI applications, 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, dates and times, expressions, operators, control flow, functions, positional and named variadic parameters, 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, TOML, XML with SAX or DOM, XLSX spreadsheet files, and archive containers with the klyn.io family of packages.

Databases & Entities

Direct SQL access, provider-neutral entity mapping, relational relationships, typed KQL, and entity repositories backed by SQL, XML, JSON, or in-memory data.

GUI

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

Other Libraries

Processes and concurrency, HTTP and TLS networking, scientific computing, and cryptographic primitives for production applications.

Advanced Topics

Dependency injection, structured logging and observability, LLM integration, reflection, automated testing, and KAR/KAB distribution 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, then distinguish local and UTC clocks in Date and Time.
  4. Move through Expressions, Statements, Functions, and Variadic Parameters.
  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, TOML, XML SAX, XML DOM, XLSX, and archives.
  8. Continue with SQL Databases, Entity Engine, relations, typed KQL, and the XML, JSON, and in-memory providers.
  9. Then open the GUI section with Windows GUI Library, Signals vs Events, GUI Themes and KSS, FormLayout, Slider Widget, DatePicker, ColorPicker, File and Folder Dialogs, Fonts and FontDialog, DockWorkspace, TerminalWidget, BrowserWidget, and Canvas and Custom Painting.
  10. Explore the other libraries through processes and concurrency, networking, HTTP, and TLS, math and scientific computing, and cryptography.
  11. Finish the advanced topics with dependency injection, structured logging, LLM API and Agents, Reflection, automated testing, and KAR and KAB Archives.
  12. 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 matching file; when it declares a package, that package must also match the directory path.
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.