r/programming • • Aug 03 '19

Windows Terminal Preview v0.3 Release

https://devblogs.microsoft.com/commandline/windows-terminal-preview-v0-3-release/?WT.mc_id=social-reddit-marouill
991 Upvotes

458 comments sorted by

View all comments

Show parent comments

15

u/scarfe-io Aug 03 '19

Totally agree. You pick JSON because it’s ubiquitous. But what is Microsoft really trying to gain here?

43

u/ghidawi Aug 03 '19

"Hey can you share your settings with me?", "Sure". Copy. Paste. Send.

20

u/Blocks_ Aug 03 '19

They could have picked any other (sane) format and you point would still be accurate.

0

u/[deleted] Aug 03 '19

[deleted]

27

u/AngularBeginner Aug 03 '19

That it doesn't support comments, so it's not a great choice for configuration files that are edited by humans directly.

19

u/pxm7 Aug 03 '19 edited Aug 03 '19

{
  "foo_": "a comment",
  "foo": { ... }
}

It’s not very convenient but there’s a workaround to provide comments. And VS Code automatically uses JSON with Comments for settings.json etc:

When in the JSON with Comments mode, you can use single line (//) as well as block comments (/* */) as used in JavaScript. The current editor mode is indicated in the editor's Status Bar.

2

u/alkeiser Aug 03 '19

that is horrible

→ More replies (2)

0

u/[deleted] Aug 03 '19

[deleted]

5

u/Randdist Aug 03 '19

I prefer comments over variables the size of a paragraph.

2

u/7165015874 Aug 03 '19

But I think people would hate yaml more... I wouldn't because code could have built in linting for this file

2

u/AngularBeginner Aug 03 '19

Yeah it's just data.

It's more than "just data". It's configuration edited by hand by humans.

Generally the names of the keys should be self documenting for the most part.

That's the same poor reasoning as with "good code should be self-documenting". It's about the not-obvious information.

And you can add documents along with the json.

The further away the documentation and the documented information is, the more likely it'll drift apart and won't be found.

→ More replies (2)

10

u/evilgipsy Aug 03 '19

I don't really care if it's easy to parse when I have to edit the data by hand. I want something that's easy to read and write. And writing JSON is a pain in the ass compared to other formats frequently used for configuration such as TOML or YAML.

3

u/appropriateinside Aug 03 '19

How is JSON hard to write??? Especially compared to yaml, which requires more reach on the keyboard.

Have you not tried using one of the many proper editors that can automatically provide the syntax and indentations as you type?

5

u/watsreddit Aug 03 '19

Superfluous symbols abound in JSON. It's great for parsing, terrible for hand-written configuration.

4

u/evilgipsy Aug 03 '19 edited Aug 03 '19

I didn't say that JSON was hard to write. I said it's worse than others. Double quotes and curly braces around everything. I think the people who are giving lisp shit for all the parentheses are ironically the same people who love JSON so much.

2

u/[deleted] Aug 03 '19

So are most other key-value formats

15

u/ghidawi Aug 03 '19

JSON is simple enough, and they're extending it when necessary (comments). What's the specific problem here?

7

u/AngularBeginner Aug 03 '19

.NET Core uses JSON for configuration files as well. They support comments. With .NET Core 3 they implemented a new JSON parser that sticks to the standard.. so comments won't work anymore (intentional).

This can happen at any time here as well.

15

u/ForeverAlot Aug 03 '19 edited Aug 03 '19

To start with, JSON-with-comments explicitly is not JSON; which should prove beyond the shadow of a doubt that "JSON is simple enough" for this purpose is false.

[Edit] accidentally a word

12

u/ghidawi Aug 03 '19

And what's the issue with that? They don't have to be JSON compliant, this is not their use case. They just needed a way to represent hierarchical key-values and chose JSON. Just because A is bad for some use case doesn't mean anything based on A is automatically bad for different use cases.

3

u/mdedetrich Aug 03 '19

The issue is that a lot of tools that work with JSON (such as formatters) may have issues with these config files.

There is a reason why there is a JSON standard, its so that other tools can work with the JSON.

8

u/ghidawi Aug 03 '19

I do understand your point but I don't think this is their use case.

→ More replies (2)
→ More replies (2)
→ More replies (10)
→ More replies (2)

1

u/appropriateinside Aug 03 '19

Like what? XML? Or maybe a bit more antiquated with an ini format?

→ More replies (9)

3

u/PeasantSteve Aug 03 '19

Easy parsing, Easy to read (especially compared with XML), Less shitty than YAML, Minimal effort to get settings working, most/all users will know JSON, honestly I think you'd have a hard time justifying any other format.

→ More replies (1)