Connect with us

News

Apple has released the Pkl programming language for configurations

Developers created Pkl because they believe that configuration is best shown as a blend between a static language and a general-purpose programming language.

Apple has announced the first release of Pkl (pronounced Pickle), a programming language for creating configurations.

When we think of configuration, we usually think of static languages such as JSON, YAML, or property lists. While these languages have their merits, they tend to fall short when the configuration becomes more complex. For example, the lack of expressiveness of these languages results in code that is often repetitive. In addition, it is easy to make mistakes in the configuration because these formats do not provide any validation.

To address these shortcomings, formats are sometimes augmented with auxiliary tools that add specialised logic. For example, it may be necessary to make the code more logical, so a special property is introduced that understands how to resolve references and merge objects. Or you need to guard against validation errors, so a new way is created to check the configuration value against the expected type. Soon these formats become almost programming languages, but ones that are hard to understand and hard to write.

At the other end of the spectrum, a general purpose language can be used instead. Languages such as Kotlin, Ruby, or JavaScript become the basis for DSLs that generate configuration data. While these languages have tremendous capabilities, they can be awkward to use to describe configuration because they are not focused on defining and validating data. In addition, these DSLs tend to be tied to their own ecosystems. It’s hard to sell a Kotlin DSL as a configuration layer for an application written in Go.

Developers created Pkl because they believe that configuration is best shown as a blend between a static language and a general-purpose programming language. They want to take the best of both worlds; provide a language that is declarative and easy to read and write, but enhanced with features borrowed from general-purpose languages. When writing Pkl you can use familiar language features such as classes, functions, conditions and loops. You can create levels of abstraction and share code by creating packages and publishing them. Most importantly, Pkl can be used for a variety of configuration tasks. You can use it to create static configuration files in any format or embed it as a library in another application’s runtime environment.

Pkl was developed with three main goals:

  • To provide safety by catching validation errors before deployment.
  • To scale from simple to complex use-cases.
  • To be a joy to write, with best-in-class IDE integrations.

Features:

  • Generate any static configuration formats. Define all your data in Pkl and generate output for JSON, YAML, property lists and other configuration formats.
  • Integrated application configuration. Embed Pkl into your applications for rantime configuration and get code generation for Java, Kotlin, Swift and Go.
  • Incredible IDE integration. A great toolkit for writing Pkl with the same ease as statically typed languages. There are plugins and extensions for IntelliJ, Visual Studio Code and Neovim, and Language Server Protocol support is coming soon.
  • Catch bugs before deployment. With rich type checking and validation, you can catch configuration errors before you deploy your application.

You can learn more about the language on the official website.

Advertisement

Trending