Befreit von Altlasten.
Das nächste Kapitel der Systemprogrammierung.

Lyx ist nicht nur eine weitere Sprache. Native Linux x86_64, Linux ARM64 und Windows x64 Binaries — ohne libc, ohne Linker, rein über Syscalls und WinAPI.

Schnellstart

Starten Sie mit Lyx in wenigen Minuten.

TERMINAL
# Compiler bauen
make build

# Linux-Programm kompilieren und ausführen
./lyxc examples/hello.lyx -o hello
./hello

# Für Windows kreuzkompilieren
./lyxc examples/hello.lyx -o hello.exe --target=win64

# Debug flags
./lyxc examples/hello.lyx --emit-asm      # IR als Pseudo-Assembler ausgeben
./lyxc examples/hello.lyx --dump-relocs   # Relokationen und Symbole anzeigen
./lyxc examples/hello.lyx --no-opt         # IR-Optimierungen deaktivieren

Ausgabe:

Hello Lyx

Keine LibC.
Keine Kompromisse.

Während andere Sprachen auf riesigen Standard-Bibliotheken aufbauen, spricht Lyx direkt mit dem Linux-Kernel und der Windows API. Cross-Compilation inklusive.

  • Linux x86_64 + ARM64 + Windows x64 Cross-Compilation
  • Direkte Syscall/WinAPI-Kommunikation
  • Vollständiges Module System mit std-Library
  • Minimaler Binary-Footprint (ab 4KB)
Binary Size Complexity
Andere (dynamisch gelinkt) ~800 KB
Lyx (statisch nativ) 4-42 KB

Kreuzkompilierung

Eine Codebasis, sechs Plattformen. Lyx unterstützt Kreuzkompilierung für Linux, Windows, macOS und ESP32.

🐧

Linux x86_64

ELF64-Binary mit SysV ABI. Direkte Syscalls für maximale Leistung.

./lyxc app.lyx -o app
🍎

Linux ARM64

Raspberry Pi, Apple Silicon Linux, Cloud Servers

./lyxc app.lyx -o app --target=arm64
🪟

Windows x64

PE32+-Binary mit Windows-x64-Aufrufkonvention. Shadow Space + IAT.

./lyxc app.lyx -o app.exe --target=win64
🍎

macOS x86_64

Intel Macs, Mach-O binary with BSD syscalls

./lyxc app.lyx -o app --target=macosx64
🍎

macOS ARM64

Apple Silicon Macs, M1/M2/M3 chips

./lyxc app.lyx -o app --target=macos-arm64
📟

ESP32

Xtensa microcontroller, GPIO, UART, built-in syscalls

./lyxc app.lyx -o app.elf --target=esp32
Ziel Format Aufrufkonvention OS-Schnittstelle Status
linux ELF64 SysV ABI (RDI, RSI, RDX, RCX, R8, R9) Syscalls Stable
arm64 ELF64 AAPCS64 (X0-X7) Syscalls Stable
win64 PE32+ Windows x64 (RCX, RDX, R8, R9 + Shadow Space) kernel32.dll Stable
macosx64 Mach-O SysV ABI BSD Syscalls Stable
macos-arm64 Mach-O AAPCS64 BSD Syscalls Stable
esp32 ELF32 Xtensa (A2-A7) GPIO, UART Experimental

Hinweis: Der --target-Parameter ist optional. Der Compiler wählt automatisch das Host-Betriebssystem als Ziel. Der --arch-Parameter ist ebenfalls optional — Architektur wird automatisch vom Target abgeleitet.

Architecture Parameter: --arch

You can also explicitly specify the architecture using --arch:

./lyxc app.lyx -o app --target=macosx64 --arch=x86_64
./lyxc app.lyx -o app --target=macos-arm64 --arch=arm64
./lyxc app.lyx -o app --target=esp32 --arch=xtensa
--arch=x86_64
64-bit x86 (Intel/AMD)
--arch=arm64
64-bit ARM (Apple Silicon)
--arch=xtensa
Xtensa (ESP32)

ARM64-Binaries auf x86_64 testen:

# QEMU installieren
sudo apt install qemu-user-static

