TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Dhall: A Non-Repetitive Alternative to YAML

193 点作者 ff_将近 6 年前

24 条评论

jrudolph将近 6 年前
Dhall is an awesome tool to have in your DevOps tool belt - we&#x27;re heavy dhall users at meshcloud [0] and couldn&#x27;t be happier about it. We picked it after evaluating a long list of contenders (yaml madness with anchors, jsonnet, ksonnet, j2&#x2F;jinja, a hacked ejs compiler [1] and some more I forgot). It&#x27;s so good we&#x27;re looking into how we can give back&#x2F;donate to the project.<p>Dhall elegantly solves a major challenge: configuration management at scale. We build a multi-cloud management platform, which serves DevOps teams, IT Governance, Controlling and IT Management in large enterprises. That means we&#x27;re an integration solution for a lot of things, so we need to be highly configurable. Because we also manage private clouds (a la OpenStack, Cloud Foundry, OpenShift etc.), we often run on-premises and operate our software as a managed service. Using dhall allows us to _compile and type check_ all our configuration for all our customers before rolling things out. We use dhall to compile everything from terraform&#x2F;ansible, kubernetes templates, spring config, to concourse ci pipelines and customer-specific reference data to load into our product. Since adopting dhall earlier this year, we measurably reduced our deployment defect rate and re-gained the ability to safely refactor configuration.<p>It takes a little time to get used to, but we appreciate that it&#x27;s highly opinionated around formatting and &quot;how to do things&quot; - somewhat in the same way as golang is. It has certainly helped that we had a member with haskell experience on the team, as dhall is built in haskell and the syntax feels familiar.<p>Plug: if you&#x27;re looking for a job working with dhall, reach out :-)<p>- 0: <a href="https:&#x2F;&#x2F;meshcloud.io" rel="nofollow">https:&#x2F;&#x2F;meshcloud.io</a> - 1: <a href="https:&#x2F;&#x2F;github.com&#x2F;Meshcloud&#x2F;ejs-compiler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Meshcloud&#x2F;ejs-compiler</a>
评论 #20360423 未加载
评论 #20362260 未加载
oalessandr将近 6 年前
I&#x27;m trying to use it for Kubernetes since it can both work like helm (paramerizing functions) and kustomize (using the merge &#x2F;&#x2F; operator). Moreover it has (safe) imports which make defining constants quite easy.<p>There are already kubernetes bindings available <a href="https:&#x2F;&#x2F;github.com&#x2F;dhall-lang&#x2F;dhall-kubernetes" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dhall-lang&#x2F;dhall-kubernetes</a> .<p>The syntax in the examples looks a bit more verbose and less readable than yaml but I think building sensible abstractions on top of it will alleviate the pain (abstractions here are innocuous since you can &#x27;normalize&#x27; the code and they disappear)<p>I&#x27;m not too happy with the default formatting though. I think if the formatter indented nested values similar to yaml that would look better to the human eye.
评论 #20359076 未加载
评论 #20366939 未加载
dang将近 6 年前
Thread from 2018: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17523623" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17523623</a><p>2017: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15185015" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15185015</a><p>2016: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13109672" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13109672</a>
hjk05将近 6 年前
This isn’t an alternative to yaml. It’s a yaml generator. To me it’s not competing with yaml it’s competing with python or Haskell, and i’d argue that putting yet another language in your stack just for generating config files is added unneeded complexity. And sure while both python and Haskell are Turing complete, how often do we actually run into issues when generations flat config files? I mean I’ve never had that issue, and I’ve never caught myself thinking “if only there was a nice way to limit myself to a non Turing complete subset of python&#x2F;Haskell”...
评论 #20360602 未加载
评论 #20360401 未加载
评论 #20366958 未加载
cryptonector将近 6 年前
If you have functions that can call functions, you&#x27;d better not have recursion if you want to not be Turing-complete.<p>Non-Turing-completeness is certainly very important in many cases (e.g., in DTrace and eBPF), but I&#x27;m not sure that it&#x27;s so important for <i>configuration</i>. Assuming for a moment that I don&#x27;t need non-Turing-completeness for configuration, my choice of DSL would be jq[0]! Using jq for configuration means that I can use JSON, TOML-style, and other ways of expressing complex data, including combinations of them, all with &quot;interpolation&quot; (not quite) and complex computation being available.<p><pre><code> [0] https:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;</code></pre>
评论 #20357370 未加载
评论 #20357705 未加载
nikolay将近 6 年前
Dhall keeps popping up on HN. Here what I don&#x27;t like about it:<p>- Why use &#x27;=&#x27; instead of &#x27;:&#x27; for attributes? If you used &#x27;:&#x27;, then &#x27;=&#x27; could be variable assignment and eliminate the need for &#x27;let&#x27;.<p>- Why is there a need for commas?<p>- Why quote via ticks?! Gee!<p>- What&#x27;s with the &#x27;{-&#x27; and &#x27;-}&#x27; for comments?! It&#x27;s like its author decided to differ <i>at any price</i>!<p>In general, good ideas, but it&#x27;s too weird and unnecessarily deviates from common syntax.
评论 #20356500 未加载
评论 #20357742 未加载
zeliard将近 6 年前
Couple of contenders:<p>- Jsonnet (<a href="https:&#x2F;&#x2F;jsonnet.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jsonnet.org&#x2F;</a>) - simpler syntax and less concepts to learn, just an extension of JSON. But no type checking. An open source offspring of Google&#x27;s internal config language (GCL&#x2F;BCL)<p>- Cue (<a href="https:&#x2F;&#x2F;github.com&#x2F;cuelang&#x2F;cue" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cuelang&#x2F;cue</a>) - a more ambitious attempt to fix GCL&#x2F;BCL by replacing inheritance as the fundamental compositional primitive with constraint unification.<p>Great thread comparing them against each other by the authors of both: <a href="https:&#x2F;&#x2F;github.com&#x2F;cuelang&#x2F;cue&#x2F;issues&#x2F;33" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cuelang&#x2F;cue&#x2F;issues&#x2F;33</a><p>Cue seems kind of similar to Dhall on first sight, but I haven&#x27;t used either enough for an informed opinion yet.
评论 #20359377 未加载
评论 #20358681 未加载
评论 #20360000 未加载
评论 #20359544 未加载
评论 #20358097 未加载
andybak将近 6 年前
Immediate response?<p>I hate commas at the start of lines and I would prefer not to have curly braces in a human editable&#x2F;readable format.<p>Neither reason is terribly rational but my first impressions weren&#x27;t great.
评论 #20356727 未加载
评论 #20358341 未加载
评论 #20357007 未加载
tobr将近 6 年前
So far, only comments complaining about syntax. You can do better, HN!
评论 #20356667 未加载
评论 #20357056 未加载
评论 #20356692 未加载
评论 #20359665 未加载
adev_将近 6 年前
For a pragmatic, <i>really</i> readable configuration file format, TOML never disappointed me ( <a href="https:&#x2F;&#x2F;github.com&#x2F;toml-lang&#x2F;toml#user-content-local-date" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;toml-lang&#x2F;toml#user-content-local-date</a> ).<p>- This is human readable contrary to the JSON family and its {} abuses.<p>- It is not space &#x2F; ident base contrary to YAML that becomes very quickly a mess to write and a mess to parse.
评论 #20357076 未加载
评论 #20356780 未加载
NuSkooler将近 6 年前
Still much prefer HJSON (<a href="http:&#x2F;&#x2F;hjson.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;hjson.org&#x2F;</a>) for stuff that people might need to touch.<p>If it&#x27;s truly for end-users (read: non-admin&#x2F;dev types), you probably shouldn&#x27;t have them touching configuration files _at all_.
评论 #20357091 未加载
评论 #20356553 未加载
评论 #20358109 未加载
markandrewj将近 6 年前
My comment isn&#x27;t specifically about Dhall, but about the note on Turing completeness. I often read comments about how YAML&#x2F;JSON is not turning complete. These comments normally frame the lack of Turing completeness as being a short coming of the format(s). I find this interesting because one the reasons that the industry moved away from XML was to have cleaner separation between data and logic. I generally tend to think that it is cleaner to separate logic and data, instead of creating a tight coupling. I don&#x27;t read many people making comments from this perspective though. I am not trying to say we can&#x27;t do better then YAML&#x2F;JSON, I am just trying to offer some food for thought. I tend to view JSON&#x2F;YAML as a data exchange format, and not a programming language, so I am not bothered by the lack of Turing completeness.
评论 #20358162 未加载
评论 #20358410 未加载
评论 #20358431 未加载
评论 #20361063 未加载
KirinDave将近 6 年前
Dhall is fantastic and I try to encourage everyone in tech I meet try it.
评论 #20358352 未加载
choeger将近 6 年前
Hmm...<p>So the authors claim that their language is guaranteed to terminate for all well-typed programs. That is actually a nice spot for configuration languages. Yet, I wonder how<p>a) they guarantee it, as I have seen no obvious link to the language&#x27;s semantics<p>b) useful this is in practice.<p>Nevertheless, very nice approach, indeed.
评论 #20356983 未加载
评论 #20357739 未加载
mitchtbaum将近 6 年前
Rust bindings tracking issue<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Nadrieril&#x2F;dhall-rust&#x2F;issues&#x2F;77" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Nadrieril&#x2F;dhall-rust&#x2F;issues&#x2F;77</a>
ilaksh将近 6 年前
I&#x27;m sure people will be happy to crucify me for throwing this out there but I don&#x27;t see a big risk in just using JavaScript in most cases if you want something like that. You could use template literals to replicate the example.
voidmain将近 6 年前
How far does &quot;non turing completeness&quot; really get you in this context? It looks easy to write a program in this language that will take longer than the age of the universe to evaluate and whose result can&#x27;t be represented explicitly without collapsing the galaxy into a black hole. How much comfort can you take in the fact that you know it doesn&#x27;t diverge?
评论 #20360398 未加载
javier2将近 6 年前
I love this!<p>How small is a static binary to run this in my containers?<p>How are some ways to integrate the typed config in a language?
评论 #20367641 未加载
arkh将近 6 年前
<p><pre><code> let input = { relative = &quot;daughter&quot; , movies = [ &quot;Boss Baby&quot;, &quot;Frozen&quot;, &quot;Moana&quot; ] } </code></pre> We don&#x27;t frequent the same kind of &quot;non-technical users&quot; I guess.
amingilani将近 6 年前
I thought the typo in the challenge was that the keys were in the root of the user&#x27;s home directory, instead of the `.ssh` directory. So, I added `.ssh&#x2F;` between the key and user home directory.
mitchtbaum将近 6 年前
This looks very useful.
评论 #20357176 未加载
desc将近 6 年前
Programmable configuration is always and without exception a monumentally stupid idea.<p>Programmatic <i>generation of static configuration files</i> can be very useful.<p>Sufficiently complex examples of the latter might as well be the former as far as maintenance is concerned.<p>If you need to write a program to configure your program, you&#x27;re probably doing it wrong.
评论 #20358302 未加载
isoprophlex将近 6 年前
To me, worrying about config files seems like the ultimate exercise in bikeshedding.<p>You either need a simple list of items (eg. dependencies) or key&#x2F;value pairs. Use a text file or yml or json or whatever.<p>Or you need templating, the use of functions, etc, like dhall provides. But then, why not use the language you&#x27;re already using for the rest of your project, or a bash script to export some variables?<p>Might sound like I&#x27;m throwing sourness around, but I just don&#x27;t see the niche for this, except inventing a new thing for the joy of it?
评论 #20357148 未加载
评论 #20360166 未加载
评论 #20356684 未加载
评论 #20358383 未加载
评论 #20360711 未加载
_j7tr将近 6 年前
What&#x27;s with the commas at the start of lines?
评论 #20356397 未加载
评论 #20357002 未加载
评论 #20356394 未加载