PitchHut logo
Like Protobuf, but simpler and more efficient.
Pitch

Skir is a declarative language designed for defining data types, constants, and APIs effortlessly. With a single schema file, generate type-safe code across languages like TypeScript, Python, Java, and more, while ensuring end-to-end type safety. Elevate productivity with seamless integration and powerful features like GitHub imports and safe schema evolution.

Description

Skir is an innovative declarative language crafted for the efficient definition of data types, constants, and APIs. By utilizing a simple .skir file, developers can effortlessly generate idiomatic, type-safe code across multiple languages, including TypeScript, Python, Java, Go, and C++.

Key Features

  • One Schema, Nine Languages, Zero Friction: Define your schema once in a YAML configuration file, run a single command, and benefit from a watch mode that dynamically refreshes the generated code with each change.
  • End-to-End Type Safety: Ensures client/server contracts remain aligned, providing shared method and type definitions that validate before runtime.
  • SkirRPC + Studio: A lightweight HTTP RPC framework complete with a built-in Studio application for method browsing and testing, enhancing the development experience.
  • GitHub Imports: Import types directly from GitHub repositories for sharing data structures seamlessly across projects.
  • Versatile Serialization Modes: Choose between dense JSON for APIs and databases, human-readable JSON for debugging, or binary formats for maximum performance.
  • Safe Schema Evolution: Features built-in checks and established rules that maintain deserializability for both old and new data.
  • Rust-like Enums: Supports variants that can either be constants or carry typed payloads, ensuring clean polymorphism and robust type definitions.
  • Immutable Generated Models: Provides deep immutability (with exceptions for C++) and incorporates required fields at construction time for stronger validation.
  • Key-Indexed Arrays: Define arrays efficiently, for example, [User|user_id], enabling rapid key-based lookup APIs.
  • First-Class Tooling: Equipped with a VS Code extension that includes validation, auto-complete, and auto-formatting capabilities, making the coding process smoother.
  • Easily Extendable: Custom generators can be integrated seamlessly as regular NPM modules, allowing for tailored solutions.

Syntax Example

// shapes.skir

struct Point {
  x: int32;
  y: int32;
  label: string;
}

struct Shape {
  points: [Point];
  /// A short string describing this shape.
  label: string;
}

const TOP_RIGHT_CORNER: Point = {
  x: 600,
  y: 400,
  label: "top-right corner",
};

/// Returns true if no part of the shape's boundary curves inward.
method IsConvex(Shape): bool = 12345;

Skir compiles these definitions into native, type-safe code ready for usage:

# my_project.py

from skirout.shapes_skir import Point  # Generated Python module from Skir

point = Point(x=3, y=4, label="P")

# Round-trip serialization to JSON
point_json = Point.serializer.to_json(point)
restored = Point.serializer.from_json(point_json)

assert(restored == point)

Documentation Resources

Supported Languages

LanguageDocumentationExample
🟦 TypeScriptDocumentationExample
🐍 PythonDocumentationExample
C++DocumentationExample
JavaDocumentationExample
💜 KotlinDocumentationExample
🦀 RustDocumentationExample
🐹 GoDocumentationExample
🎯 DartDocumentationExample
🐦 SwiftDocumentation[Example](https://github.
0 comments

No comments yet.

Sign in to be the first to comment.