# ARM64-Binary ausführen
qemu-aarch64-static ./program

Warum Lyx?

Die Freiheit der Direktheit. In einer Welt, in der moderne Sprachen oft riesige Runtimes und komplexe Abhängigkeiten mit sich schleppen, kehrt Lyx zu den Wurzeln der Systemprogrammierung zurück – ohne den Komfort moderner Syntax opfern zu müssen.

Zero Dependencies

Echte Binär-Autarkie. Die meisten Sprachen verlassen sich auf die C-Standardbibliothek oder externe Linker. Lyx bricht mit dieser Tradition.

  • Direkte ELF64- und PE32+-Generierung
  • Keine libc-Bindung, direkte Syscalls
  • Single-Toolchain: nur lyxc benötigt
🔗

Externe Funktionen

Du bist nicht isoliert. Lyx unterstützt die Einbindung externer Bibliotheken, wenn du sie brauchst.

  • extern fn extern fn für libc/libm Integration
  • Linux .so und Windows .DLL Support
  • PLT/GOT für dynamisches Linking
  • Varargs: printf(fmt, ...)
🔒

Sicherheit durch Typisierung

Lyx ist keine lockere Skriptsprache. Es ist für Systeme gebaut, auf die man sich verlassen muss.

  • Keine impliziten Casts – Fehler im Keim erstickt
  • var, let, co, con Speicherklassen
  • Volle Kontrolle über Veränderbarkeit

Das Beste aus drei Welten

Lyx kombiniert die Stärken etablierter Sprachen zu etwas Neuem.

  • C — C — Die Macht der Systemprogrammierung
  • Rust — Rust — Sicherheitsansätze und strikte Typisierung
  • Pascal — Pascal — Klarheit und Lesbarkeit der Syntax

Datentypen

Vollständiges Typsystem mit strenger Typisierung und ohne implizite Konvertierungen.

Kategorie Typen Beschreibung
Signed Integer int8 int16 int32 int64 Signed 8/16/32/64-bit integers. int = int64
Unsigned Integer uint8 uint16 uint32 uint64 Unsigned 8/16/32/64-bit integers. uint = uint64
Floating Point f32 f64 32-bit and 64-bit IEEE 754 floating point
Pointer pchar pchar? Non-nullable (default) and nullable pointers. pchar = null-terminated string
Boolean bool true / false
Spezial void usize isize Void Rückgabe, unsigned/isigned size_t
Arrays array parallel Array<T> Stack-allocated and SIMD-optimized heap arrays
Map & Set Map<K,V> Set<T> Associative arrays with O(n) lookup
QBool QBool Probabilistic boolean (0.0 to 1.0)
🔄

Typ-Umwandlung

Explizites Casting mit dem as Operator.

var f: f64 := 42 as f64;
var i: int64 := 3.14 as int64;

Nullable Typen

Pointer-Typen können mit ? nullable sein.

var p: pchar? := null;
var q: pchar := p ?? "fallback";

SIMD Arrays

parallel Array für vektorisierte Operationen.

var v: parallel Array<Int64>;
var sum := v + v; // SIMD

Einsatzgebiete

Was kann man mit Lyx entwickeln?

🖥️

Systemprogrammierung

Direkter Hardware-Zugriff, Treiber, Betriebssystem-Komponenten. Volle Kontrolle ohne Abstraktions-Overhead.

☁️

Cloud-Native

Minimale Container-Images, Microservices, Kubernetes-ready. Ultra-kleine Binaries für maximale Dichte.

🔌

Embedded Systeme

Minimaler Footprint ab 4KB, keine Runtime erforderlich. Perfekt für eingeschränkte Umgebungen.

📚

Bildung

Klare, lesbare Syntax inspiriert von Pascal. Perfekt zum Erlernen von Systemprogrammierungs-Konzepten.

MAIN.LYX
import std.math;

type Point = struct {
    x: int64;
    y: int64;
};

fn main(): int64 {
    // Struct literal with fields
    var p: Point := Point { x: 10, y: 20 };
    
    // Pipe operator and standard library
    let result: int64 := -42 |> Abs64();
    
    PrintInt(p.x + result);  // 52
    return 0;
}

