Skip to content
项目

关于

Incan: a modern, Pythonic language that compiles to Rust! Type-safe, async-friendly, with fixtures, testing, and web/inter-op built in.

编程语言与运行时

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Incan

Python-like readability. Rust-native performance.

Website · Docs · Install · The Book · Discussions · LinkedIn

CI status Latest release Documentation License Project status: beta

Incan is a statically typed language for writing clear, high-level application code that compiles to native code through the Rust compiler. It aims to feel lightweight and expressive while keeping the things that matter in large codebases explicit: types, errors, and mutability.

The current toolchain is designed to be easy to install, try, inspect, and diagnose without cloning the compiler repository first.

Getting started

To use Incan 0.6, get the incan executable and toolchain.tar.zst archive from the same build for your host. For a published release, download the matching toolchain.tar.zst.sigstore.json and keep it beside the archive. Put the downloaded incan first on PATH before installing the toolchain.

rustup toolchain install 1.98.0 --profile minimal --component rustc-dev
incan toolchain install ./toolchain.tar.zst
export PATH="${INCAN_HOME:-$HOME/.incan}/bin:$PATH"
incan --version

For host prerequisites, installation in a separate INCAN_HOME, and development checkout setup, see Install and run Incan.

Create loaf.toml, src/main.incn and tests/test_main.incn as the Getting started tutorial shows, then check, run, test and build the project. Every command takes an explicit path:

incan check src/main.incn
incan run src/main.incn
incan test tests/test_main.incn
incan build src/main.incn --profile release

Tooling and inspection

The current toolchain includes these public surfaces for installation, first contact, diagnostics, and inspection:

  • Toolchain installation through a host-specific archive and the pinned Rust compiler.
  • Project loop through incan check, incan run, incan test, and incan build, each with an explicit path. oven runs the same project operations.
  • Stable diagnostics through incan check --format json and incan explain <CODE>.
  • Build inputs and reuse through oven describe-unit PATH, which reports the selected compilation inputs, and OVEN_TRACE=-, which reports executable reuse decisions.
  • Codegraph export through incan inspect codegraph --format jsonl, with compiler-backed files, modules, declarations, imports, exports, references, calls, diagnostics, spans, provenance, and degraded-state records.
  • Boundary parity hardening across local, imported, re-exported, package, test-batch, and vocab/tooling paths.

Read the CLI reference for detailed command contracts, or the 0.6 release notes for release-specific change history.

These examples show the inspection commands most useful when evaluating a project:

incan check src/main.incn --format json
incan explain INCAN-T0001
oven describe-unit src/main.incn
incan inspect codegraph src --format jsonl

Positioning

Python won because it made application code readable and fast to write. Incan starts from that same readability premise, but changes the foundation: static types, explicit errors, explicit mutability, and Rust-native compilation.

Incan is not a Python compatibility runtime or a faster Python interpreter. It is for new application code where teams want Python-like ergonomics without Python's runtime, packaging, and deployment tradeoffs.

As AI tools generate more code, those constraints matter more. Incan gives developers and agents a smaller, typed, auditable language surface that compiles into the Rust ecosystem.

Why Incan?

  • Readable by default: concise syntax for modeling data and writing “glue code” without ceremony.
  • Explicit error handling: Result, Option, and ? keep failure paths visible and reviewable.
  • Strong domain types: newtype and model make invariants and intent first-class.
  • Deterministic composition: traits are for behavior contracts and predictable composition.
  • Rust interop when you need it: call into Rust crates for ecosystems and performance-sensitive utilities.
  • Native performance: the compiler builds a native binary through the pinned Rust compiler.

Who is this for?

  • If you like the readability of Python but want stronger correctness tools and predictable performance, Incan is aimed at that workflow.
  • If you like Rust but want a smaller surface syntax for everyday application code, Incan is built to stay close to Rust semantics while reducing boilerplate.
  • If you like TypeScript or JavaScript tooling but want native binaries and Rust-backed execution for application code, Incan should feel familiar in its focus on typed APIs, editor feedback, and installable command-line tooling.

Choose your path

Status

⚠️ Beta Software ⚠️
Incan is in active development. The language, compiler, and APIs may still change, although we will try to keep it stable as much as possible.
Feedback and contributions are of course welcome!

Docs policy: Stability policy

A small example

enum AppError:
    InvalidInput(str)

type Email = newtype str:
    def from_str(v: str) -> Result[Email, AppError]:
        if "@" not in v:
            return Err(AppError.InvalidInput("missing @"))
        return Ok(Email(v.lower()))

@derive(Debug, Eq, Clone)
model User:
    id: int
    email: Email
    is_active: bool = true

trait Loggable:
    def log(self, msg: str) -> None:
        println(f"[{self.name}] {msg}")

class UserService with Loggable:
    name: str
    users: Dict[int, User]

    def create(mut self, email_str: str) -> Result[User, AppError]:
        email = Email.from_str(email_str)?
        user = User(id=len(self.users) + 1, email=email)
        self.users[user.id] = user
        self.log(f"created user {user.id}")
        return Ok(user)

Documentation

The docs site is published at incan.io; its source lives in workspaces/docs-site/.

Build/serve locally:

make docs
make -C workspaces/docs-site docs-serve

Performance

Incan compiles to a native binary through the Rust compiler, so Rust is the meaningful reference point: on these workloads Incan runs within roughly 20% of hand-written Rust, and matches or beats it on some. Python is included for scale, not as the target.

  • Benchmarks: workspaces/benchmarks/
  • Results: workspaces/benchmarks/results/results.md
Benchmark Incan Rust Python Incan vs Rust
Fibonacci (1M iterations) 3ms 4ms 42ms ~1×
Collatz (1M numbers) 94ms 92ms 4,209ms 1.02×
GCD (10M pairs) 92ms 84ms 819ms 1.10×
Mandelbrot (2K×2K) 113ms 113ms 4,655ms 1.00×
N-Body (500K steps) 20ms 17ms 1,507ms 1.18×
Prime Sieve (50M) 141ms 124ms 3,163ms 1.14×
Quicksort (1M elements) 56ms 48ms 1,000ms 1.17×
Mergesort (1M elements) 83ms 130ms 1,300ms 0.64×

A ratio below 1.00× means Incan is faster than the hand-written Rust implementation of the same algorithm; Mergesort is the clear case. Fibonacci runs in single-digit milliseconds, where a one-millisecond difference is measurement noise rather than a meaningful gap, so it is reported as approximately even.

Benchmark details:

  • Machine: Apple Silicon (results may vary)
  • Incan/Rust: Release builds with optimizations
  • Python: CPython 3.14
  • Methodology: hyperfine with warmup runs
  • Reproduce: make benchmarks (add SKIP_PYTHON=true for Incan vs Rust only)

Community

Contributing

Contributions are welcome—docs, compiler, tooling, stdlib, and RFC work.

License

Apache 2.0

探索相关项目

加载中…