Hacker News new | past | comments | ask | show | jobs | submit login

[flagged]



I do not think parsing json requires a full blown javascript engine.


Neither does a graphical front end but that’s never stopped them.


Just out of curiosity, what would be your proposal to use instead?


>Some front end clown is about to suggest all tools should output json by default aren’t they

This unironically sounds good (and, in case this matters, I'm not a front end "clown", but a reverse engineer who mostly uses C and Python). Unified formatted output from command line tools is a thing that is severely missing from unix ecosystem.


Json is maybe a bit heavy, but using a machine readable format such as tsv or csv (including configuring your terminal emulator to properly display it) would be a big step up from the status quo.


What do you suggest? Have 100 different ways to parse output? Think about the resulting code bloat.

And no, you don't need V8 to parse JSON.


Do you really think outputting a stream of JSON, as opposed to plain text, would add any measurable overhead to all command line tools?

Honestly, I'd love this. Output one JSON object per file, bash already has hash tables and lists, so it has all the types we need for JSON already.


Ever heard of jq?


sadly JSON does not handle non-utf8 strings


Is that a problem for this application, though? Don’t most people encode their file names in utf8, or is that an ASCII-centric falsehood?


if ls returned json then it would have to decide what to do with non-utf8 filenames (or even users and groups, I do not know what the rules are there); it could reture either "filename.txt" or {"encoding":"base64", "data":"<base64 blob>"} to obviate the problem but it is not a very elegant solution


An extension of this could be to also input everything in json: {"command":"ls", parameters: ["-l"]}, etc.


Didn't Microsoft try to define something like that with Powershell, with parameters being objects (though not JSON)?


But hey, at least it's not YAML!


The funny thing is that so so many bits of info come in very much like but not quite yaml.

e.g. /proc/cpuinfo


Of course, with some k8s yaml we can run all our cli tools in separate containers each with their own userland.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: