Code Examples
Klyn distributions include a samples directory with runnable examples. Use these
programs to explore the standard library, the terminal GUI layer, database access, and larger
application structure before starting your own project.
From a source checkout, examples are available in the repository-level samples
directory. Packaged Linux installations also install them under the Klyn home directory.
cd samples
klyn gui/Calculator.kn
When an example spans several files, launch its main file from the sample directory or use the path shown below. Klyn will resolve dependencies through its normal class-loading rules.
Examples are grouped with the same high-level categories and order as the tutorial sidebar. Each card tag shows the category it belongs to.
Core Syntax
MegaGame
Core SyntaxA larger sample entry point intended to exercise application-level composition and reusable language-level building blocks.
klyn samples/MegaGame.kn
File Handling
Export XLSX
File HandlingCreates an XLSX workbook with a people directory, a second activity worksheet, and a line chart based on the exported monthly values.
klyn samples/io/ExportXLSX.kn
GUI
Calculator
GUIA compact graphical application showing event handling, widgets, and simple interaction patterns.
klyn samples/gui/Calculator.kn
Speed Demo Window
GUI
A custom speedometer widget built with Canvas, gradients, antialiased
painting, sliders, and value-change events.
klyn samples/gui/SpeedDemoWindow.kn
Clock Sample
GUI
An analog clock implemented as a custom Canvas widget. It combines gradients,
antialiased painting, time-based geometry, and a GUI Timer that repaints once
per second.
klyn samples/gui/ClockSample.kn
Slider Demo
GUIShows slider variants: filled track, ticks, values, vertical orientation, and live value tooltip during pointer drag.
klyn samples/gui/DemoSlider.kn
Login Form
GUI
A MariaDB-backed login window using FormLayout, password input, default-button
behavior, buddies, and prepared statements.
klyn samples/gui/LoginForm.kn
TUI
Breakout
TUIA multi-file terminal game. It is useful for understanding how a larger Klyn sample is split into several classes and views.
klyn samples/Breakout/Breakout.kn
Terminal Resize
TUIFocuses on terminal resize behavior and is useful when validating layout and event-loop behavior on a new platform.
klyn samples/TerminalResize.kn
Advanced Topics
SQL Login
Advanced Topics
A console MariaDB login flow using DriverManager, try-with-resources, and a
prepared update statement.
klyn samples/sql/Login.kn
ORM Sample
Advanced TopicsDemonstrates the object-relational mapping layer and the shape of database-oriented Klyn code. It may require a configured database environment.
klyn samples/ORMSample.kn
LLM
Advanced TopicsExercises the language-level LLM helpers. This sample normally requires provider configuration and valid credentials.
klyn samples/llm.kn
Financial
Advanced TopicsShows an LLM-backed financial agent sample and is a good place to inspect how domain logic can be combined with agent-style helpers.
klyn samples/Financial.kn
Continue with Lexical Structure to understand the source rules used by these examples, or open API Reference while reading their imports.