Earlier quoted context omitted.
Every YAML parser I've ever used has been literal magnitudes slower than the slowest JSON parser. It's way too flexible a format. > YAML may seem ‘simple’ and ‘obvious’ at a glance, but it’s actually not. The YAML spec is 23,449 words; for comparison, TOML is 838 words, JSON is 1,969 words, and XML is 20,603 words. https://arp242.net/weblog/yaml_probably_not_so_great_after_a...
If data is so big that parsing is a bottleneck, that seems like the wrong case for YAML. It's good for hand-edited and human-readable config files, and it's fast enough for that.
A modest proposal
131–140 of 189 posts
Re: A modest proposal
#132Earlier quoted context omitted.
Commas are unnecessary. There is zero benefit to having them. The code is actually easier to parse if you just remove them from the rules list entirely. No commas might look weird for a day or so, but you quickly get used to it. (I'm ignoring the comma operator, which is a special case and not relevant to the main point.)
foo(x, -y) is not the same as foo(x -y) (from your last sentence, I assume you were talking about JS in general, not just JSON)
foo(x -y) => foo(x, -y)
foo(x - y) => foo(x - y)Re: A modest proposal
#133Earlier quoted context omitted.
That's terrible, to have semantics depend on such a tiny syntax change that's so easy to miss.
I wish there was times that HN supported Quadratic Voting[0] so that I could more (but costly) up votes to a really sane and pertinent comment. [0] http://ericposner.com/quadratic-voting/
Re: A modest proposal
#134Earlier quoted context omitted.
It may be used as such but it shouldn't be. YAML serves this purpose much better. JSON works better as a language independent serialization format that is incidentally readable.
Yeah json is a fact of life, the fact yaml exists doesn't change that. Actually, toml is even better than yaml and yet...
Things can change. Push the world forward. Think of little things you can do that make the world of development the world you want to be in.
Re: A modest proposal
#135Earlier quoted context omitted.
Mm, fair point. Infix math rears its ugly head again. I've been living in Lisp a bit too long. Never mind. Actually, let's double down: Instead of writing 1+2, you should really be writing +(1 2). Don't you see how much easier that would make things? A single, uniform syntax everywhere! + is just a function that gets called like anything else! Your foo(x -y) example would become foo(x -(y)). I'm mostly joking.
It's not infix math that's the problem, it's the ambiguity of "-". It can take two arguments in one context, or one in another (or just be a representation of a negative number without implying any function call at all.) If we just used a different symbol for subtraction, it would clear up a number of other parsing problems languages run into. Or you could just require negations to be done inside parentheses.
res = -x ==> negative x
res = c - x ==> c minus x
res = - x ==> syntax errorRe: A modest proposal
#136Earlier quoted context omitted.
It's not an opinion however. JSON is a standard. Kinda worries me professionals use it without having a clue.
That JSON has a "good reason" for disallowing comments is an opinion, it could be a popular, well-known and established opinion or it could be completely uninformed. To know the difference one must explain it. Also standards change, and professionals use their tools in ways the original creators did not imagine a lot, that doesn't make them clueless. Heck, even JSON is a result of professionals misusing a programming…
Re: A modest proposal
#137Earlier quoted context omitted.
It may be used as such but it shouldn't be. YAML serves this purpose much better. JSON works better as a language independent serialization format that is incidentally readable.
YAML can go off and die in a fire... especially because it cannot transfer the data type, which JSON can: you have either an integer, a float or a string. Also some libraries want the values escaped, some not, some barf on non-alphanumeric keys... JSON is pretty much standardized across the board.
TBH, common JSON implementations have their problems too. Integer size and integer/float (de-)serialization tend to be somewhat interesting at times. I've even seen implementations serializing JavaScript objects as JSON (e.g., {foo: 2} instead of {"foo": 2})
Re: A modest proposal
#138Earlier quoted context omitted.
JavaScript does allow commas at the end of a list! :) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Not if you want your code to work in certain versions of Internet Explorer :(
(1) where nobody = limit(somebody) -> 0
Re: A modest proposal
#139Earlier quoted context omitted.
That's the problem with using "a modest proposal" for serious suggestions: you're supposed to use it for satire.
Wait, so is the op actually suggesting we be able to use commas? I thought op meant to say people who want to use commas are exactly like people who want to eat human babies to solve the problem of child poverty.
Yes, I think they do.
The author just borrowed the title of Swift's article in the sense "here's a fun title based on a historical reference, for something that, for once, it's indeed a modest proposal".
They didn't intend it in the exact same way Swift intended it.
Re: A modest proposal
#140Scanning the comments I don't see my reason for wanting trailing commas: version control. You want to preserve the history of your code and to be able to easily query your VC system about the providence of each line of code. I want to add a new item to the end of the list, I also need to add a comma to the end of the previous line. This makes my commit larger than needed and it muddies the code history. Just let me m…