Erweiterte Sprach-Features

Leistungsstarke Features für moderne Systemprogrammierung

📊

Global Variables

Declare variables at top-level for global state.

var globalCounter: int64 := 0;
let maxSize: int64 := 1024;

fn increment() {
  globalCounter := globalCounter + 1;
}

Compile-Time Constants

Use con for compile-time constants - no stack allocation.

con LIMIT: int64 := 5;
con MSG: pchar := "Loop\n";

fn main(): int64 {
  while (i < LIMIT) { ... }
}
🎲

QBool - Probabilistic Boolean

Quantum-like boolean type (0.0 to 1.0 probability).

import std.qbool;

var is_rainy: QBool := Maybe(0.7);
var will_stay_home: QBool := QBoolAnd(is_rainy, is_cold);
var decision: bool := Observe(will_stay_home);
🗺️

Maps & Sets

Associative arrays for key-value storage.

var scores: Map<int64, int64> := {1: 100, 2: 200};
scores[3] := 300;
if (1 in scores) { ... }

var ids: Set<int64> := {10, 20, 30};
🔄

Virtual Methods & VMT

OOP with polymorphism via Virtual Method Tables.

type Animal = class {
  virtual fn speak();
};

type Dog = class extends Animal {
  override fn speak() { ... }
};
📝

std.log - Logging

Built-in logging with levels: DEBUG, INFO, WARN, ERROR.

import std.log;

log_info("Starting app...");
log_warn("Low memory");
log_error("Connection failed");
🖥️

std.os - System Functions

OS-level access: process, environment, time, filesystem.

import std.os;

var pid: int64 := get_pid();
var home: pchar := env_get("HOME");
var t: int64 := time_ms();
sleep(100);
🔧

30+ Builtins

No imports needed for common operations.

PrintStr, PrintInt, PrintFloat
Random, RandomSeed
push, pop, len, free
abs, sqrt, sin, cos
StrLength, str_to_int

Compiler-Architektur

Vom Quellcode zum ausführbaren Programm in 8 Stufen

Source (.lyx)
Lexer → Token-Stream
Parser → AST
Sema → Scopes, Types
IR Lowering → 3-Address-Code
IR Optimizer → CSE, DCE, Copy Prop
Inlining → Function Inlining
Backend → Machine Code
Linux x86_64
Linux ARM64
Windows x64
macOS x86_64
macOS ARM64
ESP32
Executable (no libc)
ELF64
Linux x86_64/ARM64
PE32+
Windows x64
Mach-O
macOS x86_64/ARM64
ELF32
ESP32
IR Optimizer
CSE, DCE, Copy Prop
Inlining
Function Inlining

Energy-Aware Optimization

Lyx optimizes for energy efficiency with configurable energy levels and per-function pragmas

CLI Option

--target-energy=<1-5>
1 = Minimal (battery-optimized)
2 = Low
3 = Medium (balanced, default)
4 = High
5 = Extreme (max performance)

Function Pragma

@energy(1)
fn low_power_task() { ... }

@energy(5)
fn hot_path() { ... }
Override energy level per function for mixed workloads

What gets optimized?

Loop Unrolling
1× to 8× based on level
SIMD Usage
Level 3+ enables SIMD
FPU Operations
Level 4+ enables FPU
AVX2/512
Level 5 + CPU support

In-Situ Daten-Visualisierung

Inspiziere beliebige Variablen zur Laufzeit ohne Setup. Ausgabe direkt nach stderr.

Inspect() Demo

Setze Inspect() anywhere in deinen Code für sofortiges Debugging.

debug.lyx
fn main(): int64 {
    var count: int64 := 42;
    var isActive: bool := true;
    var message: pchar := "Hello, Debug!";
    
    // Inspect any variable at runtime
    Inspect(count);      // Outputs to stderr
    Inspect(isActive);
    Inspect(message);
    
    return 0;
}

Ausgabe-Vorschau

So sieht die Inspect() Ausgabe für verschiedene Typen aus:

=== count ===
Type: int64
Value: 42

=== isActive ===
Type: bool
Value: true

=== message ===
Type: pchar
Value: Hello, Debug!

