Starlark is an [[Apache v2]] licensed configuration language written in [[Python]].
- Website
- [GitHub](https://github.com/bazelbuild/starlark)
- Documentation
> Starlark (formerly known as Skylark) is a language intended for use as a configuration language. It was designed for the [Bazel](https://bazel.build/) build system, but may be useful for other projects as well.
> ...
> Starlark is a dialect of [Python](https://www.python.org/). Like Python, it is a dynamically typed language with high-level data types, first-class functions with lexical scope, and garbage collection.
# Notability
Appears to be a Python-like DSL for [[UCL]]-like configuration.
# Philosophy
> Starlark was designed at Google to replace Python as the build description language.
> ...
> The differences with Python stem from different [design principles](https://github.com/bazelbuild/starlark/blob/master/README.md#design-principles). This page documents some of the choices we made.
\- [Starlark Design Doc](https://github.com/bazelbuild/starlark/blob/master/design.md)
# Implementations
- Python only
# Features
# Example
```starlark
# Define a number
number = 18
# Define a dictionary
people = {
"Alice": 22,
"Bob": 40,
"Charlie": 55,
"Dave": 14,
}
names = ", ".join(people.keys()) # Alice, Bob, Charlie, Dave
# Define a function
def greet(name):
"""Return a greeting."""
return "Hello {}!".format(name)
greeting = greet(names)
above30 = [name for name, age in people.items() if age >= 30]
print("{} people are above 30.".format(len(above30)))
def fizz_buzz(n):
"""Print Fizz Buzz numbers from 1 to n."""
for i in range(1, n + 1):
s = ""
if i % 3 == 0:
s += "Fizz"
if i % 5 == 0:
s += "Buzz"
print(s if s else i)
fizz_buzz(20)
```
# Tips
# References