The biggest advantage is IDE integration.
You can type port = 42
and instantly be told, right there as you edit the file, that you entered an invalid value (port has to be at least 4 digits). It will also flag prot = 4242
as invalid — catching the typo. That’s a real advantage - just last week I took a server offline by making a human error in a config file. The server just didn’t respond to network requests after the change was applied and it was part of a larger deployment… so it took time to find the mistake. Catching mistakes early is a good thing.
The second big advnatage is integrated documentation - for a lot of work you won’t need to read the manual in a web browser. You can just jump into the config file, hover your mouse over something, and know how it works.
It has other strengths, but those are the big two. Probably the third is it’s just a nice language to read and write (plenty of other options share that, but it’s hardly universal).
I looked through the yaml example a bit. It looks pretty rough.
Some of those examples are unnecessarily complex to demonstrate rarely used features. I like this example better:
amends "service.pkl"
host = "example.org"
port = 4242
The only slightly ugly thing is the amends line, which defines a second config file that defines rules about how to properly configure this one. In that case it’s a path to a file on disk, but it could also be a URL such as https://pkl.apache /virtualhost
if apache were to switch to this format for VirtualHost config files. If you don’t need to import rules for use case, it’s an optional feature (though it is the main advantage pkl has over other alternatives).
As far as I know the only widely used config format with support for strict rules is XML, but XML is so complex that almost nobody can actually get IDE integration working. The rules are just too complex. Pkl is simple, these properties need to exist, they have these types (text, number, etc) and these restrictions (minimum 4 digits, etc).