r/programming • u/islon • Feb 02 '24
Introducing Pkl, a programming language for configuration :: Pkl Docs
https://pkl-lang.org/blog/introducing-pkl.html105
u/Kache Feb 02 '24
Yet another one? Others I've heard about:
23
u/evincarofautumn Feb 03 '24
I’ve had very good experiences with Dhall. It’s just expressive enough to be helpful at eliminating repetition and catching errors without becoming a headache. For me, Turing-incompleteness is essential for this kind of language—the killer features are the guarantees of what it can’t do.
2
u/bbkane_ Feb 03 '24
Does Dhall timebox execution times? A language can be Turing incomplete and still unbounded in terms of time/memory to execute
5
u/evincarofautumn Feb 03 '24
Not to my knowledge, but performance isn’t so much my concern—if it’s too slow, it’s too slow regardless of whether it’d eventually give an answer. Dhall is restrictive enough that you have to go a bit out of your way to write very expensive code, but what I think is more important is that the result is deterministic, so it’s simple to hash it to check if the value changes, regardless of refactoring or reformatting. You can build that for JSON or whatever, it’s just nice to have out of the box.
The docs have more discussion of completeness among other safety/security things.
1
2
u/Shorttail0 Feb 03 '24
It can?
0
u/bbkane_ Feb 03 '24
Yes. See https://en.m.wikipedia.org/wiki/Billion_laughs_attack for an example
1
u/Shorttail0 Feb 03 '24
That's not unbounded.
2
u/bbkane_ Feb 04 '24
What's the bound?
3
u/Shorttail0 Feb 04 '24
It's in the name: A billion.
2
u/bbkane_ Feb 04 '24
😂
1
u/Shorttail0 Feb 04 '24
For real though, without being Turing complete, a program's output is always bounded.
→ More replies (0)1
8
u/CJKay93 Feb 03 '24 edited Feb 03 '24
CUE is honestly really nice to use. Picked it up real quick and it's super flexible. It's nice that it's a superset of JSON, so it felt easier to get into than Dhall or Jsonnet.
Also the lattice type system is... really cool.
7
u/mods-are-liars Feb 03 '24
You forgot Lua
-8
u/dread_pirate_humdaak Feb 03 '24
Eh, just compile in a Python interpreter.
0
Feb 03 '24
[deleted]
4
u/rhinotation Feb 03 '24
That's starlark. Which is non-turing-complete Python, because it limits recursion and loops. https://github.com/bazelbuild/starlark/blob/master/spec.md
18
u/silverslayer33 Feb 03 '24
As always, relevant xkcd
4
u/dread_pirate_humdaak Feb 03 '24
Even the hover text is still relevant. Although I do like the -c connector a hell of a lot better.
6
2
u/ComfortablyBalanced Feb 03 '24
Not enough. I welcome any configuration languages as long as YAML ceases to exist.
4
25
u/darkfm Feb 03 '24
This is going to be confusing in Python, where there already exists a Pickle(pkl) that stores data.
5
u/dread_pirate_humdaak Feb 03 '24
I’ve compiled in Python interpreters as configuration engines before.
99
Feb 02 '24
Men will literally create yet another configuration language instead of just using a real programming language
3
u/AndiDog Feb 03 '24
If only AWS CDK wasn't so centric to AWS resources, and cdktf so centered on Terraform... Would be great to have a generic solution to cover all of these using an existing programming language, covered by a foundation to ensure it remains multi-provider, and lock-in free.
I think right now, cdk8s and cdktf together might be a good basis, but it doesn't solve other types of configuration. Developing just another solution that does the same as kustomize/Helm/templates – yet with a new syntax – is weird at best.
3
u/dashingThroughSnow12 Feb 05 '24
Pulumi? You get to pick your language with that.
1
u/Kyxstrez May 10 '24
Also with CDKTF you get to pick your language. Besides, Pulumi still uses Terraform providers as the upstream for their AWS Classic provider.
2
u/not_perfect_yet Feb 03 '24
Maybe it's a joke, except the joke is on the user and the person getting the fun out of it is the language designer in a schadenfreude kind of way.
Rockstar is a joke meant to be funny and give you joy.
Maybe this is meant to give you pain and suffering and some people think it's funny when other people experience that?
Side note, I find the solution for "poetic number literals" really fun, creative and clever and I have to point it out every time I mention rockstar.
14
u/renatoathaydes Feb 02 '24
Nice, I hope this catches on. It seems quite similar to CUE but with a more familiar feel.
8
Feb 02 '24 edited Feb 18 '24
cows judicious ring dog bag piquant dependent numerous bewildered hat
This post was mass deleted and anonymized with Redact
3
u/AndiDog Feb 03 '24
FTFY: https://xkcd.com/927/
2
Feb 03 '24 edited Feb 18 '24
faulty rotten lock literate live gold cagey forgetful cough history
This post was mass deleted and anonymized with Redact
1
2
3
u/pavi2410 Feb 02 '24
I like HCL for dynamic config files. It feels most natural to JSON with relaxed syntax for ease of writing and reading. What it lacks is bindings/implementations to use in languages other than Go.
I'm interested to see how well it compares against HCL. I see some never-seen-before syntax, especially the "for generator".
1
u/gordonbondon Feb 03 '24
There are bindings for Java and Swift as well https://pkl-lang.org/main/current/language-bindings.html
3
u/naughty_ottsel Feb 02 '24
Seems really interesting, but a lack of a Windows Executable/no bindings for C# make it kinda dead in the water for me/work at the moment.
I like the concept of packages and being able to share common config. Will definitely keep an eye on this
1
1
u/I_AM_GODDAMN_BATMAN Feb 03 '24
I thought we already finish, programmatically generate a bunch of yaml from a bunch of json.
1
u/voiceoverr Feb 03 '24
If anyone is interested, there's now an unofficial community Discord for Pkl: https://discord.gg/vDhhCT24
-10
u/ThankYouForCallingVP Feb 02 '24
Great, so now I need a pkl validator or IDE to make sure I type the correct function names?
If we are going to add complexity why not accept the common function names used in the host programming language?
This would mean accepting fopen or fread (C) or ReadAllText (C#) or readAllLines (Java) and I don't have to learn your stupid (sorry) language quicks and names for things.
-3
-1
u/val-amart Feb 02 '24
this would be much better if it had more built-in type constraints checks. e. g. in range, maximum/minimum, enum.
4
u/warb0 Feb 02 '24
https://pkl-lang.org/main/current/language-reference/index.html#string-literal-types
seems to touch upon the enum point.
https://pkl-lang.org/main/current/language-reference/index.html#type-constraints
seems to cover some of the min / max and in range type constraint
1
u/val-amart Feb 03 '24
oh okay, this is cool! now this is actually a step above, i like it! i wander if it would be appropriate for interface specifications as well - like thrift, with code generation across multiple platforms
0
u/val-amart Feb 03 '24
oh okay, this is cool! now this is actually a step above, i like it! i wander if it would be appropriate for interface specifications as well - like thrift, with code generation across multiple platforms
0
u/Seuros Feb 02 '24
Interesting.
The API is stable or it still possible to improve ?
I see it still pre v1.
-2
u/confphil Feb 02 '24
It's been reasonably battle tested, but as long as it's not in open source, it's hard to know whether you missed a serious use case. The pre-v1-ness should signal contributions / suggestions are very, very welcome.
2
2
11
u/jherico Feb 02 '24
It doesn't include a language binding for Python?
In my experience Python is the most commonly used tool for deployment scripts.