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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: I made Confetti: a configuration language file format

67 点作者 hgs3大约 1 个月前
Hello everyone, I created Confetti: a simple, typeless, and localization-friendly configuration language designed for human-editable configuration files.<p>In my opinion, JSON works well for data interchange, but it&#x27;s overused for configuration, it&#x27;s not localization-friendly, and it&#x27;s too syntactically noisy. INI is simple but lacks hierarchical structures and doesn&#x27;t have a formal specification. Confetti is intended to bridge the gap.<p>I aim to keep Confetti simple and minimalistic, while encouraging others to extend it. Think of it like Markdown for configuration files: there&#x27;s a core specification, but your welcome to create your own variations that suit your needs.

32 条评论

IshKebab大约 1 个月前
&gt; Confetti does not compete with JSON or XML, it competes with INI.<p>It clearly competes with JSON.<p>I think I would still much rather use JSON5 over this. It&#x27;s quite similar in terms of structure and terseness, but I don&#x27;t have to learn anything.<p><pre><code> &#x2F;&#x2F; This is a comment. { probe_device: [&quot;eth0&quot;, &quot;eth1&quot;], users: [ { user: &quot;*&quot;, login: &quot;anonymous&quot;, password: &quot;${ENV:ANONPASS}&quot;, machine: &quot;167.89.14.1&quot;, proxy: { try_ports: [582, 583, 584], }, }, { user: &quot;Joe Williams&quot;, login: &quot;joe&quot;, machine &quot;167.89.14.1&quot;, }, ], } </code></pre> Still, it seems fairly well designed and elegant. Way better than YAML or TOML for example. Typeless seems like a bad decision in some ways but I can see the advantages.<p>Top marks on the name!
评论 #43556049 未加载
评论 #43555025 未加载
评论 #43556229 未加载
unwind大约 1 个月前
Nice, I found one typo&#x2F;editing thing though which kind of makes it contradict itself:<p>The first paragraph says:<p><i>[...] It is minimalistic, untyped, and opinionated. [...]</i><p>but then under &quot;Notable features&quot; it begins with a big bold *Unopinionated*, so that was very confusing.
评论 #43557891 未加载
h1fra大约 1 个月前
I don&#x27;t trust a config file that doesn&#x27;t enforce quotes around strings. it&#x27;s a footgun especially when it collides with ill-defined boolean
评论 #43555224 未加载
Myrmornis大约 1 个月前
Nice looking project! The page in one place says it&#x27;s opinionated and in another place says it&#x27;s unopinionated. (I guess that means it&#x27;s unopinionated :) ).
评论 #43555460 未加载
评论 #43555443 未加载
alpaca128大约 1 个月前
Looks similar to my favorite format KDL: <a href="https:&#x2F;&#x2F;kdl.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;kdl.dev&#x2F;</a><p>Good to see a push towards less syntactic overhead, which is still considerable in JSON.
chrismorgan大约 1 个月前
In the spec &lt;<a href="https:&#x2F;&#x2F;confetti.hgs3.me&#x2F;specification&#x2F;" rel="nofollow">https:&#x2F;&#x2F;confetti.hgs3.me&#x2F;specification&#x2F;</a>&gt;:<p>&gt; <i>Confetti source text consists of zero or more Unicode scalar values. For compatibility with source code editing tools that add end-of-file markers, if the last character of the source text is a Control-Z character (U+001A), implementations may delete this character.</i><p>I’ve <i>heard</i> of this once, when researching ASCII control codes and related ancient history, but never once seen it in real life. If you’re insisting on valid Unicode, it sounds to me like you’re several decades past that happening.<p>And then given that you forbid control characters in the next section… make up your mind. You’re saying both that implementations MAY delete this character, and that source MUST NOT use it. This needs clarification. In the interests of robustness, you need to specify what parsers MUST&#x2F;SHOULD&#x2F;MAY do in case of content MUST violations, whether it be reject the entire document, ignore the line, replace with U+FFFD, <i>&amp;c.</i> (I would also recommend recapitalising the RFC 2119 terms. Decapitalising them doesn’t help readability because they’re often slightly awkward linguistically without the reminder of the specific technical meaning; rather it reduces their meaning and impact.)<p>&gt; <i>For compatibility with Windows operating systems, implementations may treat the sequence Carriage Return (U+000D) followed by Line Feed (U+000A) as a single, indivisible new line character sequence.</i><p>This is inviting unnecessary incompatibility. I recommend that you either mandate CRLF merging, or mandate CR stripping, or disallow special CRLF handling. Otherwise you can cause different implementations to parse differently, which has a long history of causing security problems, things like HTTP request smuggling.<p>I acknowledge this is intended as the base for a family of formats, rather than a strict single spec, but I still think allowing such variation for no good reason is a bad idea. (I’m not <i>all</i> that eager about the annexes, either.)
评论 #43557110 未加载
mncharity大约 1 个月前
JSON, jsonc, json5, hcl, kdl, scfg, caddyfile... and that&#x27;s just from earlier comments. After a brief search, puzzled, I ask: Is there really no more thorough comparison than wikipedia&#x27;s[1]? No syntax-across-languages[2]? No design space characterization?<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Comparison_of_data-serialization_formats#Syntax_comparison_of_human-readable_formats" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Comparison_of_data-serializati...</a> [2] <a href="https:&#x2F;&#x2F;rigaux.org&#x2F;language-study&#x2F;syntax-across-languages.html" rel="nofollow">https:&#x2F;&#x2F;rigaux.org&#x2F;language-study&#x2F;syntax-across-languages.ht...</a>
评论 #43555956 未加载
bobuk大约 1 个月前
I&#x27;ve been a long-time fan of KDL format, so I liked Confetti even more.<p>I spent a couple hours writing a fully complaint parser in pure Python. It passes all tests, and among other things has a separate &quot;mapper&quot; mode for more pythonic usage.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;bobuk&#x2F;pyconfetti">https:&#x2F;&#x2F;github.com&#x2F;bobuk&#x2F;pyconfetti</a>
buzzm大约 1 个月前
Of late I have grown fond of ... brace yourself ... RDF in turtle format for config files. Supports comments, multiline literals, built-in support for references, and rich typing via xsd casting when necessary e.g. ex:subject ex:createdOn &quot;2002-01-24T12:00:00.000Z&quot;^^xsd:dateTime ; You can have no namespace (:subject :name &quot;foo&quot;) or one or more to help separate metadata and structure (the config structure) from actual config data (ex:myInstance config:logfile &quot;pathname to file&quot;). And of course, all the metadata itself is labelable and can carry comments and descriptions so the config is essentially self-documenting. Or at least there is a standard, straightforward way to extract and organize the labels and comments if time has been taken to add them.
EdgeExplorer大约 1 个月前
Whoa. This is really cool. I&#x27;ve thought a lot about markup &#x2F; configuration languages. Aside from types (won&#x27;t get into typed&#x2F;typeless here) there are basically just a few possible structures: lists, maps, tables (lists of maps with same keys), and trees (xml-like with nested nodes of particular types) are the ones I think about.<p>Most existing formats are really bad for at least one of these. Tables in JSON have tons of repetition. XML doesn&#x27;t have a clear and obvious way to do maps. Almost anything other than XML is awkward at best for node trees.<p>Confetti seems to cover maps, trees, and non-nested lists really well, which isn&#x27;t a combination any other format I&#x27;m aware of covers as well.<p>Nested lists and tables seem like they would be more awkward, though from what I can tell &quot;-&quot; is a legal argument, so you could do:<p><pre><code> nestedlist { - { - 1 ; - 2 } - { - { - a ; - b } - { - c ; - d } } } </code></pre> To get something like [[1, 2], [[a, b], [c, d]]]. Of course you could also name the items (item { item 1 ; item 2 }), but either way this is certainly more awkward than a nested list in JSON or YAML.<p>I think a table could be done like JSON&#x2F;HTML with repeated keys, but maybe also like:<p><pre><code> table name age favorite-color { row Bob 87 red row &quot;Someone else&quot; 106 &quot;bright neon green&quot; } </code></pre> This is actually pretty nice.<p>In any event, I love seeing more exploration of configuration languages, so thanks for sharing this!<p>My number 1 request is a parser on the documentation page that shows parse tree and converts to JSON or other formats so you can play with it.
crabbone大约 1 个月前
Not at all in the direction where I&#x27;d want a configuration language to go... The marginal &quot;improvements&quot; wrt&#x27; punctuation are just inconsequential.<p>I&#x27;d take Prolog without I&#x2F;O and (some? all?) extra-logical predicates as configuration language. Maybe if there&#x27;s a way to require recursion to terminate, that&#x27;d be great, but not essential.
Aachen大约 1 个月前
I like it! The spec could be more accessibly written, but it&#x27;s somewhat understandable in casual reading. Perhaps it would benefit from a diagram like json&#x27;s famous one<p>One thing I didn&#x27;t understand is this example on the homepage:<p>&gt; password &quot;${ENV:ANONPASS}&quot;<p>The spec doesn&#x27;t seem to mention any ${}. Is this for the program to manage rather than the parser of the config going out to fetch an env var? If so, I find this a bit out of scope to show; at least, it confused me about whether that&#x27;s built-in&#x2F;supported syntax or if it&#x27;s just a literal with syntax intended for a different program<p>Depending on how set in stone this is, another complaint I might have is that you still have the trailing comma issue from JSON, except it&#x27;s not a comma but a backslash (reverse solidus, as the spec calls it—my mobile keyboard didn&#x27;t even know that word). Maybe starting a list of arguments with [ could allow one to use any number of lines for the values, until a ] is encountered?
评论 #43558388 未加载
nalakawula大约 1 个月前
It reminds me of the Caddyfile.<p><pre><code> example.com { root \* &#x2F;var&#x2F;www&#x2F;wordpress encode php_fastcgi unix&#x2F;&#x2F;run&#x2F;php&#x2F;php-version-fpm.sock file_server </code></pre> <a href="https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;caddyfile" rel="nofollow">https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;caddyfile</a>
jacobtomlinson大约 1 个月前
This also reminds me of HCL<p><a href="https:&#x2F;&#x2F;github.com&#x2F;hashicorp&#x2F;hcl?tab=readme-ov-file#information-model-and-syntax" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hashicorp&#x2F;hcl?tab=readme-ov-file#informat...</a>
voodooEntity大约 1 个月前
Why is typeless considered something good?
评论 #43554963 未加载
评论 #43554943 未加载
Heliodex大约 1 个月前
Loving this! Like other commenters here the syntax reminds me of KDL, except a lot simpler. I checked it out and was fully nerdsniped, so wrote an implementation &lt;<a href="https:&#x2F;&#x2F;github.com&#x2F;Heliodex&#x2F;confetti-go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Heliodex&#x2F;confetti-go</a>&gt; that passes all conformance tests, giving me a good feel for the language. Pretty easy to get working as well, though I haven&#x27;t tried adding any of the appendices yet.
juliangmp大约 1 个月前
I like the look of it, very clean<p>Though I&#x27;m not sure why using keywords like `true`, `false` or `null` are seen as a negative. Especially the numeral digits, its the system that most of the world uses...
评论 #43555455 未加载
ryukoposting大约 1 个月前
Nice! I like it. I&#x27;ve always liked INI for the exact advantage you cite - typelessness.<p>Blah blah blah it doesn&#x27;t have a spec. Lack of a spec doesn&#x27;t matter from the user&#x27;s POV in this problem domain, as all configuration files are categorically application-specific anyway. It doesn&#x27;t matter to the developer either, insofar as whatever implementation you use fits your needs. This isn&#x27;t object notation, it&#x27;s not data interchange, it&#x27;s <i>configuration</i>.
darccio大约 1 个月前
Congrats on shipping this. It&#x27;s similar to something that was in the back of my mind for a while. I&#x27;ll give it a try!
M95D大约 1 个月前
To author:<p>In the &quot;Material Definitions&quot; example there are no { }. Why not? What&#x27;s the difference? Is indentation significant?
评论 #43557995 未加载
danielvaughn大约 1 个月前
So weird, I was toying with a DSL 1-2 years ago and strongly considered turning it into a configuration language because the ergonomics were much nicer than JSON or YAML, and reminded me of HCL in a way. It looked very similar to this.<p>I abandoned the effort, but nice to know that someone else had a similar idea. Will be trying this out!
eviks大约 1 个月前
Nice that Unicode is supported, and the localization is a nice twist<p>Are there any examples of what&#x27;s possible with extensions?
评论 #43558186 未加载
pbronez大约 1 个月前
I like how the spec defines character classes by just passing the buck to Unicode<p>=====<p>Forbidden Characters<p>Forbidden characters are Unicode scalar values with general category Control, Surrogate, and Unassigned. Forbidden characters must not appear in the source text.<p>White Space<p>White space characters are those Unicode characters with the Whitespace property, including line terminators.
评论 #43558262 未加载
tiffanyh大约 1 个月前
Great work!<p>Suggestion, might be good to include Lua in the comparison table - since it’s also used for config as well.
xnorswap大约 1 个月前
So much continual effort wasted when for over 20 years we&#x27;ve had XML.<p>XML still works well as a configuration format.<p>Is it verbose? Very much so, but it ticks all the boxes:<p>- No ambiguity<p>- Typed<p>- Quick to parse<p>- Has Schemas that allow validation<p>- Widespread tooling support<p>All we needed was for applications to publish their XML schema files and any XML tool could allow for friendly editing.
评论 #43556031 未加载
NuSkooler大约 1 个月前
I&#x27;m still a fan of HJSON, and JSON5 looks quite nice, but this does as well. That&#x27;s all I can really say. There are so many choices, but looks like you did really well on this one.
protecto大约 1 个月前
Looks a lot like scfg.<p><a href="https:&#x2F;&#x2F;git.sr.ht&#x2F;~emersion&#x2F;scfg" rel="nofollow">https:&#x2F;&#x2F;git.sr.ht&#x2F;~emersion&#x2F;scfg</a>
mort96大约 1 个月前
I really like this kind of config file. People are saying it&#x27;s useless because you should just use JSON, but I think that misses the fundamental point of this style of config: you configure &quot;things&quot; not as part of a huge tree structure, but as their own free-standing structures. Users don&#x27;t go into an array of users as a 3rd level of indentation, users are their own top-level thing.<p>This allows really cool things, like modular configs where one &quot;main&quot; config file can include multiple specific-purpose configs. One file can contain the &quot;default users&quot; while another can contain additional users, for example. Or each user can get its own file.
kitd大约 1 个月前
Looks nice. Less syntactic noise that many other efforts, a good thing IMHO.
sophronesis0大约 1 个月前
Can you please add comparison of your language with nix lang?
jelder大约 1 个月前
I don’t intend this to be mean, but is this satire? Confetti seems to proudly use concepts which are very much NOT popular right now.<p>For example, you’ve reintroduced the Norway Problem. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36745212">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36745212</a><p>And I personally hope to never edit another file which lacks a strict schema like this does.
评论 #43555685 未加载
jp57大约 1 个月前
Obligatory XKCD: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;</a>