| Starlark | |
|---|---|
| Paradigm | scripting, procedural (imperative) |
| First appeared | 2015 |
| Typing discipline | Dynamic |
| OS | Cross-platform |
| Filename extensions | .star |
| Website | github |
| Major implementations | |
| starlark-go, starlark-rust, | |
| Influenced by | |
| Python | |
Starlark is a lightweight, high-level programming language designed for embedded use in applications. It uses a subset of the Python syntax. By default, the code is deterministic and hermetic[further explanation needed].
Starlark was released in 2015 as part of Bazel under the name Skylark. This first implementation was written in Java. In 2018, the language was renamed Starlark.
In 2017, a new implementation of Starlark in Go was announced.
In 2021, Meta announced an implementation of Starlark written in Rust, to be used for the Buck build system.
In addition to the Bazel and Buck build systems, Starlark is used by dozens of projects, including Isopod, skycfg, Uber's Starlark Worker, and Tilt.
On GitHub, Starlark is among the top 50 languages based on the developer activity.
Starlark syntax is a strict subset of Python syntax. Similar to Python syntax, Starlark relies on indentation to delimit blocks, using the off-side rule.
Starlark's statements include:
= statement to assign a value to a variableif statement to execute conditionally a block of code (with else or elif)for statement to iterate over an iterable objectdef statement to define a functionbreak statement to exit a loopcontinue statement to skip the rest of the current iteration and continues with the nextpass statement, serving as a NOP, syntactically needed to create an empty code blockreturn statement to return a value from a function.load statement, which replaces Python import, to import a value from another module. Unlike Python, the order of load statements does not affect the semantics of the code.Unlike Python, Starlark statements don't include: while, try, raise, class, with, del, assert, yield, import, match and case.
To ensure thread safety and support parallel computing, Starlark has a feature called freezing. At the end of the evaluation of a module, all values become immutable. This means that the values that can be accessed from multiple threads can no longer be modified, which removes the risk of race conditions.