Closed Peefy closed 5 months ago
We can combine the first and second solutions. Step 1: Migrate the stack virtual machine of python kclvm to rust. Step 2: After ensuring availability, then we can implement a transpiler from python bytecode to wasm.
We need to study these pre-dependencies:
Or we can take a different approach and allow KCL to run as a standalone server,client communicate via HTTP or gRPC.
Thank you! @reckless-huang ❤️
This is a great suggestion. Actually, we have already built a KCL server for interacting with external systems, and you can see here https://kcl-lang.io/docs/reference/xlang-api/rest-api and view a list of all HTTP/gRPC functions, including the ListOptions
API. But the kcl server will include both the kcl compiler and runtime, especially LLVM, which results in a larger binary size. The main purpose of this issue is to track lighter clients without LLVM, and it is expected to reduce the size by at least half.
Problems
python3 -m pip install kclvm
. The kclvm trust also needs to be compiledcargo install kclvm
, installed and run through cargo install (convenient for integration by other two party and three party applications).Design
Design 1
Migrate KCLVM python's stack virtual machine to Rust.
Pros.
Cons.
Design 2
Just like rego (https://github.com/open-policy-agent/opa), cadence (https://github.com/onflow/cadence), and wa (https://github.com/wa-lang/wa), write a WASM codegen adaptation layer, and the executive layer uses the industry's mature WASM virtual machine, such as wasmtime (https://github.com/bytecodealliance/wasmtime).
Pros
Cons
Transition Plan
Just like
libtaichi.dylib
in the taichi repo (https://github.com/taichi-dev/taichi), package the KCLVM rust core library into the pip packagepython3 -m pip install kclvm
or go package for installationgo get kclvm-go
.