Examples

A few features worth trying on their own — see Language Docs for the fuller reference.

Pattern matching over strings

A match expression with literal, comma-separated, and regex patterns — no if/else if chain required, and the compiler requires a wildcard _ arm so there's always a fallback.

string Classify(string input) {
  return match input {
    "cat", "dog" => "animal",
    r"^[0-9]+$" => "number",
    _ => "unknown"
  };
}

print(Classify("dog"));    // animal
print(Classify("42"));     // number
print(Classify("???"));    // unknown

String interpolation

No string concatenation soup — $"..." embeds real expressions directly, and they can be arbitrarily complex, not just bare variable names.

string name = "Ada";
number age = 36;
print($"{name} is {age + 1} next year");

Interfaces, including interface inheritance

A class can implement any number of interfaces alongside at most one base class, all in one colon-separated list — the compiler figures out which name is which. Interfaces can extend other interfaces too.

interface IShape {
  number Area();
}

interface INamedShape : IShape {
  string Name();
}

class Square : INamedShape {
  private number Side;
  constructor(number side) { this.Side = side; }
  public number Area() { return this.Side * this.Side; }
  public string Name() { return "Square"; }
}

Array stdlib: Map, Filter, Push

A small PascalCase standard library on arrays, taking lambdas or any other function-valued expression. Push is the one deliberate departure from JS — non-mutating, returning a new array instead of mutating in place, for consistency with Map/Filter.

number[] xs = [1, 2, 3, 4];
string[] labels = xs.Map((number x) => "n" + x);      // ["n1", "n2", "n3", "n4"]
number[] evens = xs.Filter((number x) => x % 2 == 0);  // [2, 4]
number[] grown = xs.Push(5);                           // [1, 2, 3, 4, 5]; xs itself is untouched

Real closures

Lambdas capture their enclosing scope by reference and compile directly to JS arrow functions — mutating a captured variable from inside a lambda is visible to the code that captured it, exactly like closures work in JS.

number count = 0;
() => number next = () => { count = count + 1; return count; };
print(next()); // 1
print(next()); // 2

Enums

Numbered from 0 in declaration order, compiling to a frozen JS object.

enum Color { Red, Green, Blue }

Color c = Color.Green;
if (c == Color.Green) { print("It's green"); }

Want to see the language and the framework working together in a real, running app? The Home page's counter is real Kopular source, not a mockup. The Dogs page goes further — a real dynamic route (/dogs/:id), a real form with live validation (FormField<T>/Validators), and two real Http.Get calls to a public API (dog.ceo) — a breed dropdown populated live from its full breed list, and an actual photo fetched for whichever one you pick. The Notes page rounds it out — a real template from page actually rendering with *for/*if (not just described in a code sample), a real Http.Post, and a route gated behind Router.SetGuard. The Nested components page demonstrates VElement.Mount — each row in its list is its own independent, addable/removable Component, not a plain element the parent builds by hand.