possible-fqz / KCLVM

A constraint-based record & functional language mainly used in configuration and policy scenarios.

Home Page:https://kusionstack.io/docs/reference/lang/lang/tour

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KCL

license Continuous Integration

中文

Kusion Configuration Language (KCL) is an open source configuration language mainly used in Kusion Stack. KCL is a statically typed language for configuration and policy scenarios, based on concepts such as declarative and Object-Oriented Programming (OOP) paradigms.

Core Features

  • Simple
    • Originated from Python and Golang, incorporating functional language features.
    • Absorbs integrated language elements such as statements, expressions, conditions, loops, etc.
    • Type and data separation, schema declaration configuration definition.
  • Stable
    • Strong immutable constraint.
    • Compile-time type deduction, type checking.
    • Rule policy definition: attribute-centric constraint expressions, query results based on constraints.
    • Testable: assert, print, and test tools.
  • Scalable
    • Configuration unification: compile-time configuration dependency graph substitution.
    • Configuration attribute operators: meet the needs of configuration override, merge, add and delete, etc.
    • Configuration reuse: rich built-in data structures and syntax semantics, easily to expand one configuration of different scenarios.
  • Engineering
    • Schema single inheritance and declarative model reuse and assembly.
    • Tool & API granular configuration automation.
    • Rich built-in functions and system libraries.
    • Top-level dynamic data input.
    • Code organization: modules and packages.
    • Plug-in system: reuse common programming language ecology.
    • OpenAPI model support: Swagger and KCL schema bidirectional conversion, Kubernetes CRD conversion to KCL schema.
  • High Performance
    • Works with the LLVM optimizer, supports compilation to native code and formats like WASM and executes efficiently.

Installing & Documentation

How to install

Download the latest release from GitHub and add {install-location}/kclvm/bin to environment PATH.

Quick Showcase

./samples/fib.k is an example of calculating the Fibonacci sequence.

schema Fib:
    n1: int = n - 1
    n2: int = n1 - 1
    n: int
    value: int

    if n <= 1:
        value = 1
    elif n == 2:
        value = 1
    else:
        value = Fib {n: n1}.value + Fib {n: n2}.value

fib8 = Fib {n: 8}.value

We can execute the following command to get a YAML output.

kcl ./samples/fib.k

YAML output

fib8: 21

Documentation

Detailed documentation is available at https://kusionstack.io

Developing & Contributing

Developing

See Developing Guide.

Roadmap

See KCLVM Roadmap

License

Apache License Version 2.0

About

A constraint-based record & functional language mainly used in configuration and policy scenarios.

https://kusionstack.io/docs/reference/lang/lang/tour

License:Apache License 2.0


Languages

Language:Rust 69.6%Language:C 19.7%Language:C++ 7.0%Language:LLVM 1.1%Language:Go 1.1%Language:Shell 0.6%Language:Makefile 0.4%Language:SWIG 0.2%Language:Dockerfile 0.2%Language:Batchfile 0.1%Language:NSIS 0.0%Language:AMPL 0.0%Language:Fluent 0.0%