Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Classes in Lykn: The Honest Position

Surface Lykn has no class form. Classes are kernel forms available through passthrough (Ch 14). This was deliberate — classes bring this, and surface Lykn eliminates this.

What Surface Lykn Uses Instead

NeedOOP ApproachLykn Approach
EncapsulationPrivate fieldsClosures (Ch 7)
PolymorphismInheritance + overrideMulti-clause func (Ch 8)
Data modelingClass + constructortype + match (Ch 10)
StateInstance fieldscell containers (Ch 13)
Interface contractAbstract classContracts :pre/:post (Ch 8)

When to Use Classes

  • JS interop — a library expects class instances or extends a base class
  • Extending built-ins — custom Error subclasses, HTMLElement for Web Components
  • Framework requirements — some React patterns, some testing frameworks
  • Developer preference — Lykn doesn’t forbid classes, it just provides alternatives

The rest of this chapter teaches classes thoroughly — because you’ll encounter them in every JavaScript library you use. But the recommendation stands: start with type/match. Reach for classes when interop requires it.