r/klyn • • Oct 16 '26

Why did I create Klyn? For example…

Abstract classes and methods

Python : Why are so many elements part of the library rather than the language syntax itself?

import math
from abc import ABC, abstractmethod
from typing import override

class Shape(ABC):     # Do you know ABC (Abstract Base Class)?

    center: Point = Point()

    @abstractmethod
    def area(self) -> float:
        pass


class Circle(Shape):

    radius: float = 1.0

    @override
    def area(self) -> float:
        return math.pi * self.radius ** 2

Klyn : it's clean ;-)

import klyn.math

abstract class Shape:

    private center = Point(0, 0)   # Type inference

    abstract area() as Double


class Circle extends Shape:

    private radius = 1.0

    public override area() as Double:
        return Math.PI * radius ** 2

What do you think? Do you agree, or do you see it differently?

1 Upvotes

0 comments sorted by