Skip to content

What is Starlark?

Starlark is a configuration language designed by Google, originally for Bazel. It features Python-like syntax with deterministic evaluation, making it ideal for build systems and configuration.

Deterministic

Same inputs always produce same outputs. No randomness, no timestamps.

Hermetic

No filesystem, network, or system access. Safe for untrusted code.

Parallel

Modules load concurrently. Immutable data ensures thread safety.

Python-like

Familiar syntax reduces learning curve for Python developers.

# Define data
people = {
"Alice": 22,
"Bob": 40,
"Charlie": 14,
}
# Define a function
def greet(name):
"""Return a greeting."""
return "Hello, {}!".format(name)
# List comprehension
adults = [name for name, age in people.items() if age >= 18]
print(greet(", ".join(adults))) # Hello, Alice, Bob!
Use CaseBenefit
Build systemsReproducible builds via determinism
ConfigurationType-safe, programmable configs
Sandboxed scriptingSafe execution of user code
CI/CD pipelinesConsistent behavior across runs
  • Bazel - Google’s build system
  • Buck2 - Meta’s build system
  • Tilt - Kubernetes development
  • Drone CI - Continuous integration
  • Kurtosis - Development environments
  • ytt - YAML templating

While Starlark looks like Python, key differences ensure determinism:

FeaturePythonStarlark
MutationAllowedFrozen after creation
Global stateYesNo
RecursionYesNo (prevents infinite loops)
while loopsYesNo (use for with ranges)
importYesUse load() instead
ClassesYesNo (use structs)