Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

let's see:

jq does JSON parsing. And does it really well. Check.

jq does filtering jq does projection (. operator, .[] operator, select etc) jq builds objects (the {} operator) jq does arithmetic (addition, subtraction, division, multiplication) jq does database-like "lookups" in collections (keys, has, length etc) jq does pipelining of the in-tool "objects". jq does object generation of new objects like range operators etc. jq does data type conversions jq does sorting, grouping, extracts min/max etc. jq does string interpolation and string formatting jq does equals and relational comparisons, tests and other boolean tests.

awk does many of these too.

bash has some boolean tests, but typically very filesystem or envvar centric.

In general, when using shells and tools:

Sorting should be handled by sort. Except when it is handled by jq or by ls or by find or by ps or ....

Filtering should be handled by grep. Except when it is handled by ls or by find or by ps or by jq or by awk or ...

Formatting is always handled by each and every command. Which is understandable given that the format of each line is so important.

Now consider PowerShell where ConvertFrom-Json does one thing: Converts text from JSON to objects. Where-Object (aliases ?, where) does filtering. On any type of object. Sort-Object (alias sort) does sorting. On any type of object. Select-Object does projections. On any type of object. Format-Table, Format-List and other Format- cmdlets formats objects to human-readable output.

The text protocol does not scale well with structural complexity. It is really only good for lines of text. It has been somewhat enhanced to be able to delimit fields which then makes for an informal tabular-like protocol.

The object protocol scales with structural complexity. That's the difference.



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

Search: