News for hackers. Stuff that matters.
Re:Hjson, the Human JSON by jcoffland on Thursday April 14, 2016 @12:48PM (#11498277)
I came here to make the same comment. The ability to leave off quotes on strings is a misfeature which overly complicates the language. Also I see no need for three different comment styles.
Re:Hjson, the Human JSON by PhiLho on Friday April 15, 2016 @06:53AM (#11503367)
Yes! There is the same ambiguity in Yaml, so syntax highlighters of the format don't agree where a string ends...

The site even has an ambiguous example: three: 4 # oops Well, is that "4 # oops" or 4? I saw no rule about ending comments, and they say that three: 3 times is a string.

I have seen no formal specification of the grammar, so we already have lot of ambiguity. Good luck to implementers...

Seriously, removing the "no quotes needed" rule would improve greatly the format. If you want to include HTML with double quotes literally, just use the multiline string format and be done.

Re:Hjson, the Human JSON by nix0n on Thursday April 14, 2016 @12:56PM (#11498371)
Use what you want, ignore the rest. Like C++.
Re:Hjson, the Human JSON by creshal on Thursday April 14, 2016 @01:28PM (#11498702)
That might work for programming languages (C++'s bad rep nonwithstanding), but for data exchange formats you cannot cherrypick features, you have to support the whole spec, and nothing else.
Re:Hjson, the Human JSON by kbenson on Thursday April 14, 2016 @04:41PM (#11500180)
I think it's more nuanced than that. You must be strict in what you emit, but can be liberal in what you accept. That liberalness can go too far though, and should not make parsing brittle, or encourage misuse of the spec. It's there more to allow someone's unambiguous mistakes to still parse.

- Accidentally left in a final comma on a list? That's okay, that only means one thing, we understand.

- Allow non-quoted keys on objects? Well, we understand JavaScript generally allows this, so we'll let it slide. This time.

- Make newline significant and define new items? Okay, are we just ignoring space efficient payloads now? Should making it space efficient mean changing formats from Hjson to json?

- Considering all terms in place of a object value a string until a newline? Are you just trolling me now? How is that more human readable? Does your spoken language not use quotes to distinguish distinct chunks of communication or something, and if so, does it use a Latin alphabet so it's off-putting when you see them?

Needless to say, I'm really confused by the reason this even exists.

Re:Hjson, the Human JSON by ZenPsycho on Thursday April 14, 2016 @05:57PM (#11500643)
I think the problem it is solving is that JSON is designed and best used as a data exchange format, but it also gets used for configuration files, which it does okay with but is not really so good. INI files don't have a clear standard. YAML is too complicated, and using turing complete javascript for configuration seems like you've just gone too far.

we just need JSON, but with a couple things fixed up to make it nicer to use for configuration files.

Re:Hjson, the Human JSON by kbenson on Thursday April 14, 2016 @06:30PM (#11500816)
> we just need JSON, but with a couple things fixed up to make it nicer to use for configuration files.

Using JSON for configuration is just the whole situation of using XML for data exchange redux. One of the major points for JSON over XML for data exchange was that it was so much better because it was optimized for data, not markup. Why are we ignoring this argument now that JSON is on the other side? JSON is used for configuration because it's ubiquitous, not because it fits the problem domain well. Let's just choose a more appropriate format.

Choosing the most common set of rules for INI files (what is proposed by Wikipedia[1] is probably sufficient) would serve us MUCH better than coaxing a data interchange format into that role.

1: https://en.wikipedia.org/wiki/INI_file

Re:Hjson, the Human JSON by lomnakkus on Friday April 15, 2016 @01:12AM (#11502339)
If you're using a strongly typed language, XML even has one (IMO) massive advantage over JSON: You can use XSD to define a schema declaratively. This means you get

(1) lots of general tooling support, in particular you get at least decent editor support for your config file, and

(2) you can autogenerate the code needed to read your configuration into structured data without having to do any unnecessary duplication of "key names" (tags) as you have to with e.g. INI or JSON. You also get the data sturctures themselves for "free" (based on the XSD).

Alright, it's not the end of the world to not have these things, but they're both very nice to have.

Re:Hjson, the Human JSON by ZenPsycho on Friday April 15, 2016 @06:38AM (#11503322)
have you seen http://json-schema.org ?
Re:Hjson, the Human JSON by lomnakkus on Friday April 15, 2016 @11:17AM (#11504983)
Yes indeed I have, and I have several problems with it, one of which is "Expires: August 3, 2013" with no new version in sight. My other major problem is that AFAICT it doesn't support one of my pet favorite features namely "Algebraic Data Types"[0, 1]. If you extend json-schema like Swagger has done it might support ADTs properly AFAICT, but I don't have any actual practical experience with Swagger.

[0] https://en.wikipedia.org/wiki/Algebraic_data_type [1] I should note that support for ADTs in XSD is sometimes sketchy in the various code generators, but at least the XSD specification supports it. (It could also be argued that XSD supports something even more general... which it probably shouldn't since ADTs basically cover the whole data structure space unless you go to higher kinds, inheritance and such.)

Re:Hjson, the Human JSON by ZenPsycho on Friday April 15, 2016 @01:02AM (#11502293)
well basically virtually anything other than JSON that's actually designed to be configuration would be better for configuration. There's dozens of them. that is the problem: JSON parsers and generators are ubiquitous in the way that no single configuration format is. Right now, I can just use json in any language and get data between any language and any other language. If I use it for config I get the advantage of even being able to config across multiple languages that might be getting used in a single system if I have to. No proper configuration format has that level of mindshare and interoperation.
Re:Hjson, the Human JSON by thenonameguy on Thursday April 14, 2016 @08:34PM (#11501297)
Something like edn[1] perhaps? Worked really well in my projects.

[1]: https://github.com/edn-format/edn

Re:Hjson, the Human JSON by daurnimator on Thursday April 14, 2016 @10:48PM (#11501747)
Re:Hjson, the Human JSON by kbenson on Thursday April 14, 2016 @11:40PM (#11501933)
While I agree on some points, I do not agree in general. I think too much prescriptivism in protocol implementation is a naive approach, and assumes that we can always get things right initially. Sometimes real-world concerns and needs drive changes, not just sloppiness.
Re:Hjson, the Human JSON by talles on Thursday April 14, 2016 @01:16PM (#11498595)
I prefer to openly discuss the features while giving the authors feedback instead of just ignoring what I don't want, but that's just me.
Re:Hjson, the Human JSON by bpicolo on Thursday April 14, 2016 @01:45PM (#11498871)
Features that cause ambiguity make things harder to do right.
Re:Hjson, the Human JSON by d33 on Thursday April 14, 2016 @04:12PM (#11499967)
Well, the first thing I thought of is what nightmare would it be to safely implement a parser for this in C. I filed a Github issue for this one: https://github.com/laktak/hjson/issues/37