Apple releases open source programming language 'Pkl' for system configuration



Apple has released Pkl (Pickle), a programming language for creating system configurations, as open source. By writing the configuration in Pkl, you can freely output it in JSON, YAML, Kotlin, Ruby, JavaScript, etc. as needed.

Pkl :: Pkl Docs

https://pkl-lang.org/index.html




apple/pkl: A configuration as code language with rich validation and tooling.
https://github.com/apple/pkl


Static languages such as JSON, YAML, and property lists (plists) are often used to describe system configurations, but they have limited expressive power, cause code to repeat frequently, and do not provide unique validation. Due to this, problems such as syntax errors are likely to occur.

Using auxiliary tools that add special logic to address these problems can generate complex and difficult code over time. On the other hand, a possible solution is to use a general-purpose language such as Kotlin, Ruby, or JavaScript, but since it is a general-purpose language, it is difficult to use it to describe the configuration.

Pkl is a programming language that combines the strength of static languages, which are declarative and easy to read and write, with the features of general-purpose languages such as classes, functions, conditional statements, and loops, making it possible to describe various configurations in an easy-to-understand manner.

For example, consider a Pkl like the one shown below.



Based on the Pkl above, the output in JSON format is as shown below.



On the other hand, if it is in YAML format, it will look like the image below. In this way, the output can be changed flexibly depending on the required format.



In Pkl, if you just define two variables, 'host' and 'port', you can write it simply as shown in the figure below.



It is also possible to output to languages such as Java, Kotlin, Swift, and Go.



Plugins and extensions have been released for IntelliJ, Visual Studio Code, and Neovim, and you can also get input assistance from the IDE.



It also uses a rich type and validation system to detect errors before the application is deployed.



Apple provides 'ready-to-use' samples for ' JVM ,' ' Swift ,' ' Go ,' and ' Kubernetes ' on GitHub, so if you are thinking about using them, please check them out.

in Software, Posted by log1d_ts