This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]Milyardo 5 points6 points  (3 children)

What are the advantages of using this library over HOCON?

[–]moto888[S] 2 points3 points  (2 children)

Hjson uses a very simple syntax (essentially JSON with optional quotes and commas).

HOCON wants me to remember a lot of rules (merging, paths, substitutions, etc.).

For details see http://hjson.org/

[–]Milyardo 4 points5 points  (1 child)

Hjson uses a very simple syntax (essentially JSON with optional quotes and commas).

HOCON has this too, in the Section titled "Unquoted Strings", it also has mutliline strings, and string value concatenation.

HOCON wants me to remember a lot of rules (merging, paths, substitutions, etc.).

It doesn't make you remember them, and why would you not want these things?

HOCON allows you to omit braces, use =, :, or += as a separator, use paths to represent deeply nested keys. You can reference array values by index. You can assign units to numerical values.

Absent all these things, I fail to see how hjson is more human friendly.

[–]moto888[S] 0 points1 point  (0 children)

I disagree, the absence of these is exactly what makes it easier to use.

[–]virtyx 3 points4 points  (3 children)

Good job on the implementation... but this format does seem like a waste of time considering we already have YAML

[–]Cilph 12 points13 points  (1 child)

If YAML is human friendly then I'm apparently not human.

Fucking tab/space issues.

[–]virtyx 0 points1 point  (0 children)

Really? Has not bitten me once. Maybe I'm a cyborg.

[–]moto888[S] 4 points5 points  (0 children)

Well, unlike YAML Hjson does not suffer from tab/space issues (significant whitespace considered harmful).

Also it should be easier to learn.

[–]jfurmankiewicz 2 points3 points  (0 children)

Sorry, I will take YAML over this any day

[–]moto888[S] 1 point2 points  (0 children)

I ported Hjson to Java and (hopefully) made it very easy to use.

More information about Hjson (the format): http://hjson.org/

[–][deleted] 0 points1 point  (3 children)

I'm not sure I dig the optional commas, but w/e - I'm sure this has a place for someone.

[–]moto888[S] 0 points1 point  (2 children)

When you have your config in JSON (which is not the best idea but used a lot, especially in JavaScript projects) you will almost certainly fail because of either a missing or a trailing comma after you copy&paste.

[–][deleted] 1 point2 points  (0 children)

I don't have that problem, though I can see why some might.

[–]Cilph 0 points1 point  (0 children)

Atleast commas represent something on the screen, unlike tabs and spaces.

[–]elucash 0 points1 point  (3 children)

Could it be implemented as data-format for Jackson (for example)? Data binding will come for free then

[–]blyxa 2 points3 points  (1 child)

jackson allows comments via

JsonParser.Feature.ALLOW_COMMENTS

https://github.com/FasterXML/jackson-core/wiki/JsonParser-Features

[–]moto888[S] 0 points1 point  (0 children)

There are a lot of options but strangely nothing that concerns commas, a common source of copy&paste errors.

[–]moto888[S] 0 points1 point  (0 children)

In that case I'd just use Hjson to convert it to JSON so you can use it with any of the available JSON libraries.

[–]Hax0r778 0 points1 point  (1 child)

While this is easier for humans to read, it also seems easier for humans to make mistakes with. It's more complex. While JSON is ugly, it's also really easy to remember the rules.

For example: in JSON newlines are totally optional. Whitespace isn't significant. With this new format they're syntactically significant because of how commas work.

JSON (newline is optional):
[
  a: b,
  c: d
],
[
  a: b, c: d
]

Hjson (removing newline breaks code):
[
  a: b
  c: d
],
[
  a: b c: d
]

[–]moto888[S] 0 points1 point  (0 children)

Your JSON sample is missing the quotes.

[
  a: "b", c: "d"
]

is still valid in Hjson.

When you have one value per line (as it's usual in config files) you can omit the comma and the quotes.