Apple said in a blog post: We're excited to announce the first open source release of Pkl (pronounced pickle), a programming language for creating configurations. When we think of configuration, we typically think of static languages like JSON, YAML, and property lists. Although these languages have their own advantages, they tend to fall short when the composition becomes complex. For example, a lack of expressiveness results in code that is often repeated. Additionally, these formats do not provide their own validation and are therefore more prone to configuration errors. To address these shortcomings, the format is sometimes enhanced by auxiliary tools that add special logic. For example, if your code needs to be more DRY, special properties are introduced to understand how to resolve references and merge objects. Alternatively, validation errors need to be prevented, so new methods are created to validate configuration values against expected types. Over time, these formats become almost programming languages, but they are difficult to understand and write.
Conversely, a general-purpose language may be used instead. Languages such as Kotlin, Ruby, and JavaScript are the basis for DSLs that generate configuration data. Although these languages are very powerful, they can be unwieldy to use for writing configuration because they are not centered around data definition and validation. Additionally, these DSLs tend to be tied into their own ecosystems. Using Kotlin DSL as a configuration layer for applications written in Go is difficult. We created his Pkl because we believe configuration can best be expressed as a combination of a static language and a general-purpose programming language. We want to have the best of both worlds. It provides a language that is declarative and easy to read and write, yet enhanced with features borrowed from general-purpose languages. When writing Pkl, you can use expected language features such as classes, functions, conditionals, and loops. You can build abstraction layers and share your code by creating and publishing packages. Most importantly, you can use Pkl to meet different types of configuration needs. You can use it to create static configuration files in any format or embed them as libraries in another application runtime.
We designed Pkl with three overarching goals.
Ensure safety by detecting validation errors before deployment.
Scale from simple to complex use cases.
Best-in-class IDE integration makes writing fun.