Pkl; Cue; KISS
Two Drops today! This one, which makes up for the time-crunch-skipped one from earlier in the week, and the WPE.
TL;DR
This is an AI-generated summary of today’s edition.
- Apple introduces Pkl, a new “configuration-as-code” language with features like variables, conditionals, and loops, designed to reduce repetitive boilerplate code in configuration files. It supports packages, called “pantries,” and has editor support for IntelliJ, VSCode, and Neovim. Examples for Java, Go, Swift, and Kubernetes are provided, but a tool to convert existing YAML/JSON to Pkl is missing.
- Google’s Cue, another configuration language, is designed to simplify defining and validating data, with a focus on Kubernetes and Terraform. Cue is a superset of JSON, making it easier to learn, and it can convert existing JSON and YAML files into Cue specifications. Cue and Pkl both offer advanced data validation and schema definition, but Pkl adds object-oriented features like classes and inheritance.
- A Golang-based utility,
yamltojson, is mentioned as a simpler alternative for converting YAML to JSON and vice versa, suggesting that sometimes simpler tools may be sufficient for configuration tasks without the need for more complex programming components.
Pkl

As if we didn’t already have enough configuration “languages” to make life miserable across diverse projects, Apple enters the fray with Pkl. This is (as we’ll see) another “configuration-as-code” language + tooling pair vs. traditional, “static” configuration language + tooling such as JSON, YAML, or good ol’ INI files (though there are some aspects of YAML that also give it code-execution powers). That’s right, Pkl has full language features like variables, conditionals, and loops, which are designed to help us avoid repetitive boilerplate code.
It also groks that configuration files need to be valid, so there’s full support for defining rules and testing configurations out, which is handy in a CI/CD context.
While there’s a full, standalone, and robust CLI tool for working with Pkl files, it is also a library with multi-language support, and can be embedded in virtually any framework/app.
Because it’s a language, it supports the use of packages, which can be sourced from any URL with that houses a consistent directory structure. These are called “pantries” (of course they are), and Apple’s core pantry sources are oddly on GitHub. Apple also has many Pkl-oriented project repositories y’all can explore.
There is also nascent editor support for Pkl files (presently IntelliJ, VSCode, and Neovim). And, Apple has some examples for Java, Go, Swift, and Kubernetes which you can peruse to see how various Pkl bits translate to formats you are likely more familiar with.
A glaring “miss” from my perspective is a “turn this existing YAML/JSON/etc. into Pkl” bit of tooling (there is some of this if you read through the various pantry offerings and the language examples referenced in the previous paragraph).
Cue

Google’s Configuration Language, Cue (GH), is yet-another language + tool pair for defining and using data constraints. It, like Pkl, is designed to simplify tasks involving defining and validating data (which include configuration files). With Cue, we can define a schema with constraints, which can then be used to validate data against that schema. It was really designed with Kubernetes and Terraform in mind (likely one reason Apple provided k8’s examples with Pkl). Unlike Apple, Google understood folks already have quite a bit of information to keep in their noggins, so they made Cue a superset of JSON vs. design a new, special, crunchy language syntax we need to learn.
In terms of features, both Cue’s ecosystem and Pkl offer advanced data validation capabilities and the ability to define schemas with constraints. However, Pkl introduces object-oriented features like classes and inheritance, which are not a part of Cue’s more functional approach. Pkl also emphasizes integration with IDEs (oddly lacking direct support in Apple’s own Xcode) and aims to be a polyglot config solution, supporting multiple programming languages out of the gate.
Because Cue has been around for a little longer, it has out-of-the gate support for ingesting existing JSON, YAML (etc.) files and turning them into Cue specifications. So, if you’re just looking to escape YAML hades, you might be better off working with Cue, for now.
If you’re not familiar with Cue at all, there’s a handy Cuetorial.
We’re not showing how to use either, since I cannot see why one would need either bit of tooling. We’ve covered many configuration languages and conversion tools across these 400+ Drops, and some like Jsonnet have been around for nearly a decade and accomplish the same tasks (and, may be able to do more given their age).
Keep It Simple, Sir!

I realize both Cue and Pkl have bigger scopes in mind, sometimes all you need is the ability to go from something sane-ish (JSON) to insane (YAML), and back. While we’ve covered many tools like that, one ~4-year-old one is a Golang-based utility dubbed yamltojson. It’s a simple install, can convert a single file, or entire directory, and works everywhere. And, perhaps, leave the programming components to the full-on languages?
FIN
Remember, you can follow and interact with the full text of The Daily Drop’s free posts on Mastodon via @dailydrop.hrbrmstr.dev@dailydrop.hrbrmstr.dev ☮️
Leave a reply to hackcaster Cancel reply