Skip to content

Implementations

Starlark has three major implementations, each with different strengths. This guide helps you choose the right one for your project.

Featurestarlark-gostarlark-rust (Buck2)starlark-java (Bazel)
LanguageGoRustJava
MaintainerGoogleMetaBazel team
Type annotations✅ Basic✅ Full✅ via Java
record type
enum type
Union types
LSP support
DAP debugging
Static analysis⚠️ Limited✅ Experimental⚠️ WIP
REPL
Profiling

Google’s reference implementation in Go. Best for embedding in Go applications.

Terminal window
go get go.starlark.net/starlark
  • Simple API - Easy to embed in Go projects
  • Stable - Well-tested, production-ready
  • Lightweight - Small binary size
  • Good documentation - Clear examples and guides
  • No advanced type features (records, enums)
  • No built-in LSP or debugging
  • Limited static analysis
package main
import (
"fmt"
"log"
"go.starlark.net/starlark"
)
func main() {
thread := &starlark.Thread{Name: "main"}
globals, err := starlark.ExecFile(thread, "config.star", nil, nil)
if err != nil {
log.Fatal(err)
}
if v, ok := globals["message"]; ok {
fmt.Println(v)
}
}

Meta’s implementation in Rust. Powers Buck2 and has the most advanced type system.

Terminal window
# Add to Cargo.toml
starlark = "0.12"
  • Rich type system - Records, enums, union types
  • Developer tools - Built-in LSP and DAP
  • Performance - Optimized for large codebases
  • Static analysis - Experimental type checking
  • More complex API than Go version
  • Rust ecosystem required
  • Heavier dependency
# Works in starlark-rust
BuildConfig = record(
name = str,
srcs = list[str],
deps = field(list[str], []),
)
Status = enum("debug", "release")
def build(config: BuildConfig, mode: Status) -> str:
return "{}-{}".format(config.name, mode.value)

The starlark-rust LSP provides:

  • Code completion
  • Go to definition
  • Hover documentation
  • Diagnostics
  • Signature help

Bazel’s native implementation. Tightly integrated with the Bazel build system.

  • Bazel integration - Native to Bazel’s rule system
  • Java interop - Easy to add Java-based builtins
  • Mature - Powers Bazel’s entire rule ecosystem
  • Primarily designed for Bazel
  • JVM dependency
  • Less portable than Go/Rust versions
  • Not published as a standalone library (lives inside Bazel’s monorepo)

Bazel is working on static types (Issue #27370):

# Proposed syntax for Bazel static types
def my_rule_impl(ctx: ctx) -> list[Provider]:
...
  • Building a Go application
  • Need simple embedding
  • Want minimal dependencies
  • Targeting lightweight deployments
  • Building with Rust or need best performance
  • Need advanced type features (records, enums)
  • Want built-in LSP/DAP support
  • Building a build system like Buck2
  • Working within Bazel ecosystem
  • Need Java interoperability
  • Building Bazel rules or extensions

All implementations follow the Starlark specification. Language changes are decided at the spec level, not by individual implementations.

To propose new Starlark language features:

  1. Open an issue on bazelbuild/starlark
  2. Discuss with maintainers from all implementations
  3. If accepted, update the specification
  4. Implementations add support

Example: Type annotations were requested via starlark-go #610, but redirected to the spec repo #106 for cross-implementation discussion.