Introducing Pkl: Apple's New Configuration-as-Code Language

Introducing Pkl: Apple's New Configuration-as-Code Language

If you haven't yet checked out Pkl (pronounced "Pickle"), it's time to take a look at this innovative open-source configuration-as-code language from Apple. Designed to blend the best of static and general-purpose programming languages, Pkl offers a powerful and flexible way to handle configurations.

What is Pkl?

Pkl is an open-source language programmed in Java, specifically designed for writing configurations in a programmable manner. This means that with Pkl, you can create configurations that are not only concise and validated but also capable of handling complex use cases.

Key Features

  • Rich Language Constructs: Pkl includes all the constructs you'd expect from a full-fledged programming language, such as functions, loops, classes, and more. This makes it incredibly versatile and powerful.
  • Build Pipeline Integration: You can integrate Pkl into your build pipeline to validate and generate configurations in your favorite formats like JSON, plist, and .properties files.
  • Multi-language Bindings: Currently, Pkl has bindings for Swift, Java, Kotlin, and Go. More bindings can be created, allowing Pkl to generate code in different languages based on its defined schema.
  • Package Management: Just like NPM, Pkl allows you to create and share packages across different projects, enhancing reusability and collaboration.

Native vs. JVM Versions

Interestingly, the Pkl documentation recommends using a native version instead of a JVM version. For those unfamiliar, a native version compiles Java bytecode to machine code, bypassing the need for a JVM at runtime. While this approach has its own pros and cons, it's an intriguing aspect that could be the topic of another post.

Installation and Tooling

Pkl comes with a Read-Eval-Print Loop (REPL) for experimenting and learning. For code editor support, Pkl currently integrates with IntelliJ, VS Code, and Neovim. I tried installing the VS Code plugin, and while it's a bit manual (you have to download and install the latest Visual Studio Extension (.vsix) file yourself), it's straightforward enough.

Final Thoughts

Pkl represents a significant step forward in the realm of configuration-as-code. By making configurations more programmable and manageable, Pkl stands to benefit the entire tech ecosystem. Whether you're looking to streamline your build processes or enhance the flexibility of your configurations, Pkl is definitely worth exploring.

You can learn more about Pkl and start experimenting with it by visiting their official website.


To view or add a comment, sign in

More articles by Asad Khan

Insights from the community

Others also viewed

Explore topics