Live data from Hacker News

Pkl, a Programming Language for Configuration

pkl-lang.org

321–330 of 598 posts

Re: Pkl, a Programming Language for Configuration

#322
post #171

Earlier quoted context omitted.

> This is the real friction point, but is it a bigger friction point than having to adopt yet another DSL? Yesterday, I created a virtualenv, then ran `pip install`, only to see it fail. I found out that even `pip --version` was failing. I discovered that running `python -m ensurepip --upgrade` would fix pip. It did fix pip, but `pip install` still didn't work properly. I figured out that pip was reporting a differen…

Did you activate the virtual environment? For all the flak python gets, dependency setup is pretty simple if you're not flailing around aimlessly python3.12 -m venv --copies --clear --upgrade-deps ".venv" source ".venv/bin/activate" python -m pip install --upgrade pip setuptools wheel python -m pip install --editable .

Yes, I had activated the virtual environment. Thanks for the guide. It works without problems. I had used `virtualenv venv -p /usr/local/bin/python3.12` in my setup. Yours seems to be a better way.

Re: Pkl, a Programming Language for Configuration

#323

Earlier quoted context omitted.

There are three (maybe more?) ways things can be Turing-incomplete: 1. You are limited to N evaluation/reduction steps. 2. The language doesn't include primitives like recursion or loops. 3. You can have recursion or loops, but the language makes you somehow prove that your program will terminate. I think (1) would be fine, but I don't know any configuration languages that use this approach. (2) is restrictive/annoyi…

I think there is another option: 2a. The language includes limited primitives for recursion or loops. If that’s done right, somehow proving that your program will terminate becomes trivial. For example, allowing looping over a previously defined array with (key,value1) pairs to generate many more complex definitions that include common value2, value3, etc fields trivially guarantees termination, but a generic “while”…

See my examples with html un-escaping and mergesort, down the comment chain.

Limited recursion/iteration is ok if all you need is to fill existing values into a template and possibly reduce repetition.

But in a large system with many components I might want to take a single timestamp, parse it, and generate timestamps in five different formats for five different subcomponents.

Or I might want to generate a piece of yaml config for an Ansible playbook that needs it, and now my config language needs to know how to escape yaml strings.

Or a config for a static site generator needs to be able to calculate a hash of a local css file because I’d like to use links like `style.css?hash` (a popular cache-defeating mechanism).

Or a certain path has to be split on “.” and reversed (Java-style com.example.blah things).

Or a Unix path needs to be converted to a Windows path, except [some special-cased paths that live in a map in an adjacent config].

There are endless reasons to want arbitrary logic in my config files, beyond reducing repetition. A lot of things I’ve listed are provided as primitives in various config/templating languages, but you always end up stumbling upon something that’s not provided.

Of course, one could say “You should use a real programming language for this kind of stuff”, and I’m happy that the JavaScript ecosystem is converging on allowing .js/.ts files for configs, because that’s exactly what I want too. But I’d like to have the same features available in projects that aren’t allowed to touch JS.

Re: Pkl, a Programming Language for Configuration

#324
post #203

Is this a reasonable tool to manage problems like: I've got a stream of json in one schema; I want to make ETL for this to write it out to elasticsearch, S3 (in a specific different schema) and postgres targets, using a mixture of "bespoke python", vector, and logstash. Should I use this or should I roll my own goo using ERB or mustache or similar? Or should I quit and go work some place that's using gRPC?

More poking around in this; it'd be great if things like

https://github.com/apple/pkl-pantry

Had more documentation. Like there's a prometheus template; is that for use only in k8?

Re: Pkl, a Programming Language for Configuration

#327
post #320

Earlier quoted context omitted.

Did all the timestamps get reset? Seeing most (all?) comments at about 30min ago

Ah sorry - that was an unintended side-effect of re-upping the original submission. I must have done some of the steps in the wrong order.

You mean you don’t have a distributed merge post microservice that emits post migration events, which are then consumed by a post owner conversion service using your existing event-driven architecture to facilitate seamless data synchronization and user notification processes??? That is not very hacker news of you from the guy who owns hacker news.

Re: Pkl, a Programming Language for Configuration

#328

Earlier quoted context omitted.

I’m also curious, because Graal is pretty exciting stuff, what this might give over Jsonnet or Cuelang. It’s already a hard enough sell to try to get people to adopt these and they are much older and more robust than Pkl.

I'm very wary of anything Java-based, having been burned by Java tooling in the past. I work on a few different Android projects and I have to switch between three different JDK versions depending on which I'm working on. What happened to "write once, run anywhere"?? I really like Pkl's comparison page, which includes its weak points as well! https://pkl-lang.org/main/current/introduction/comparison.ht... Pkl’s nativ…

There are reasons Oracle sued Google over Android and you just articulated one of them.

Re: Pkl, a Programming Language for Configuration

#329
post #5

I was a big believer in Helm for generating Kubernetes resources until I looked up and saw that we had created an impossible-to-validate, impossible-to-reason-about DSL in our values.yaml and that's when I realized we were at the end of our rope with Helm. We switched to Pkl for our Kubernetes resource generation -- it's delightful to maintain and reason about our deployments before execution time :)

Curious if you have experience with terraform/open tofu/hcl for k8s?

Re: Pkl, a Programming Language for Configuration

#330
post #74

Earlier quoted context omitted.

Why assume it's a greenfield project? I would think most open source software that comes out of companies have lived internally for a while before going public?

Additionally I cant think of other such projects from Apple. They tend to build things that get used extensively till the end of their life is consumed. I wish Apple would continue to open source much more. Especially old software much like Microsoft does. I would kind of enjoy a Linux Distro that can natively run old Apple software and tools.

Clang leaps to mind. Most of LLVM was developed under Apple's auspices, although the project predates Apple hiring Chris Latner. Swift is also open source, although in practice it's almost always used in a macOS context. Which I think is a shame, it's a great language for writing the sorts of servers for which people usually reach for Go.

That's not a complete list of programs Apple has open-sourced, although clearly open-source software isn't what they're best known for. But clang alone is a worthy contribution which deserves to be recognized.

Post reply on HN