News for hackers. Stuff that matters.
Re:KCL, a constraint-based functional language for configura... by hosh on Monday August 05, 2024 @02:42PM (#41164083)
There was that other long thread about using a general purpose language to generate Kubernetes manifests. However, just looking at this briefly, this may have all the features I care about from general-purpose languages.

Although it looks like it is a better replacement for HCL (Terraform), I'm thinking this may end up working better than Helm.

Re:KCL, a constraint-based functional language for configura... by hbogert on Monday August 05, 2024 @04:51PM (#41165486)
Have you seen timoni? it ticks all my boxes. It uses cuelang which admittedly is a steeper learning curve, but o boi, its conceptual model is so nice once it 'clicks'

https://timoni.sh/

Re:KCL, a constraint-based functional language for configura... by hosh on Monday August 05, 2024 @06:44PM (#41166298)
I have not.

However, looking at it now, it falls into the same problems all template generators have. Those are things solved by using general purpose languages generate rather than templating manifests.

KCL is in the middle ground. The Ruby mixins I can use for manifest generation can has an equivalence with KCL's union.

I can see Timoni's appeal as it looks like an improvement over Helm and integrates building artifacts.

Re:KCL, a constraint-based functional language for configura... by hbogert on Thursday August 08, 2024 @03:21PM (#41195214)
Oh, now I'm eager to now why you think KCL is middle ground, but cuelang and timoni are not. What is inherent to KCL that is so powerful that you can not due in CUE?
Re:KCL, a constraint-based functional language for configura... by aliasxneo on Monday August 05, 2024 @05:17PM (#41165701)
We've been using Timoni in production for six months now. What a breath of fresh air (and sanity) coming from Helm. It's not perfect, but I'll take immature imperfections (that are improving by the month) over the YAML/Go templating nightmare that is Helm.
Re:KCL, a constraint-based functional language for configura... by evanjrowley on Monday August 05, 2024 @03:17PM (#41164457)
How does this compare with Nickel?
Re:KCL, a constraint-based functional language for configura... by kirmerzlikin on Monday August 05, 2024 @05:27PM (#41165779)
Here's what KCL authors say about it themselves

https://www.kcl-lang.io/docs/user_docs/getting-started/intro...

Re:KCL, a constraint-based functional language for configura... by jeffrallen on Monday August 05, 2024 @03:19PM (#41164488)
Re:KCL, a constraint-based functional language for configura... by from-nibly on Monday August 05, 2024 @03:29PM (#41164581)
> KCL's automatic merge mechanism for isolated configuration blocks promotes high scalability.

This part scares me a bit. How does it merge? In cuelang, everything has to agree otherwise it's an error. If KCL has a situation where one file can override another, I'm out. That gets way too hairy way too fast.

Edit:

    data0 = {id: 1} | {id: 2}  # Error:conflicting values between {'id': 2} and {'id': 1}
    data1 = {id: 1} | {id = 2}  # Ok, the value of `data` is {"id": 2}
There are the foot guns
Re:KCL, a constraint-based functional language for configura... by drdaeman on Monday August 05, 2024 @03:50PM (#41164843)
nixpkgs.lib has mkDefault/mkForce/mkOverride system (which I'm not a fond of because of the poor type system, but at least it works) that feels like a better approach than this weirdness.
Re:KCL, a constraint-based functional language for configura... by yjftsjthsd-h on Monday August 05, 2024 @07:47PM (#41166633)
ansible has what I think is a sort of similar system, where a role can define default values for its variables but they can be overridden in a fairly deep hierarchy of successive priorities; it helps that the lowest tier is literally labeled "defaults" so you automatically expect it to be overwritten, though in the upper layers I still have to look up to see which thing takes precedence.
Re:KCL, a constraint-based functional language for configura... by soraminazuki on Tuesday August 06, 2024 @06:04PM (#41175894)
The merging behavior of Nixpkgs modules are much simpler. It doesn't have orders or complex priority rules that depend on where an option is defined. Options have types, which also specifies the merging behavior. Merging of collection types just work.
Re:KCL, a constraint-based functional language for configura... by soraminazuki on Tuesday August 06, 2024 @07:05AM (#41169646)
The Nixpkgs module system that you're describing does have types though. The whole purpose of that system is to attach types and documentation to data.
Re:KCL, a constraint-based functional language for configura... by drdaeman on Tuesday August 06, 2024 @01:10PM (#41172862)
Unless I'm misunderstanding how it all works, it's just attrsets underneath. Like JSON objects with some semantics given to them - and those (and their YAML counterparts) are not exactly great. In particular, I believe (I could be wrong here) this results in sometimes hard-to-understand error traces if something gets messed up.
Re:KCL, a constraint-based functional language for configura... by soraminazuki on Tuesday August 06, 2024 @05:38PM (#41175659)
The module system type checks each attribute in a attrset. It merges all modules, ensures there are no conflicts, type checks and returns the resulting attrset. Error messages indicate the offending option definition along with its location in the case of conflicts or type errors, which should be enough for enough for debugging.
Re:KCL, a constraint-based functional language for configura... by drdaeman on Tuesday August 06, 2024 @10:29PM (#41177690)
I vaguely remember shooting myself in my foot by doing some weird stuff with deep attrset transformations, where I managed to screw-up those "special" attrsets by making a mistake in a function that tried to build module options dynamically from another "transplant" module's options. Surely, that was weird stuff, and sadly I don't have a history of what exactly I did back then (it was couple years ago), but I remember having to introspect with Nix REPL to understand where I messed up.

I would've loved it more if Nix had ability to create custom types, ideally GADTs. Tagged attrsets work for sure, but a better type system would've probably made things easier and nicer.

Re:KCL, a constraint-based functional language for configura... by aliasxneo on Monday August 05, 2024 @05:15PM (#41165685)
This seems to be a feature to some people. They must exclusively work on tiny, compartmentalized projects. Otherwise, I don't understand the allure. We use CUE a lot, and when I teach people about this particular constraint (only one concrete value is allowed), they get frustrated, as if the alternative is better.
Re:KCL, a constraint-based functional language for configura... by patrick451 on Monday August 05, 2024 @06:13PM (#41166098)
What do you mean `{id = 2}` ?

The ROS parameter system does automatic overwriting of values. You end up with different subsystems loading different param files in the parameter server, with each one overwriting values from the last one. It is a complete nightmare.

Re:KCL, a constraint-based functional language for configura... by lmpdev on Monday August 05, 2024 @09:20PM (#41167062)
Hahaha oh my lord

State will always err… find a way

Re:KCL, a constraint-based functional language for configura... by peefy on Tuesday August 06, 2024 @03:52AM (#41168696)
Multiple configuration merging strategies do not imply inconsistency or uncertainty, nor do they mean that one file can overwrite or patch another.

KCL also provides a certain degree of immutability, such as ensuring that exported variables are immutable and that configurations in a file cannot be modified. You can only import it and use it to generate new configurations.

In addition, in the cloud native field such as Kubernetes, configuration merging operations can be seen everywhere, such as the built-in JsonMergePatch strategy, Kustomize, and multiple environment configurations for developers. You can find similar corresponding features in KCL.

In fact, KCL also has the idempotent merge operation of cuelang, and languages such as jsonnet, pkl, Nickel also have certain configuration merge capabilities. Only cuelang strictly follows the idempotency of merging, which to some extent limits its use and understanding.

Re:KCL, a constraint-based functional language for configura... by from-nibly on Thursday August 08, 2024 @03:45PM (#41195422)
yeah, just because people are doing it doesn't mean it's good. You need to have the strictness of cuelang. But I recognize that KCL will probably win overall cause it's shiny and easy to get started with. But this will cause a LOT of problems for everyone as it already does, with things like json merge patch etc.
Re:KCL, a constraint-based functional language for configura... by jiggawatts on Monday August 05, 2024 @10:30PM (#41167357)
Comparison with YAML, Jsonnet, HCL, CUE, Dhall, Nickel, Helm, etc... here:

https://www.kcl-lang.io/docs/user_docs/getting-started/intro...