Unterstützte Typen

Inspect erkennt und formatiert automatisch:

int64 int32 uint8 bool pchar f32 f64

Integrierter Linter

10 eingebaute Regeln helfen dir, saubereren und sichereren Code von Anfang an zu schreiben.

CLI Flags

# Linter aktivieren (Standard)
./lyxc program.lyx --lint
# Linter-Warnungen deaktivieren
./lyxc program.lyx --no-lint
# Nur linten, nicht kompilieren
./lyxc program.lyx --lint-only

Lint-Regeln

Der integrierte Linter prüft deinen Code auf häufige Probleme:

1 Unused Variables
2 Type Mismatches
3 Dead Code
4 Naming Conventions
5 Redundant Casts
6 Unsafe Operations
7 Shadowing
8 Missing Returns
9 Constant Comparisons
10 Inefficient Patterns

IR-Level Optimizer

Mehrere Optimierungsdurchläufe erzeugen schnelleren, kleineren Code.

Constant Folding

Wertet konstante Ausdrücke zur Compile-Zeit aus.

x := 2 + 4x := 6

Common Subexpression Elimination

Eliminiert redundante Berechnungen.

a := x + y
b := x + y
reuse

Dead Code Elimination

Entfernt unerreichbaren Code und unbenutzte Funktionen.

if false { dead(); }
removed

Copy Propagation

Ersetzt Kopien durch direkte Wertnutzung.

a := b
c := a
c := b

Strength Reduction

Ersetzt teure durch günstigere Operationen.

x * 2x << 1
x / 2x >> 1

Peephole Optimizer

Lokale Optimierungen: Identity Ops, redundante Moves.

mov rax, rax
removed

Function Inlining

Inliniert kleine Funktionen zur Reduzierung des Call-Overheads.

fn add(a, b: int64): int64 {
return a + b;
}
// becomes:
inlined at call site

Optimierungsergebnis

Kleinerer Code = schnellere Ausführung = weniger Energie

Standard-Bibliothek

Umfassende eingebaute Bibliotheken — keine externen Abhängigkeiten erforderlich.

std.math
Mathematical functions
Abs64, Min64, Max64, Sqrt64, Clamp64, Sign64, Lerp64, Map64, Sin64, Cos64, Hypot64, IsEven, IsOdd, NextPowerOfTwo
std.io
I/O functions
print, PrintLn, PrintIntLn, ExitProc, Printf
std.string
String manipulation
StrLength, StrCharAt, StrFind, StrToLower, StrToUpper, StrConcat, StrReplace
std.env
Environment API
ArgCount, Arg, init
std.time
Date and time
Numerical calculations, timezone support
std.geo
Geolocation
Decimal Degrees, GeoPoint, Distance, BoundingBox
std.fs
Filesystem operations
open, read, write, close, file existence
std.crt
ANSI Terminal
Colors, cursor control
std.pack
Binary serialization
VarInt, int/float/string packing
std.regex
Regex matching
Full regex engine included
std.qbool
Probabilistic Boolean
QBool, Maybe(), Observe(), Entanglement
std.vector
2D Vector library
Vec2
std.list
Collections
StaticList8, StackInt64, QueueInt64, RingBufferVec2
std.rect
Rectangle utilities
Rect
std.color
RGBA Color utilities
Color manipulation

Einfachheit ist das
höchste Maß an Perfektion.

v0.5.0 Feature

OOP — Vollständig

Classes mit Vererbung, Konstruktoren, Destruktoren. Heap-Allokation mit new/dispose. super für Basisklassenaufrufe.

  • class extends für Single Inheritance
  • new ClassName(args) mit Konstruktor
  • dispose obj ruft Destroy()
  • super.method() für Basisklasse
type
Dog = class extends Animal {
breed: pchar;
fn Create(n, b: pchar) {
self.name := n;
self.breed := b;
}
fn speak() {
PrintStr("Woof!\n");
}
};

Cross-Compilation

Linux x86_64, Linux ARM64 und Windows x64 aus einem Codebase. Ein Compiler, drei Plattformen.

Module System

Vollständiges Import/Export mit Standard Library.