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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Levels of configuration languages

75 点作者 kaycebasques大约 1 个月前

23 条评论

susam大约 1 个月前
About 20 or so years ago, I have come across a configuration pattern that could be arguably called "Level 0". It was configuration by file existence. The file itself would be typically empty. So no parsing, syntax, or schema involved. For example, if the file /opt/foo/foo.txt exists, the software does one thing but if it is missing the software does another thing. So effectively, the existence of the file serves as a boolean configuration flag.
评论 #43668776 未加载
评论 #43668716 未加载
评论 #43670191 未加载
评论 #43669086 未加载
评论 #43674820 未加载
评论 #43668584 未加载
评论 #43668670 未加载
评论 #43669702 未加载
alexambarch大约 1 个月前
I’d argue Terraform&#x2F;HCL is quite popular as a Level 4 configuration language. My biggest issue with it is that once things get sufficiently complex, you wish you were using a Level 5 language.<p>In fact, it’s hard to see where a Level 4 language perfectly fits. After you’ve surpassed the abilities of JSON or YAML (and you don’t opt for slapping on a templating engine like Helm does), it feels like jumping straight to Level 5 is worth the effort for the tooling and larger community.
评论 #43669221 未加载
评论 #43669858 未加载
评论 #43669154 未加载
sgeisenh大约 1 个月前
&gt; Don&#x27;t waste time on discussions within a level.<p>I disagree with this. YAML has too many footguns (boolean conversions being the first among them) not to mention it is a superset of JSON. Plain old JSON or TOML are much simpler.
评论 #43670890 未加载
评论 #43672000 未加载
AtlasBarfed大约 1 个月前
This is just the complexity in individual files!<p>Configuration can be a lot more complicated. Look at dockerfiles, which are filesystems overlaid over each other, often sourced from the internet.<p><a href="https:&#x2F;&#x2F;docs.spring.io&#x2F;spring-boot&#x2F;reference&#x2F;features&#x2F;external-config.html" rel="nofollow">https:&#x2F;&#x2F;docs.spring.io&#x2F;spring-boot&#x2F;reference&#x2F;features&#x2F;extern...</a><p>Look at that: a massive 15 deep precedence order for pulling just individual values (oh man, doesn&#x27;t even touch things like maps&#x2F;lists that get merged&#x2F;overridden).<p>That includes sources like the OS, environment-specific, a database (the JNDI registry), XML, JSON, .properties files, hardcodes. Honestly, I remember this being even deeper, I suspect they have simplified this.<p>This doesn&#x27;t even get into secrets&#x2F;secured configuration, which may require a web service invocation. I used to also pull config via ssh, or from private gits or github, from aws web service calls (THAT required another layer of config getting a TOTP cycled cred).<p><a href="https:&#x2F;&#x2F;crushedby1sand0s.blogspot.com&#x2F;2021&#x2F;02&#x2F;stages-of-despair-in-configuration.html" rel="nofollow">https:&#x2F;&#x2F;crushedby1sand0s.blogspot.com&#x2F;2021&#x2F;02&#x2F;stages-of-desp...</a><p>I was right, the Spring config fallthru was deeper.
18172828286177大约 1 个月前
&gt; Don&#x27;t waste time on discussions within a level. For example, JSON and YAML both have their problems and pitfalls but both are probably good enough.<p>Disagree. YAML is considerably easier to work with than JSON, and it’s worth dying on that hill.
评论 #43668585 未加载
评论 #43668954 未加载
评论 #43668682 未加载
ajb大约 1 个月前
I&#x27;m not convinced by reducing this to a single dimension. There are differences in both &#x27;what can be expressed&#x27; and &#x27;what validation can be done&#x27; which are somewhat independent of each other
评论 #43668735 未加载
behnamoh大约 1 个月前
Lisp code is represented in the same data structure it manipulates. This homoiconicity makes Lisp code be a great config data especially in a Lisp program. In comparison, you can&#x27;t represent JS code in JSON.
评论 #43680194 未加载
waynecochran大约 1 个月前
<a href="https:&#x2F;&#x2F;jsonnet.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jsonnet.org&#x2F;</a> I never heard of this before. This seems like the JSON I wish I really had. Of course at some point you could just use JavaScript. I guess that fits w option 5.
评论 #43668951 未加载
评论 #43671983 未加载
jiggawatts大约 1 个月前
In my opinion there&#x27;s a &quot;level 4.5&quot; in between structured templating and full-blown procedural scripting: Using a general-purpose language to generate structured data, but then handing that over to a simpler system to materialise.<p>Pulumi is the best known example. Also, any time a normal programming language is used to generate something like an ARM template or any other kind of declarative deployment file.<p>This is the best-of-all-worlds in my opinion: Full capability, but with the safety of having an output that can be reviewed, committed to source control, diff-ed, etc...
评论 #43672181 未加载
James_K大约 1 个月前
&quot;Use the lowest level possible&quot; has always seemed rather stupid advice to me. What I suggest: use XML. Every programming language under the sun can spit out XML files, so you can generate them programmatically if needed, and it&#x27;s not as if you&#x27;ll ever sit there wishing you&#x27;d gone for a simpler format. Sachems make the files practically self-documenting and the tooling for them is brilliant.
chewbacha大约 1 个月前
Reminds me a lot of the configuration complexity clock: <a href="https:&#x2F;&#x2F;mikehadlow.blogspot.com&#x2F;2012&#x2F;05&#x2F;configuration-complexity-clock.html" rel="nofollow">https:&#x2F;&#x2F;mikehadlow.blogspot.com&#x2F;2012&#x2F;05&#x2F;configuration-comple...</a><p>It’s made the page before and proposes that these forms are cyclic.
评论 #43671911 未加载
chubot大约 1 个月前
Hm I also made a taxonomy of 5 categories of config languages, which is a bit different<p><i>Survey of Config Languages</i> <a href="https:&#x2F;&#x2F;github.com&#x2F;oils-for-unix&#x2F;oils&#x2F;wiki&#x2F;Survey-of-Config-Languages">https:&#x2F;&#x2F;github.com&#x2F;oils-for-unix&#x2F;oils&#x2F;wiki&#x2F;Survey-of-Config-...</a><p><pre><code> Languages for String Data Languages for Typed Data Programmable String-ish Languages Programmable Typed Data Internal DSLs in General Purpose Languages </code></pre> Their taxonomy is:<p><pre><code> String in a File A List Nested Data Structures Total Programming Languages Full Programming Language </code></pre> So the last category (#5) is the same, the first one is different (they start with plain files), and the middle is a bit different.<p>FWIW I don’t think “Total” is useful – for example, take Starlark … The more salient things about Starlark are that it is restricted to evaluate very fast in parallel, and it has no I&#x2F;O to the external world. IMO it has nothing to do with Turing completeness.<p>Related threads on the “total” issue:<p><a href="https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;dyqczr&#x2F;find_mkdir_is_turing_complete" rel="nofollow">https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;dyqczr&#x2F;find_mkdir_is_turing_complete</a><p><a href="https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;gcfdnn&#x2F;why_dhall_advertises_absence_turing" rel="nofollow">https:&#x2F;&#x2F;lobste.rs&#x2F;s&#x2F;gcfdnn&#x2F;why_dhall_advertises_absence_turi...</a>
bob1029大约 1 个月前
I think SQL is one of the best level 4&#x2F;5 configuration languages out there. Whether or not it&#x27;s a &quot;full programming language&quot; depends on your specific dialect and how it&#x27;s used.
评论 #43669866 未加载
ks2048大约 1 个月前
&gt; I actually like XML. It isn&#x27;t &quot;cool&quot; like YAML anymore, but it has better tooling support (e.g. schema checking) and doesn&#x27;t try to be too clever. Just try to stay away from namespaces and don&#x27;t be afraid of using attributes.<p>I agree with this (even though, In practice I usually just use JSON or YAML) - it avoids some of the pitfalls of both JSON and YAML - has comments, lacks ambiguity. The main annoyances are textContent (is whitespace important?), attributes vs children, verbosity of closing tags, etc.
评论 #43670347 未加载
throw0101d大约 1 个月前
Personally I lean towards what ISC BIND uses:<p>* <a href="https:&#x2F;&#x2F;bind9.readthedocs.io&#x2F;en&#x2F;latest&#x2F;reference.html#options-block-grammar" rel="nofollow">https:&#x2F;&#x2F;bind9.readthedocs.io&#x2F;en&#x2F;latest&#x2F;reference.html#option...</a><p>* <a href="https:&#x2F;&#x2F;www.zytrax.com&#x2F;books&#x2F;dns&#x2F;ch7&#x2F;statements.html" rel="nofollow">https:&#x2F;&#x2F;www.zytrax.com&#x2F;books&#x2F;dns&#x2F;ch7&#x2F;statements.html</a><p>Not as &#x27;freestyle&#x27; as INI (Level 2), but a little less structured than most of the Level 3 stuff.
retropragma大约 1 个月前
As a TypeScript developer, my answer is to use unconfig [1]. Support for JSON, JavaScript, or best of all, TypeScript.<p>Or wire up your own utility function with bundle-require [2], another favorite of mine, for loading TS or JS config files.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;antfu-collective&#x2F;unconfig">https:&#x2F;&#x2F;github.com&#x2F;antfu-collective&#x2F;unconfig</a> [2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;egoist&#x2F;bundle-require">https:&#x2F;&#x2F;github.com&#x2F;egoist&#x2F;bundle-require</a>
rdtsc大约 1 个月前
That’s a good breakdown.<p>In practice configuration systems that reach level 4 or 5 start to look complex and the whole thing ends up with a new rewrite into a level 2 or 3. After a while it expands, because it needs comments, include files, templating, for loops, etc., until it becomes a total mess and gets thrown out and we cycle back to level 3.
ks2048大约 1 个月前
I&#x27;m not sure &quot;total&quot; vs &quot;turing-complete&quot; should be a huge difference - just terminate with an error after X seconds.<p>For example, can &quot;total programming languages&quot; include: &quot;for i in range(10000000000000): do_something()&quot;?<p>If so, your config file can still hang - even though it provably terminates.
评论 #43670900 未加载
kristopolous大约 1 个月前
The distance between 3 and 4 are wider and have more members. Take CSS for example.
评论 #43668371 未加载
iambvk大约 1 个月前
IMO there is another level in between 3 and 4 where config file allows for cross referencing among config values, forming a graph.<p><pre><code> foo.password = xxx bar.password = yyy wifi.ssid = foo</code></pre>
bblb大约 1 个月前
&quot;vibeconfig&quot;<p>1. You give LLM the requirements<p>2. It spits out whatever monstrosity is required to configure the software or service in question<p>3. When issues later arise, you just vibeconfig again with new requirements<p>Eventually new vibeconfig tools will rise because even those three steps are not complex enough. These call LLM APIs to inject the config files dynamically at runtime. &quot;But it&#x27;s a security issue&quot;. So another vertical is born: auditing and securing the vibeconfig LLM autogeneration toolsets.
somat大约 1 个月前
For my personal projects I am drifting towards the simple side. More and more I try to stick with a simple single level key value configuration.<p>But if you do require a complex configuration, I think it is beneficial to both yourself and your users to invest in a openbsd style parse.y like solution rather than just shovel the usual json or yaml slop.<p><a href="https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;cgi-bin&#x2F;cvsweb&#x2F;~checkout~&#x2F;src&#x2F;usr.sbin&#x2F;smtpd&#x2F;parse.y?rev=1.299&amp;content-type=text&#x2F;plain" rel="nofollow">https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;cgi-bin&#x2F;cvsweb&#x2F;~checkout~&#x2F;src&#x2F;usr...</a><p>By which I mean it does not have to be yacc, but taking the time to think about the language of your configurations improves the ui dramaticly.
runeblaze大约 1 个月前
But jsonnet is Turing complete…?