Live data from Hacker News

Zq: An easier and faster alternative to jq

brimdata.io

81–90 of 237 posts

Re: Zq: An easier and faster alternative to jq

#81

The name of its corporate progenitor may leave a bad taste in some mouths, but I highly recommend PowerShell for this sort of thing. It's cross platform, MIT licensed, and comes with excellent JSON parsing and querying capabilities. Reading, parsing, and querying JSON to return all red cars: Get-Content cars.json | ConvertFrom-Json | ? { $_.color -eq 'red' } The beauty of this is that the query syntax applies not jus…

I conceptually like pwsh, but even as your example shows, I don't have the RSI budget left to spend on typing that extremely verbose expression every day

jq and its unix-y friends allow me to trade off expressiveness against having to memorize arcane invocations

Re: Zq: An easier and faster alternative to jq

#82
post #16

Earlier quoted context omitted.

> They also make some performance claims towards the end of the article. essentially a marginal speed increase they think on json, but a much bigger speed increase (5x-100x they claim) if you switch to their native format ZNG. if I'm switching formats completely, I'm not sure why I care about jq vs zq in json performance ...

Marginally faster is better than marginally slower, at least. I agree the JSON use is probably more compelling than their ZNG thing.

> I agree the JSON use is probably more compelling than their ZNG thing.

considering how much data I can already get via json (or converted to json via other json related standards such as geojson), there doesn't seem to be much of a compelling case to use ZNG.

I'd love to hear different though!

Re: Zq: An easier and faster alternative to jq

#85
post #46
post #34

jq is awesome, last time I used it is... today :) Or rather the pure Go rewrite https://github.com/itchyny/gojq which is a better faster implementation, with bugs fixed

The better error messages alone make this an improvement over jq IMHO.

And if it's maintained, that's also a plus, since I didn't realize jq was unmaintained, I thought it just didn't have any bugs to fix

Re: Zq: An easier and faster alternative to jq

#86
post #74
post #6

Since no one seems to know about it, jq is described in great detail on the github wiki page [0]. That flattens the learning curve a lot. It's not as arcane as it seems. The touted claim that is fundamentally stateless is not true. jq is also stateful in the sense that it has variables. If you want, you can write regular procedural code this way. Some examples [1] The real problem of jq is that it is currently lackin…

Sadly very few authors seem to acknowledge or even know that github wiki pages are not indexed by search engines so if it wasn't for third-party sites like github-wiki-see.page (which could stop working at any time) their contents would be undiscoverable by the very same people they are usually intended...

What? That's crazy! Does Github block indexing?

Re: Zq: An easier and faster alternative to jq

#87
post #4
post #2

It takes a while to get to the point so I’ll save others some time and tldr this very lengthy and agenda-driven blog post: jq had a tough learning curve so you should switch to zq which is a (closed source?) wrapper around an obscure language you’ve never heard of that we promise is easier because reasons. Also coincidentally it’s the language of an ecosystem we were funded to build. Edit: mea culpa, turns out you ca…

Closed source? https://github.com/brimdata/zed/blob/main/runtime/query.go Yes, it’s an obscure query language. But if you were interested in jq, that clearly wasn’t a barrier to entry. I agree the author is happy to show off their tool, but disagree that that is somehow disqualifying. They made a cool thing, they’re allowed to be proud about it.

And it's BSD 3 Clause, for those interested: https://github.com/brimdata/zed/blob/v1.0.0/LICENSE.txt

Re: Zq: An easier and faster alternative to jq

#88
post #6

Since no one seems to know about it, jq is described in great detail on the github wiki page [0]. That flattens the learning curve a lot. It's not as arcane as it seems. The touted claim that is fundamentally stateless is not true. jq is also stateful in the sense that it has variables. If you want, you can write regular procedural code this way. Some examples [1] The real problem of jq is that it is currently lackin…

> It's not as arcane as it seems. The issue with jq is that I use it maybe once a month, or even less. The syntax is "arcane enough" that I keep forgetting how to use it because I use it so sporadically. In comparison awk – which I also don't use that often – has a much easier syntax that I can mostly remember. Not entirely convinced by the zq syntax either though; it also seems "arcane enough" that I would keep forg…

Same issue. However, I do successfully rely on using ctrl-r a lot to search prior invoked commands. And have a few core aliases that I've cobbled together....

Re: Zq: An easier and faster alternative to jq

#90
post #81

The name of its corporate progenitor may leave a bad taste in some mouths, but I highly recommend PowerShell for this sort of thing. It's cross platform, MIT licensed, and comes with excellent JSON parsing and querying capabilities. Reading, parsing, and querying JSON to return all red cars: Get-Content cars.json | ConvertFrom-Json | ? { $_.color -eq 'red' } The beauty of this is that the query syntax applies not jus…

I conceptually like pwsh, but even as your example shows, I don't have the RSI budget left to spend on typing that extremely verbose expression every day jq and its unix-y friends allow me to trade off expressiveness against having to memorize arcane invocations

I hear that, I use and like *nix too. PowerShell aliases help a lot. It comes with some predefined, like `gc` for `Get-Content`. The above example could be rewritten:

  gc cars.json | ConvertFrom-Json | ? color -eq 'red'
`ConvertFrom-Json` doesn't have a default alias, but you can define one in your PowerShell profile. I do that for commands I find myself using frequently. Say we pick convjson:

  gc cars.json | convjson | ? color -eq 'red'
That's more like what my typical pipelines look like.

The nice thing about aliases is you can always switch back to the verbose names when clarity is more important than brevity, like in long-term scripts.

Edit: Seems I've been using too many braces and dollar signs all these years. Thanks to majkinetor for the tip.

Post reply on HN