Comparison

Configuration is often described in a static configuration format or is generated with a general-purpose programming language. This page lists shortcomings of these approaches and explains how Pkl addresses them. Also, Pkl’s strong and weak points in comparison to other configuration languages are discussed in this document.

Pkl vs. Static Config Formats

Static configuration formats such as JSON, YAML, TOML, and XML work reasonably well for simple configuration needs. However, they do have some shortcomings, including:

  1. They are not very human-friendly to read and write. (JSON, XML)

  2. They do not provide a way to split a large file into multiple smaller ones. (JSON, YAML, TOML)

  3. They offer no way or very limited ways to abstract over repetitive configuration. (JSON, YAML, TOML, XML)

  4. They do not offer standardized or widely available schema validators. (JSON, YAML, TOML)

  5. They offer little or no schema-aware tooling. (JSON, YAML, TOML)

Pkl addresses these shortcomings as follows:

  1. It has a clutter-free and familiar syntax with nestable comments.

  2. Modules can import other modules from local and remote locations.

  3. Every object can act as a template for other objects. The standard library offers strong support for data manipulation.

  4. It has strong built-in support for describing and validating configuration schemas.

  5. It is designed to enable schema-aware tooling, such as REPLs and editors with code completion support.

Pkl vs. General-purpose Languages

When configuration needs outgrow the capabilities of static configuration formats, projects often turn to generate configuration with a general-purpose programming language such as Python. Given enough effort, this approach can satisfy complex configuration needs. However, expressing configuration in a full-blown programming language does have some shortcomings, including:

  1. Reading, writing, and debugging configuration can become as challenging as reading, writing, and debugging application code.

  2. The host language may not be a good fit for describing, manipulating, and abstracting over hierarchical configuration.

  3. Configuration code may not visually resemble the configuration it generates.

  4. The host language may not be a good fit for defining and validating configuration schemas.

  5. Development environments may offer little help for developing and validating configuration written in the host language.

  6. General-purpose languages are powerful and often difficult to sandbox. Are you certain your configuration script isn’t erasing your hard disk or launching a rocket?

Pkl addresses these shortcomings as follows:

  1. As an expression-oriented and side-effect free language, it eliminates many potential sources of errors.

  2. It is specifically designed for describing, manipulating, and abstracting over hierarchical configuration.

  3. Pkl code often resembles the configuration it generates.

  4. It has strong built-in support for defining and validating configuration schemas.

  5. It is designed to enable advanced and schema-aware tooling.

  6. It is comparatively powerless and strictly sandboxed, making fatal configuration mistakes and exploits less likely. Till now, we haven’t spotted any Pkl script capable of erasing your hard disk.

Pkl vs. Other Config Languages

Compared to open-source configuration languages such as Jsonnet, HCL, and Dhall, Pkl’s strong points are:

General
  • Pkl has a clean and familiar syntax, which makes it easier to read and learn.

  • Pkl supports writing sophisticated schemas, which enables config validation, code and documentation generation, and advanced IDE support. This is Pkl’s most significant differentiator, and is the main reason why we created it.

  • Pkl has stronger templating capabilities than other config languages, reducing user code to the absolute minimum.

Embedding
  • Pkl is great for embedding into JVM applications.

  • Pkl offers modern JVM libraries for runtime application configuration.

  • Pkl supports code generation to enable statically typed access to configuration from programming languages.

  • Pkl integrates with third-party (Spring Boot) JVM libraries and frameworks.

Tooling
  • Pkl has a polished documentation generator that produces highly navigable and searchable documentation.

  • Pkl offers a Gradle plugin to easily integrate code evaluation, documentation generation, and code generation into your builds.

  • Pkl’s native executables have a JIT compiler that can speed up evaluation up to hundred times.

On the other hand, we believe that Pkl’s weak points are:

  • Pkl’s native binaries are larger than those of other config languages.

  • Pkl is less known and has a smaller community than some other config languages.

We are working towards making Pkl overcome these weakness. Please support us in reaching this goal!

We hope that you will enjoy Pkl, and that you trust us to gradually improve its weak points.