| Starlark | |
|---|---|
| Paradigm | scripting,procedural (imperative)[1] |
| First appeared | 2015; 11 years ago (2015)[2] |
| Typing discipline | Dynamic[1] |
| OS | Cross-platform |
| Filename extensions | .star |
| Website | github |
| Majorimplementations | |
| starlark-go,starlark-rust, | |
| Influenced by | |
| Python[1] | |
Starlark is alightweight,high-levelprogramming language designed forembedded use in applications. It uses a subset of thePython syntax. By default, the code isdeterministic and hermetic.[1]
Starlark was released in 2015 as part ofBazel under the name Skylark.[3] This first implementation was written inJava. In 2018, the language was renamed Starlark.[4]
In 2017, a new implementation of Starlark inGo was announced.[5]
In 2021,Meta announced an implementation of Starlark written inRust,[6] to be used for theBuckbuild system.[7][8]
In addition to the Bazel[9] and Buck build systems, Starlark is used by dozens of projects,[10][11] including Isopod,[12] skycfg,[13] Uber's Starlark Worker,[14] and Tilt.[15]
On GitHub, Starlark is among the top 50 languages based on the developer activity.[16][17]
Starlarksyntax is a strict subset ofPython syntax.[1] Similar toPython syntax, Starlark relies on indentation to delimit blocks, using theoff-side rule.
Starlark'sstatements include:[18]
= statement toassign a value to a variableif statement to execute conditionally a block of code (withelse orelif)for statement to iterate over aniterable objectdef statement to define afunctionbreak statement to exit a loopcontinue statement to skip the rest of the current iteration and continues with the nextpass statement, serving as aNOP, syntactically needed to create an empty code blockreturn statement to return a value from a function.load statement, which replaces Pythonimport, to import a value from anothermodule.[19] Unlike Python, the order of load statements does not affect the semantics of the code.[20]Unlike Python, Starlark statements don't include:while,try,raise,class,with,del,assert,yield,import,match andcase.[21]
To ensurethread safety and supportparallel computing, Starlark has a feature calledfreezing. At the end of the evaluation of a module, all values becomeimmutable. This means that the values that can be accessed from multiplethreads can no longer be modified, which removes the risk ofrace conditions.[3][22]