Peefy / KCLVM

A develop branch from KCLVM

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KCL: Constraint-based Record & Functional Language

English | 简体中文

Introduction | Features | What is it for | Installation | Showcase | Documentation | Contributing | Roadmap

Introduction

KCL is an open-source, constraint-based record and functional language that enhances the writing of complex configurations, including those for cloud-native scenarios. With its advanced programming language technology and practices, KCL is dedicated to promoting better modularity, scalability, and stability for configurations. It enables simpler logic writing and offers ease of automation APIs and integration with homegrown systems.

What is it for?

You can use KCL to

Features

  • Easy-to-use: Originated from high-level languages ​​such as Python and Golang, incorporating functional language features with low side-effects.
  • Well-designed: Independent spec-driven syntax, semantics, runtime and system modules design.
  • Quick modeling: Schema-centric configuration types and modular abstraction.
  • Rich capabilities: Configuration with type, logic and policy based on Config, Schema, Lambda, Rule.
  • Stability: Configuration stability is achieved through a static type system, constraints, and rules.
  • Scalability: High scalability is assured with an automatic merge mechanism of isolated config blocks.
  • Fast automation: Gradient automation scheme of CRUD APIs, multilingual SDKs, and language plugin
  • High performance: High compile-time and runtime performance using Rust & C and LLVM, and support compilation to native code and WASM.
  • API affinity: Native support for ecological API specifications such as OpenAPI, Kubernetes CRD, Kubernetes YAML spec.
  • Developer-friendly: Friendly development experiences with rich language tools (Format, Lint, Test, Vet, Doc, etc.), package manage tool and IDE plugins.
  • Safety & maintainable: Domain-oriented, no system-level functions such as native threads and IO, low noise and security risk, easy maintenance and governance.
  • Rich multi-language SDK: Go, Python, andJava meet different scenarios and application use prelude.
  • Integrations: Mutate and validate manifests through Kubectl KCL Plugin, Kustomize KCL Plugin, Helm KCL Plugin or KPT KCL SDK.
  • Production-ready: Widely used in production practices of platform engineering and automation at Ant Group.

How to choose?

The simple answer:

  • YAML is recommended if you need to write structured static K-V or use Kubernetes' native tools.
  • HCL is recommended if you want to use programming language convenience to remove boilerplate with good human readability or if you are already a Terraform user.
  • CUE is recommended if you want to use a type system to improve stability and maintain scalable configurations.
  • KCL is recommended if you want types and modeling like a modern language, scalable configurations, in-house pure functions and rules, and production-ready performance and automation.

A detailed feature and scenario comparison is here.

Installation

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

For more information about installation, please check the Installation Guide on the KCL official website.

Showcase

./samples/kubernetes.k is an example of generating kubernetes manifests.

apiVersion = "apps/v1"
kind = "Deployment"
metadata = {
    name = "nginx"
    labels.app = "nginx"
}
spec = {
    replicas = 3
    selector.matchLabels = metadata.labels
    template.metadata.labels = metadata.labels
    template.spec.containers = [
        {
            name = metadata.name
            image = "${metadata.name}:1.14.2"
            ports = [{ containerPort = 80 }]
        }
    ]
}

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

kcl ./samples/kubernetes.k

YAML output

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

More examples can be found at here.

Documentation

Detailed documentation is available at KCL Website

Contributing

See Developing Guide. You can also get started by opening the project in GitHub Codespaces.

Open in GitHub Codespaces

Roadmap

See KCL Roadmap.

Community

See the community for ways to join us.

About

A develop branch from KCLVM

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

License:Apache License 2.0


Languages

Language:Rust 96.7%Language:LLVM 1.1%Language:C 1.0%Language:Dockerfile 0.3%Language:Go 0.2%Language:Makefile 0.2%Language:Shell 0.2%Language:PowerShell 0.1%Language:AMPL 0.1%Language:Fluent 0.0%Language:Batchfile 0.0%