Hacker News new | ask | show | jobs
by breck 4582 days ago
Edited. Should have said "encoding language".

Here are some examples of space in action:

- http://sender.nudgepad.com/demo.html

- http://nudgepress.com/

It is very useful. Happy to answer questions about it.

4 comments

What does this give you over e.g. YAML, which has widespread support?

Not that I like YAML either - I detest encodings that depend on indentation for meaning...

It's much simpler than YAML. Some might argue too simple, but there's enough there for many use cases.
Is there a spec or a grammar somewhere?

Edit: here we go https://github.com/nudgepad/space/blob/master/spec.txt

Its list handling seems broken? tojson(fromjson(x)) !== x.

Paste { "name": "John", "age": "29", "foo": [1,2,3] } into the JSON side, and click in the left and move the cursor to force it to update and see what happens (I see it drop the first two list items).

Correct. We can turn all JSON to Space easily, but there's no canonical way to turn all Space into JSON (although you can do it easily for a particular use case).

Unlike JSON, in Space order is important and you can have duplicate properties. So in JSON you can't do this:

``` { 'h1' : 'hello world', 'h1' : 'this is a test', } ```

But you can do that in Space.

It can't handle lists. A spaces object is a JS object whose keys contain no newlines or spaces, whose string values contain no newlines, and whose non-string values are spaces objects (definitely not null/boolean/number/array).
Why would you use this over JSON? Looks like if your application makes heavy use of arrays, space will take way more 'space' than JSON.

eg: {"test":[1,2,3]} vs test\n item 1\n item 2\n item 3\n

Space is great for building DSLs on top of. You often want to have additional types that your domain specific code recognizes. For example, your example could also be written in a DSL that is also valid space:

``` test [1,2,3] ```

Space is best for cases where you have small to medium sized objects that are often viewed/edited by humans, such as APIs, config files, schemas, or database objects.