ztcl

Modern Tcl for the AI era. ztcl is an alternative implementation of Tcl in Zig, built to be the fastest and most complete one. It runs Tcl 9.1 scripts, and Tcl 8.6 scripts with --tcl 8.6, with exact compute and memory limits, a JIT compiler that is on by default, real threads, microVM isolation, and a WebAssembly build for the browser. The current release is 1.0.0-beta.1.

Docs: https://beetlebug.org/ztcl/ · Playground: https://beetlebug.org/ztcl/playground/

Coming, each in an open issue: the isolation levels wasm and vm-confidential for threads (#209), ztcl as a host of wasm modules (#202), and https and an HTTP/2 server (#27).

Install

brew install beetlebugorg/tap/ztcl     # macOS and Linux
npm install @beetlebug/ztcl            # WebAssembly, for the browser and Node.js

Install has the release binaries and the build from source.

Example

proc fib {n} {
    if {$n < 2} { return $n }
    expr {[fib [expr {$n - 1}]] + [fib [expr {$n - 2}]]}
}
puts [fib 20]
Live
$ ztcl fib.tcl
6765
$ ztcl --compute 1000 fib.tcl
fib.tcl:2: compute limit reached

Documentation

Status

ztcl is experimental, and its APIs can change in any release. It passes 38,054 of the 47,133 tests of the Tcl 8.6.16 suite, so it is not yet a drop-in replacement for Tcl. The code and the docs were written largely with AI coding agents, under human direction. Review the code before you depend on it. The issues and the milestones have the roadmap.

Contact

Write to opensource@beetlebug.org about ztcl. Open an issue for a bug or a request, and report a security problem as SECURITY.md says.

License

BSD-2-Clause. See LICENSE. References credits Tcl and the other sources.