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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

The Norway Problem

656 点作者 dedalus大约 4 年前

65 条评论

keeperofdakeys大约 4 年前
This is part of more general problem, they had to rename a gene to stop excel auto-completing it into a date.<p><a href="https:&#x2F;&#x2F;www.theverge.com&#x2F;2020&#x2F;8&#x2F;6&#x2F;21355674&#x2F;human-genes-rename-microsoft-excel-misreading-dates" rel="nofollow">https:&#x2F;&#x2F;www.theverge.com&#x2F;2020&#x2F;8&#x2F;6&#x2F;21355674&#x2F;human-genes-renam...</a><p>Edit: Apparently Excel has its own Norway Problem ... <a href="https:&#x2F;&#x2F;answers.microsoft.com&#x2F;en-us&#x2F;msoffice&#x2F;forum&#x2F;msoffice_excel-mso_win10-mso_o365b&#x2F;norway-not-showing-on-maps-in-excel&#x2F;a0a9d886-598b-46e1-a2f9-35794960b89a" rel="nofollow">https:&#x2F;&#x2F;answers.microsoft.com&#x2F;en-us&#x2F;msoffice&#x2F;forum&#x2F;msoffice_...</a>
评论 #26679426 未加载
评论 #26679629 未加载
评论 #26681150 未加载
评论 #26680493 未加载
评论 #26679744 未加载
评论 #26679570 未加载
评论 #26680626 未加载
评论 #26680501 未加载
评论 #26680982 未加载
评论 #26686632 未加载
评论 #26691152 未加载
评论 #26680637 未加载
评论 #26693684 未加载
评论 #26680215 未加载
评论 #26679752 未加载
atombender大约 4 年前
The world <i>desperately</i> needs a replacement for YAML.<p>TOML is fine for configuration, but not an adequate solution for representing arbitrary data.<p>JSON is a fine data exchange format, but is not particularly human-friendly, and is especially poor for editable content: Lacks comments, multi-line strings, is far too strict about unimportant syntax, etc.<p>Jsonnet (a derivative of Google&#x27;s internal configuration language) is very good, but has failed to reach widespread adoption.<p>Cue is a newer Jsonnet-inspired language that ticks a lot of boxes for me (strict, schema support, human-readable, compact), but has not seen wide adoption.<p>Protobuf has a JSON-like text format that&#x27;s friendlier, but I don&#x27;t think it&#x27;s widely adopted, and as I recall, it inherits a lot of Protobufisms.<p>Dhall is interesting, but a bit too complex to replace YAML.<p>Starlark is a neat language, but has the same problem as Dhall. It&#x27;s essentially a stripped-down Python.<p>Amazon Ion [1] is neat, but I&#x27;ve not seen any adoption outside of AWS.<p>NestedText [2] looks promising, but it&#x27;s just a Python library.<p>StrictYAML [3] is a nice attempt at cleaning up YAML. But we need a new language with wide adoption across many popular languages, and this is Python only.<p>Any others?<p>[1] <a href="https:&#x2F;&#x2F;amzn.github.io&#x2F;ion-docs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;amzn.github.io&#x2F;ion-docs&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;nestedtext.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nestedtext.org&#x2F;</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;crdoconnor&#x2F;strictyaml&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;crdoconnor&#x2F;strictyaml&#x2F;</a>
评论 #26682730 未加载
评论 #26682792 未加载
评论 #26683310 未加载
评论 #26683205 未加载
评论 #26683314 未加载
评论 #26682412 未加载
评论 #26682258 未加载
评论 #26683122 未加载
评论 #26682703 未加载
评论 #26682842 未加载
评论 #26682934 未加载
评论 #26682079 未加载
评论 #26682046 未加载
评论 #26682574 未加载
评论 #26691261 未加载
评论 #26682101 未加载
评论 #26689291 未加载
azernik大约 4 年前
YAML had a worse example, once.<p>For the ease of entering time units YAML 1.1 parsed any set of two digits, separated by colons, as a number in sexagesimal (base 60). So 1:11:00 would parse to the integer 4260, as in 1 hour and 11 minutes equals 4260 seconds.<p>Now try plugging MAC addresses into that parser.<p>The most annoying part is that the MAC addresses would <i>only</i> be mis-parsed if there were no hex digits in the string. Like the bug in this post, it could only be reproduced with specific values.<p>Generally, if you&#x27;re doing implicit typing, you need to keep the number of cases as low as possible, and preferably error out in case of ambiguity.
评论 #26679983 未加载
评论 #26679728 未加载
评论 #26679657 未加载
评论 #26681548 未加载
评论 #26679385 未加载
kstenerud大约 4 年前
The worst tragedy of this is the security implications of subtly different parsers. As your application surface increases, you&#x27;re likely to mix languages (and thus different parsers), which means that the same input data will produce different output data depending on whether your parser replaces, truncates, ignores, or otherwise attempts to automatically &quot;fix up&quot; the data. A carefully crafted document could exploit this to trick your data storage layer into storing truncated data that elevates privileges or sets zero cost, while your access control layer that ignores or replaces the data is perfectly happy to let the bad document pass by.<p>And here&#x27;s something else to keep you up at night: Just think of how many unintentional land mines lurk in your serialized data, waiting to blow up spectacularly (or even worse, silently) as soon as you attempt to change implementation technologies!<p>This is why I&#x27;ve been so anal about consistent decoder behavior in Concise Encoding <a href="https:&#x2F;&#x2F;github.com&#x2F;kstenerud&#x2F;concise-encoding&#x2F;blob&#x2F;master&#x2F;ce-structure.md#security-and-limits" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kstenerud&#x2F;concise-encoding&#x2F;blob&#x2F;master&#x2F;ce...</a><p><a href="https:&#x2F;&#x2F;concise-encoding.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;concise-encoding.org&#x2F;</a>
yellowapple大约 4 年前
This is exactly why configuration&#x2F;serialization formats should make as few assumptions about value types as possible. Once parsing&#x27;s done, everything should be a string (or possibly a symbol&#x2F;atom, if the program ingesting such a file supports those), and it should be up to the application to convert values to the types it expects. This is Tcl&#x27;s approach, and it&#x27;s about as sensible as it gets.<p>...which is why it pains me to admit that in my own project for a Tcl-like scripting&#x2F;config language[1] I missed the float v. string issue, so it&#x27;ll currently &quot;cleverly&quot; return different types for 1.2 (float) v. 1.2.3 (atom). Coincidentally, I started work on a &quot;stringy&quot; alternative interpreter that hews closer to Tcl&#x27;s philosophy (to fix a separate issue - namely, to avoid dynamically generating atoms, and therefore avoid crashing the Erlang VM when given potentially-adversarial input), so I&#x27;m gonna fix that case for at least the &quot;stringy&quot; mode (by emitting strings instead of numbers, too), knocking out two birds with one stone for the upcoming 0.3.0 release :)<p>----<p>[1]: <a href="https:&#x2F;&#x2F;otpcl.github.io" rel="nofollow">https:&#x2F;&#x2F;otpcl.github.io</a>, for those curious
评论 #26679465 未加载
评论 #26679583 未加载
WalterBright大约 4 年前
&gt; The most tragic aspect of this bug, howevere, is that it is intended behavior according to the YAML 2.0 specification.<p>This is one of those great ideas that sadly one needs experience to realize are really bad ideas. Every new generation of programmers has to relearn it.<p>Other bad ideas that resurface constantly:<p>1. implicit declaration of variables<p>2. don&#x27;t really need a ; as a statement terminator<p>3. assert should not abort because one can recover from assert failures
评论 #26679838 未加载
评论 #26679663 未加载
评论 #26680428 未加载
评论 #26683822 未加载
评论 #26679949 未加载
评论 #26679719 未加载
mcv大约 4 年前
If it ignores part of the spec, I don&#x27;t think &quot;strictyaml&quot; is the correct name here. Instead, if it interprets everything as string, perhaps &quot;stringyaml&quot; would have been more accurate, though I&#x27;m sure that&#x27;s not as good PR.<p>I&#x27;m reminded of the discussion we had a few days ago about environment variables; one problem there is that env variables are always strings, and sometimes you do want different types in your config. But clearly having the system automatically interpret whether it&#x27;s a string or something else is a major source of bugs. Maybe having an explicit definition of which field should be which type would help, but then you end up with the heavy-handed XML with its XSD schema.<p>Or you just use JSON, which is light-weight, easy to read, but unambiguous about its types. I guess there&#x27;s a good reason it&#x27;s so popular.<p>Maybe other systems like yaml and environment variables should only ever be used for strings, and not for anything else, and I suppose replacing regular yaml with &#x27;strictyaml&#x27; could play a role there. Or cause unending confusion, because it does violate the spec.
评论 #26681545 未加载
评论 #26681498 未加载
评论 #26681355 未加载
grenoire大约 4 年前
I was helping out a friend of mine in the risk department of a Big 4; he was parsing CSV data from a client&#x27;s portfolio. Once he started parsing it, he was getting random NaNs (pandas&#x27; nan type, to be more accurate).<p>I couldn&#x27;t get access to the original dataset but the column gave it away. Namibia&#x27;s 2-letter ISO country code is NA—which happens to be in pandas&#x27; default list of NaN equivalent strings.<p>It was a headache and a half...
评论 #26679033 未加载
评论 #26679053 未加载
sdfhbdf大约 4 年前
What I am most baffled by with Yaml is the fact that it’s a superset of JSON.<p>Whenever an input accepts YAML you can actually pass in JSON there and it’ll be valid<p>It really surprised me when I found out and I use JSON Whenever possible since then since it’s much stricter<p><a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;JSON#YAML" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;JSON#YAML</a>
评论 #26679699 未加载
评论 #26679840 未加载
评论 #26679609 未加载
yakshaving_jgt大约 4 年前
&gt; it’s equally true that extremely strict type systems require a lot more upfront and the law of diminishing returns applies to type strictness - a cogent answer to the question “why is so little software written in haskell?“<p>I was with the article up until that point. I don&#x27;t agree that diminishing returns with regards to type strictness applies linearly. Term-level Haskell is not massively harder than writing most equivalent code in JavaScript — in fact I&#x27;d say it&#x27;s easier and you reap greater benefit. Perhaps it&#x27;s a different story when you go all-in on type-level programming, but I&#x27;m not sure that&#x27;s what the author was getting at. This smells of the <i>Middle Ground</i> logical fallacy to me. Or of course the comment was tongue-in-cheek and I&#x27;m overreacting.
评论 #26680288 未加载
评论 #26679116 未加载
评论 #26679139 未加载
abujazar大约 4 年前
Norwegian here. I’d say the problem is YAML, not Norway :D
jasode大约 4 年前
That author&#x27;s blog post sent me down a rabbit hole of insanity with YAML and the PyYAML parser idiosyncrasies.<p>First, he mentions &quot;YAML 2.0&quot; but there&#x27;s no such reference about &quot;2.0&quot; from yaml.org or Google&#x2F;Bing searches. Yaml.org and wikipedia says yaml is at 1.2. Apparently the other commenters in this thread clarified that the older &quot;YAML 1.1&quot; is what the author is referring to.<p>Ok, if we look at the official YAML 1.1 spec[1], it has this excerpt for implicit bool conversions:<p><pre><code> y|Y|yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF </code></pre> But the pyyaml code excerpts[2][3] from resolver.py has this:<p><pre><code> u&#x27;tag:yaml.org,2002:bool&#x27;, re.compile(ur&#x27;&#x27;&#x27;^(?:yes|Yes|YES|n|N|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF)$&#x27;&#x27;&#x27;, re.X), </code></pre> The programmer <i>omitted</i> the single character options of &#x27;y&#x27; and &#x27;Y&#x27; but it still has &#x27;n&#x27; and &#x27;N&#x27; ?!? The lack of symmetry makes the parser inconsistent.<p>And btw for trivia... PyYAML also converts strings with leading zeros to numbers like MS Excel: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;54820256&#x2F;how-to-read-load-yaml-parameters-with-leading-zeros-as-a-string" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;54820256&#x2F;how-to-read-loa...</a><p>[1] <a href="https:&#x2F;&#x2F;yaml.org&#x2F;type&#x2F;bool.html" rel="nofollow">https:&#x2F;&#x2F;yaml.org&#x2F;type&#x2F;bool.html</a><p>[2] 2020 latest: <a href="https:&#x2F;&#x2F;github.com&#x2F;yaml&#x2F;pyyaml&#x2F;blob&#x2F;ee37f4653c08fc07aecff69cfd92848e6b1a540e&#x2F;lib&#x2F;yaml&#x2F;resolver.py#L172" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yaml&#x2F;pyyaml&#x2F;blob&#x2F;ee37f4653c08fc07aecff69c...</a><p>[3] 2006 original : <a href="https:&#x2F;&#x2F;github.com&#x2F;yaml&#x2F;pyyaml&#x2F;blob&#x2F;4c570faa8bc4608609f0e531452f9941e4a272b3&#x2F;lib&#x2F;yaml&#x2F;resolver.py#L96" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yaml&#x2F;pyyaml&#x2F;blob&#x2F;4c570faa8bc4608609f0e531...</a>
ancarda大约 4 年前
You can catch this with yamllint (<a href="https:&#x2F;&#x2F;github.com&#x2F;adrienverge&#x2F;yamllint" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adrienverge&#x2F;yamllint</a>):<p><pre><code> % cat countries.yml --- countries: - US - GB - NO - FR % yamllint countries.yml countries.yml 5:4 warning truthy value should be one of [false, true] (truthy)</code></pre>
RcouF1uZ4gsC大约 4 年前
YAML seems like a really neat idea, but over time, I have I have come to regard it as being too complicated for me to use for configuration.<p>My personal favorite is TOML, but I would even prefer plain JSON over YAML<p>The last thing I want at 2 AM when trying to look figure out if an outage is due to a configuration change is having to think if each line of my configuration is doing the thing I want.<p>YAML prizes making data look nicely formatted over simplicity or precision. That for me, is not a tradeoff, I am willing to make.
评论 #26679210 未加载
ravanave大约 4 年前
Btw, the reason Haskell isn’t used more isn’t type system per se, as all types can be inferred at the compilation time. People would sometimes use this feature even to see if GHCi guesses the type correctly (by correctly I mean exactly how the user wants, technically it’s correct always) first time and save them some time writing it either with an extension or just copy&amp;paste from the interpreter window.<p>When it gets hairy is that most programming languages have low entrance barrier. To write Haskell effectively you’ve got to unlearn a lot of rooted bad habits and you get to dive into the “mathematical” aspect of the language. Not only you got monads, but there’s plethora of other types you need to get comfortably onboard with and the whole branch of mathematics talking about types (you don’t need to even know that such a field as category theory exists to use it).<p>However, since most people just want to write X, or just want hire a dev team at price they can afford, Haskell rarely is the first choice language.
评论 #26688131 未加载
lolinder大约 4 年前
This comment was buried in a thread, but I&#x27;m bringing it out because it&#x27;s very relevant to the conversation:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26679728" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26679728</a><p>&gt; the article refers to YAML 2.O, a nonexistent spec, and to PyYAML, a real parser which supports only YAML 1.1.<p>&gt; Both the unquoted-YES&#x2F;NO-as-boolean and sexagesimal literals were removed in YAML 1.2.
评论 #26689516 未加载
paxys大约 4 年前
I will never understand why YAML didn&#x27;t just require quoted strings. Did the creator not anticipate how many problems the ambiguity would cause?
评论 #26679524 未加载
blunte大约 4 年前
If you want no misunderstandings, be explicit. This applies to YAML and life in general. There&#x27;s an annoying but fairly accurate saying about assumptions that applies.<p>If you want something to be a specific type, you better have an explicit way of indicating that. If you say quotes will always indicate a string, great. Of course we know it&#x27;s not that simple, since there are character sets to consider.<p>The safest answer is to do something like XML with DTDs. But that imposes a LOT of overhead. Naturally we hate that, so we make some &quot;convention over configuration&quot; choices. But eventually, we hit a point where the invisible magic bites us.<p>This is one case where tests would catch the problem, if those tests are thorough enough - explicitly testing every possibility or better yet, generative testing.
评论 #26682750 未加载
dpratt71大约 4 年前
I don&#x27;t understand why Haskell gets brought up in the middle of an otherwise interesting and useful article. This sort of thing cannot happen in Haskell. And while Haskell is not universally admired, I can&#x27;t recall seeing Haskell&#x27;s flavor of type inference being a reason why someone claimed to dislike Haskell.
Waterluvian大约 4 年前
I have never gotten far into a project and thought, &quot;my config files are too verbose. I wish there were clever shorthands.&quot;<p>Does Yaml have any sort of strict mode?<p>I imagine I could find a linter that disallows implicit strings.
评论 #26680672 未加载
eitland大约 4 年前
There exists a couple of mainstream languages that are full of these sorts of <i>interesting</i> behavior, one of them is supposedly cool and productive and the other is supposedly ugly and evil.
评论 #26682626 未加载
评论 #26679403 未加载
评论 #26679141 未加载
dragonwriter大约 4 年前
its weird that this is a 2019 article misrepresenting behavior in the YAML 1.1 spec (2005) most of which reverted in the YAML 1.2 spec (2009) as being part of a nonexistent YAML 2.0 spec and justifying a library that purports to handle “YAML” ignoring the spec.
评论 #26681699 未加载
IHLayman大约 4 年前
Reminds me of the multiple YAML bugs that have plagued Kubernetes such as <a href="https:&#x2F;&#x2F;github.com&#x2F;kubernetes&#x2F;kubernetes&#x2F;issues&#x2F;82296" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kubernetes&#x2F;kubernetes&#x2F;issues&#x2F;82296</a><p>It is interesting how the standard of any language seems to diverge due to just the implementation from different parsers.
dan-robertson大约 4 年前
Other reasons to not want types happening during parse time:<p>- “modified” numbers, e.g. $50, 35%, 1.2345568896347853246863477<p>- Dates. If your language tries to convert a date to Unix time or Julian Day, you can have problems with time zones or distant or historical dates.<p>- strings vs symbols. The person writing config shouldn’t have to care about this distinction.<p>- Automatic deduplication for fields of objects can be a problem.
LeonM大约 4 年前
I was bitten with this issue some time ago.<p>The Stripe library has constants for which type of VAT number is supplied. One of those constants is &#x27;NO_VAT&#x27;...<p>Needless to say, this caused me some grey hairs
suttree大约 4 年前
Reminds me that the reasoning behind austerity came from an Excel calculation that didn&#x27;t include all the relevant rows :~&#x2F;<p><a href="https:&#x2F;&#x2F;www.theguardian.com&#x2F;politics&#x2F;2013&#x2F;apr&#x2F;18&#x2F;uncovered-error-george-osborne-austerity" rel="nofollow">https:&#x2F;&#x2F;www.theguardian.com&#x2F;politics&#x2F;2013&#x2F;apr&#x2F;18&#x2F;uncovered-e...</a><p><a href="https:&#x2F;&#x2F;www.bbc.co.uk&#x2F;news&#x2F;magazine-22223190" rel="nofollow">https:&#x2F;&#x2F;www.bbc.co.uk&#x2F;news&#x2F;magazine-22223190</a><p><a href="https:&#x2F;&#x2F;theconversation.com&#x2F;the-reinhart-rogoff-error-or-how-not-to-excel-at-economics-13646" rel="nofollow">https:&#x2F;&#x2F;theconversation.com&#x2F;the-reinhart-rogoff-error-or-how...</a>
评论 #26689590 未加载
thrower123大约 4 年前
I&#x27;ve never seen anything that used YAML that I didn&#x27;t want to douse with gasoline, nuke from orbit, and then salt the ground where it once stood.<p>I cry and rage and rend my clothes when I stumble upon some new thing that makes me have to use it.
pintxo大约 4 年前
&gt; “While the website went down and we were losing money we chased down a number of loose ends until finally finding the root cause.”<p>And that&#x27;s why you have a staging environment. Or you debug in production, whatever you prefer.
评论 #26679029 未加载
评论 #26679165 未加载
评论 #26679079 未加载
评论 #26679394 未加载
dwheeler大约 4 年前
The YAML specification eliminated this problem in 2009, with the release of version 1.2. That spec also eliminated some other problematic problems.<p>The real problem is that YAML parsers in wide use have not been updated to the spec that was released <i>TWELVE</i> years ago.<p>So who&#x27;s going to help the common YAML parser developers update their implementations to support version 1.2? I think that would be a big help. Maybe the Norwegian government can chip in some money &amp; time to get them updated, that would probably quietly eliminate a number of problems.
评论 #26692916 未加载
runeks大约 4 年前
Why not just enclose your strings in quotes and be done with it?<p>As far as I can see, this has nothing to do with typing and everything to do with syntax (of literals). If strings were required to be quoted this problem wouldn’t appear.<p>This is the reason no programming language has this issue — regardless of type system (JS&#x2F;Python&#x2F;Java&#x2F;Haskell). If you want a string here you need quotes.<p>Haskell could even be regarded as what the author calls “implicitly typed” — since types are derived from literals — and I’ve never heard a Haskeller complain about this issue.
jansan大约 4 年前
Norway is one of the luckiest countries in the world. They have a vast amount of resources, can produce their electrical energy entirely from hydropower, have a great democracy, a government they can trust, a beautiful landscape and great people.<p>I must say that I feel a little bit of relief to see that they have problems that nobody else has, besides insanely expensive alcohol that is only sold in &quot;wine monopoly&quot; stores that are more heavily guarded than banks.
DoofusOfDeath大约 4 年前
Funny coincidence. Around 2000, I worked for a company that coined the term &quot;Norway problem&quot; for a different software problem.<p>Their product used an MVCC database (I think ObjectStore). One of their customers in Norway had a problem where updates to the database seemed to not show up. IIRC the problem was a bug in this company&#x27;s software that caused MVCC to show an older version of the database content than expected.
Hendrikto大约 4 年前
&gt; The real fix requires explicitly disregaring the spec<p>Or… just quote your strings.
评论 #26679881 未加载
dangoor大约 4 年前
Cue also solves this problem. The &quot;no&quot; example is right on the front page: <a href="https:&#x2F;&#x2F;cuelang.org" rel="nofollow">https:&#x2F;&#x2F;cuelang.org</a><p>I used it for configuration of a Go program recently and found it pleasant to work with. I hope the language is declared stable soon, because it&#x27;s a good model.
namelosw大约 4 年前
I prefer JSON over YAML because I spend more time confused and burned by the problems caused by it.<p>I understand that people don&#x27;t like directly use JSON because it&#x27;s not very friendly: no comments, no multi-line string, etc.<p>A great alternative IMHO is cson[0]. It&#x27;s like JSON to JavaScript but for CoffeeScript (though nobody talks about it nowadays). It has indentation-based syntax, comments, and multiline string which usually don&#x27;t need to escape. The advantage is it&#x27;s close enough to JSON which is the canonical format that everybody can agree on nowadays. For YAML and TOML there are too many visual part-aways from JSON.<p>Or just create a JSON variant that enables comments and the backtick multiline string from JavaScript.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;bevry&#x2F;cson" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bevry&#x2F;cson</a>
korijn大约 4 年前
Edit: downvoters, thanks! I realize this is not an easily agreeable opinion (&quot;let&#x27;s all chant &#x27;death to YAML!&#x27;&quot;) but it&#x27;s really easy to avoid losing money on something like this. Just do proper testing.<p>Aren&#x27;t you setting yourself up for surprises if you write file formats such as TOML and YAML without reading the documentation, learning and experimenting first? How about unit testing? Or verifying the type in your config parser? Have you tried opening your site in the norway config on your development or testing environment? Or even in production? It all seems very basic and not at all blog post or even HN worthy.<p>I&#x27;m going to assume the authors still haven&#x27;t learned their lesson and are going to experience many more surprises in the future working with plain text file formats.
earthboundkid大约 4 年前
It&#x27;s fashionable to hate XML because it was used in a lot of places it was a bad fit in the 00s, but at least it&#x27;s a pretty good document language.<p>YAML though is always a bad fit. If you want machine readable config, use JSON; human readable, use TOML. When does YAML ever fit?
lopespm大约 4 年前
&gt; Christopher Null has a name that is notorious for breaking software code - airlines, banks, every bug caused by a programmer who didn’t know a type from their elbow has hit him.<p>This one made chuckle, and TIL that Null is a real life surname.
bsenftner大约 4 年前
This is such a core issue with a tool like YAML, how the hell did this program get so popular? Are there that many developers willy nilly using tools that fail in critical, silent ways, and the horde of no-nothings follows them?
makkesk8大约 4 年前
We too had this problem, we solved it using the 3 letter country code instead.
DennisP大约 4 年前
Something that used to plague me is that I had database processes importing Excel docs from clients, and if the first few rows in a column were numbers, SQLServer assumed that all the values must be numbers. Then it would run into cells containing other strings, and instead of revising its assumption, it would just import them as null. Since clients often didn&#x27;t have great data hygiene, it was a problem.<p>I finally solved it by exporting to csv, and using third-party software that handled its own import and did it correctly.
jmartrican大约 4 年前
It seems like we need to treat yaml like json and quote all strings. Would that help resolve these issues? Just trying to figure out a rule I can implement to prevent these issues.
schoen大约 4 年前
Recent related HN discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26365365" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26365365</a>
zomglings大约 4 年前
Have had a similar issue when adding git revisions to YAML documents.<p>The problem is that if a YAML parser sees a string like this:<p>&quot;0123e04&quot;<p>It interprets it as a number: 123 * 10^4<p>Our hacky solution was to prefix the revision hashes like sha-0123e04, but still this was quite annoying.<p>After that experience, I have stopped using YAML for any of my own configuration. Have started preferring putting my configurations in code. And when I don&#x27;t want that, have found JSON good enough for my purposes.
评论 #26689656 未加载
评论 #26689645 未加载
joshxyz大约 4 年前
This is why i love JSON. It&#x27;s only string, number, boolean, arrays, objects&#x2F;dictionaries, unless you write custom serializer and deserializers..
评论 #26681674 未加载
评论 #26689666 未加载
jmull大约 4 年前
&gt; “While the website went down and we were losing money we chased down a number of loose ends until finally finding the root cause.”<p>Hopefully not a real story. If you’re trying out new configurations in production and have no mechanism to rollback problematic changes, you’ve got bigger problems than YAML.<p>To me, though, YAML, including “StrictYAML” doesn’t solve any problems JSON, perhaps w&#x2F;comments, already solves.
paulintrognon大约 4 年前
I am sometimes annoyed by the fact you have to put double quotes around string properties in JSON. It would be so much lighter to use JS syntax..! Then I read articles like this one. Thank you JSON for not trying to be smart.
gitowiec大约 4 年前
I don&#x27;t like YAML because when I need to write configuration in it I waste time to remember what is the syntax. I have much better understanding of JSON, because I use it almost on daily basis.
NaturalPhallacy大约 4 年前
This is why implicit typing is an <i>invitation</i> to errors.
lenkite大约 4 年前
Why does YAML accept unquoted strings ? Be Strict. Be Safe.
kleer001大约 4 年前
Ah, tool centric (not centered in the person) time-offset (the ones making the original mistake doesn&#x27;t see it) paredolia. Good &#x27;el TCTOP...
groundCode大约 4 年前
I&#x27;ve hit this exact same problem loading YAML in Ruby. Luckily caught it before it hit prod, but still, it made me go argh for a while.
mrzool大约 4 年前
Wow, YAML has definitely some pretty quirky edges.
vanshg大约 4 年前
Why not just use Python itself for storing configurations? You can be explicit about the data type and no need to parse anything
teddyh大约 4 年前
This is another good argument against weak types in general. Strong types are better, and explicit is better than implict.
mleonhard大约 4 年前
Don&#x27;t use ambiguous formats. Use TOML.<p><a href="https:&#x2F;&#x2F;toml.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;toml.io&#x2F;</a>
lifeisstillgood大约 4 年前
Hang on. The strict model seems off.<p>In the first model entering<p>GB 9.3<p>gets you a string and a number.<p>But the second gets you two strings?<p><i>Both</i> are wrong in my opinion.<p>&quot;GB&quot; 9.3<p>is the correct approach<p>Explicit beats implicit every time.
pietroppeter大约 4 年前
I like strict yaml but I have used it very little. Anyone who uses it more that can give more feedback?
jgalt212大约 4 年前
another gotcha:<p>2020-03-25 -&gt; datetime.date(2020, 3, 25), not &quot;2020-03-25&quot;
throwaway4good大约 4 年前
Just use json.
knorker大约 4 年前
NO problem.
Meniteos4大约 4 年前
They decided to go against the YAML standard and therefore are no longer a YAML parser. The actual answer to this problem would have been to use a better storage format. Perhaps JSON5? or TOML?
enaaem大约 4 年前
Related xkcd<p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;327&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;327&#x2F;</a>
评论 #26683179 未加载
dudeinjapan大约 4 年前
You say Norway, I say Yesway.
bmn__大约 4 年前
The problem is insufficiently analysed by the article author and the commenters in this thread so far. It is very superficial. The recent thread &quot;Can’t use iCloud with “true” as the last name&quot; <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26364993" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26364993</a> went deeper. Let me take up its relevant particulars into this thread.<p>The article author hitchdev does not say it outright, but it is heavily implied that the YAML file was edited by hand. This is the immediate cause of the problem. The indirect root of the problem is that the spec authors chose a plain text serialisation format and thus created an <i>affordance</i> <a href="http:&#x2F;&#x2F;enwp.org&#x2F;Affordance#As_perceived_action_possibilities" rel="nofollow">http:&#x2F;&#x2F;enwp.org&#x2F;Affordance#As_perceived_action_possibilities</a> to be edited by hand.<p>This turns out the be unsafe&#x2F;source of bugs because YAML end-users are not capable of correctly applying the serialisation rules considering the edge cases detailed in the article because humans are creatures of habit, applying analogy and common sense, making assumptions and then sometimes go wrong, whereas a piece of software will not make the Norway, Null etc. mistakes. hitchdev even writes that quoting the string is &quot;a fix for sure, but kind of a hack&quot;, but that&#x27;s a grave misunderstanding. Quoting the string here is actually applying the serialisation rules correctly.<p>The tangential at the end of the article about typing is also orthogonal&#x2F;irrelevant. YAML is strictly&#x2F;strongly&#x2F;unambiguously typed, and so is the mentioned variant Strict YAML. The difference is that Strict YAML has serialisation rules that are more amenable to or aligning with the human factors of habit etc. and thus work better in practice.<p>My personal recommendation is to never edit YAML by hand and always use a serialiser. This is less convenient, but safe.<p>In closing, I would like the reader of this comment to make an effort to distinguish between &quot;what is&quot; and &quot;what ought to be&quot; in their head, otherwise the ideas here will be very muddled.
评论 #26679797 未加载
评论 #26679856 未加载
评论 #26679771 未加载
评论 #26679798 未加载