Draft:Starlark
{{AFC submission|d|nn|u=LLB|ns=118|decliner=Caleb Stanford|declinets=20250323042158|ts=20250218182822}}
{{AFC submission|d|nn|u=LLB|ns=118|decliner=Ktkvtsh|declinets=20241208233109|small=yes|ts=20241208232917}}
{{AFC comment|1=Topic may be notable! Article looks like a reasonable start. Just a couple things: please fix the missing inline citations. Please add citations to the infobox. Caleb Stanford (talk) 04:21, 23 March 2025 (UTC)}}
----
{{Short description|Lightweight programming language}}
{{Draft topics|software|computing|technology}}
{{AfC topic|stem}}
{{Use dmy dates|date=February 2021}}
{{Infobox programming language
| name = Starlark
| paradigm = scripting, procedural (imperative)
| year = {{Start date and age|2015|df=yes}}
| typing = Dynamic{{Cite web|url=https://github.com/bazelbuild/starlark/blob/master/spec.md#overview|title=starlark/spec.md at master · bazelbuild/starlark|website=GitHub}}
| implementations = [https://github.com/google/starlark-go starlark-go], [https://github.com/facebook/starlark-rust starlark-rust],
| influenced by = Python
| operating system = Cross-platform
| website = {{URL|https://github.com/bazelbuild/starlark/}}
| file ext = .star
}}
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.
History
Starlark was released in 2015 as part of Bazel under the name Skylark{{Cite web|url=https://blog.bazel.build/2017/03/21/design-of-skylark.html|title=A glimpse of the design of Skylark|website=blog.bazel.build}}. This first implementation was written in Java. In 2018, the language was renamed Starlark.{{Cite web|url=https://blog.bazel.build/2018/08/17/starlark.html|title=Starlark|website=blog.bazel.build}}
In 2017, a new implementation of Starlark in Go was announced.{{cite AV media | last = Donovan | first = Alan | title = A Go implementation of the Skylark Configuration Language | url = https://www.youtube.com/watch?v=9P_YKVhncWI | publisher = GothamGo 2017 | date = 18 November 2017|via=YouTube}}
In 2021, Meta announced an implementation of Starlark written in Rust,{{Cite web|url=https://developers.facebook.com/blog/post/2021/04/08/rust-starlark-library/|title=The Rust Starlark library|last=Mitchell | first=Neil|date=2021-04-08}} to be used for the Buck build system.{{Cite web|url=https://www.infoworld.com/article/2338301/meta-open-sources-significantly-faster-build-system.html|title=Meta open-sources 'significantly faster' build system|website=InfoWorld}}{{Cite web|url=https://engineering.fb.com/2023/10/23/developer-tools/5-things-you-didnt-know-about-buck2/|title=5 Things you didn't know about Buck2|date=23 October 2023}}
Popularity
In addition to the Bazel{{cite book |last1=Antoniucci |first1=Javier |title=Ultimate Monorepo and Bazel for Building Apps at Scale: Level up Your Large-Scale Application Development with Monorepo and Bazel for Enhanced Productivity, Scalability, and Integration (English Edition) |date=2024 |publisher=Orange Education PVT Ltd |isbn=9788197223914 |edition=1st}} and Buck build systems, Starlark is used by dozens of projects,{{Cite web|url=https://starlark-lang.org/resources.html#users|title=Starlark Programming Language|website=starlark-lang.org}}{{cite web |last1=Pandey |first1=Mohit |title=Starlark is Basically Python, But Not Really Python, and That's Fine |url=https://analyticsindiamag.com/developers-corner/starlark-is-basically-python-but-not-really-python-and-thats-fine/ |website=AIM |date=12 December 2024 |access-date=13 December 2024}} including Isopod{{cite conference|last1 = Xu|first1 = Charles|last2 = Ilyevskiy | first2 = Dmitry|title = Isopod: An expressive DSL for Kubernetes configuration|conference = Proceedings of the ACM Symposium on Cloud Computing|year = 2019| doi=10.1145/3357223.3365759 |url = https://dl.acm.org/doi/abs/10.1145/3357223.3365759}}, skycfg{{cite journal|last = Norton|first = Peter|title = Other Faces of Python|journal = Login Usenix Mag.|volume = 44|issue = 2|year = 2019|url = https://www.usenix.org/system/files/login/articles/login_summer19_09_norton.pdf}}, and Tilt.{{cite book |last1=Sayfan |first1=Gigi |title=Hands-on microservices with Kubernetes: build, deploy, and manage scalable microservices on Kubernetes |date=2019 |publisher=Packt Publishing |isbn=9781789809732 |pages=353 |edition=1st}}
On GitHub, Starlark is among the top 50 languages based on the developer activity.{{cite web|title=Global Metrics: Programming Languages|url=https://innovationgraph.github.com/global-metrics/programming-languages|website = Innovation Graph|publisher = GitHub}}{{cite web | url=https://tjpalmer.github.io/languish/ | title=Languish - Programming Language Trends }}
Syntax
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.
=Statements and control flow=
Starlark's statements include:{{Cite web|url=https://github.com/bazelbuild/starlark/blob/master/spec.md#statements|title=starlark/spec.md at master · bazelbuild/starlark|website=GitHub}}
- 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 (withelse
orelif
) - 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 Pythonimport
, to import a value from another module.{{Cite web|url=https://github.com/bazelbuild/starlark/blob/master/spec.md#load-statements|title=starlark/spec.md at master · bazelbuild/starlark|website=GitHub}} Unlike Python, the order of load statements does not affect the semantics of the code.{{cite web |last1=Le Brun |first1=Laurent |title=A practical introduction to the Starlark language |url=https://laurent.le-brun.eu/blog/a-practical-introduction-to-the-starlark-language |access-date=24 March 2025 |language=en |date=December 2024}}
Unlike Python, Starlark statements don't include: while
, try
, raise
, class
, with
, del
, assert
, yield
, import
, match
and case
.{{Cite web|url=https://github.com/bazelbuild/starlark/blob/master/spec.md#lexical-elements|title=starlark/spec.md at master · bazelbuild/starlark|website=GitHub}}
Freezing
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.{{Cite web|url=https://github.com/bazelbuild/starlark/blob/master/spec.md#freezing-a-value|title=starlark/spec.md at master · bazelbuild/starlark|website=GitHub}}
See also
{{Portal|Computer programming}}
References
{{reflist}}
{{Programming languages}}
{{Draft categories|
:Category:Programming languages