Starlark
Paradigmscripting, procedural (imperative)
First appeared2015; 9 years ago (2015)
Typing disciplineDynamic
OSCross-platform
Filename extensions.star
Websitegithub.com/bazelbuild/starlark/
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.[1]

History

edit

Starlark was released in 2015 as part of Bazel under the name Skylark[2]. This first implementation was written in Java. In 2018, the language was renamed Starlark[3].

In 2017, a new implementation of Starlark in Go was announced.[4]

In 2021, Meta announced an implementation of Starlark written in Rust[5], to be used for the Buck build system[6][7].

Popularity

edit

In addition to the Bazel and Buck build systems, Starlark is used by dozens of projects[8], including Isopod[9], and skycfg[10].

On GitHub, Starlark is among the top 50 languages based on the developer activity.[11][12]

Syntax

edit

Similar to Python syntax, Starlark syntax relies on indentation to delimit blocks.

Statements and control flow

edit

Starlark's statements include:

  • The = statement to assign a value to a variable
  • The augmented assignment statements to modify a variable
  • The if statement to execute conditionally a block of code (with else or elif)
  • The for statement to iterate over an iterable object
  • The def statement to define a function
  • The break statement to exit a loop
  • The continue statement to skip the rest of the current iteration and continues with the next
  • The pass statement, serving as a NOP, syntactically needed to create an empty code block
  • The return statement to return a value from a function.
  • The load statement, which replaces Python import, to import a value from another module.

Unlike Python, Starlark statements don't include: while, try, raise, class, with, del, assert, yield, import, match and case.

Freezing

edit

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. So the values that can be accessed from multiple threads can no longer be modified. This removes the risk of race conditions.[13]

See also

edit

References

edit
  1. ^ "starlark/spec.md at master · bazelbuild/starlark". GitHub.
  2. ^ "A glimpse of the design of Skylark". blog.bazel.build.
  3. ^ "Starlark". blog.bazel.build.
  4. ^ Donovan, Alan (18 November 2017). A Go implementation of the Skylark Configuration Language. GothamGo 2017 – via YouTube.
  5. ^ Mitchell, Neil (8 April 2021). "The Rust Starlark library".
  6. ^ "Meta open-sources 'significantly faster' build system". InfoWorld.
  7. ^ "5 Things you didn't know about Buck2". 23 October 2023.
  8. ^ "Starlark Programming Language". starlark-lang.org.
  9. ^ Xu, Charles; Ilyevskiy, Dmitry (2019). Isopod: An expressive DSL for Kubernetes configuration. Proceedings of the ACM Symposium on Cloud Computing.
  10. ^ Norton, Peter (2019). "Other Faces of Python" (PDF). login Usenix Mag. 44 (2).
  11. ^ "Global Metrics: Programming Languages". Innovation Graph. GitHub.
  12. ^ https://tjpalmer.github.io/languish/
  13. ^ "starlark/spec.md at master · bazelbuild/starlark". GitHub.