Hacker News new | ask | show | jobs
by cirwin 597 days ago
Funnily enough, I've been working on solving the same problem concurrently. Though in my _very_ biased opinion; I think CONL is easier to read and write:

https://github.com/ConradIrwin/conl

  value = example

  map
    a = b

  list
    = 1
    = 2

  multiline_value = """bash
    #!/usr/bin/bash
    echo "hello world"
1 comments

Agreed that this is much better than the OP. That said, my general opinion is that a whitespace-only indentation should be avoided especially in the serialization format due to the inherent ambiguity of whitespace characters and resulting human mistakes. When I designed CSON [1] I strived to make it as readable as possible without the indentation for that reason.

[1] https://github.com/lifthrasiir/cson

Nice – I like your verbatim syntax for multiline strings!

I went with indentation because a very common use-case in a configuration file is commenting out lines. Even with CSON-like comma rules, you still need to balance your {} and []s. Indentation balances itself most* of the time.

Indentations are still desired for most human tasks indeed! But you can have indentations and groupings at once, one complementing each other. As you've noticed, CSON's verbatim syntax was intentionally designed so that it remains valid without any indentation but your instinct really wants to align those lines anyway. (A similar approach can be seen in Zig verbatim strings, which seem to be designed independently from CSON and make me much more confident about this choice.)
Indentation in xᴇɴᴏɴ is optional and for readability.
I mean it can be encoded inline, including using \n in strings