PitchHut logo
Like Protobuf, without the pain
Pitch

Skir is a powerful declarative language that shares the same goals as Protobuf but does a few things better, for example: polymorphism (via Rust-like enums), GitHub imports, built-in compatibility checks, a first-in-class DX.

Description

Skir is a modern declarative language designed for defining data types, constants, and APIs, providing a streamlined alternative to Protocol Buffers. By utilizing a .skir file for schema definitions, users can generate idiomatic, type-safe code across multiple programming languages such as TypeScript, Python, Java, Go, C++, and more.

Key Features

  • One schema, nine languages, zero friction: Create a single YAML configuration, execute one command, and utilize a watch mode that automatically refreshes generated code upon changes.
  • End-to-end type safety: Maintain alignment of client/server contracts through shared method and type definitions prior to runtime.
  • SkirRPC + Studio: Access a lightweight HTTP RPC along with a built-in Studio application for method browsing and testing.
  • GitHub imports: Import types directly from GitHub repositories, facilitating the seamless sharing of data structures across different projects.
  • Serialization modes: Support various serialization formats including dense JSON for APIs/databases, human-readable JSON for debugging, and binary formats for optimal performance.
  • Safe schema evolution: Ensure backward compatibility with built-in checks and clearly defined rules for deserialization.
  • Rust-like enums: Employ variants that can be constants or carry typed payloads, promoting clean polymorphism.
  • Immutable generated models: Achieve deep immutability (except in C++), necessitating required fields during construction.
  • Key-indexed arrays: Easily declare arrays, enabling fast key-based lookup APIs with syntax like [User|user_id].
  • First-class tooling: Leverage a VS Code extension and Language Server Protocol (LSP) support for validation, autocompletion, and formatting.
  • Easy to extend: Integrate custom generators into the workflow as they are regular NPM modules.

Syntax Example

Below is a simple example of a schema definition in 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;

The above definitions compile into native, type-safe code that can be utilized in various projects. For example, in Python:

# my_project.py
from skirout.shapes_skir import Point  # Python module generated by 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)

Supported Languages

Skir supports various programming languages with comprehensive documentation and examples:

LanguageDocumentationExample
🟦 TypeScriptDocumentationExample
🐍 PythonDocumentationExample
⚡ C++DocumentationExample
☕ JavaDocumentationExample
💜 KotlinDocumentationExample
🦀 RustDocumentationExample
🐹 GoDocumentationExample
🎯 DartDocumentationExample
🐦 SwiftDocumentationExample

For more detailed information about getting started, refer to the documentation.
Explore Skir for an efficient and type-safe approach to data definition and serialization.

0 comments

No comments yet.

Sign in to be the first to comment.