Live data from Hacker News

Q: A faster re-implementaiton of jq written in Reason Native/OCaml

github.com

171–180 of 196 posts

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#171

The speed is not concern for me. I am wondering if there something better than `jq` in terms of syntax. Whenever I want to get something more that just prettify json output in the console or simply get value by specific field name I have a problem, for me it is just difficult to remember jq syntax without looking into history. As well have in my notes links to examples like this one https://mosermichael.github.io/jq-…

My humble attempt https://github.com/jsqry/jsqry-cli2

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#172
post #82

For everyone pining for a Jq with a different syntax: I have a bunch of links to alternatives collected, you might want to try some of them (some may be for different things than JSON): https://github.com/fiatjaf/awesome-jq https://github.com/TomConlin/json2xpath https://github.com/antonmedv/fx https://github.com/fiatjaf/jiq https://github.com/simeji/jid https://github.com/jmespath/jp https://github.com/cube2222/jql…

Sorry, what is "Hy"?

A lightweight Lisp on top of Python.

Personally I'd prefer Fennel, which is on Lua and thus a whole lot faster, especially in regard to the startup time—but as I noted in a thread on Fennel, Lua's omission of a proper ‘null’ makes it awkward to handle exchange and transformations of data from third parties. And, since I'm likely to fiddle with the queries for some time, startup delay is less important here.

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#173
post #114

Earlier quoted context omitted.

Tools that accept filenames often expect you give them a real file, as they’ll do things on it that may not be supported by the various “it’s a file descriptor pretending to be something on disk” solutions.

Hm, do you have any examples handy? It's not that I don't believe you, it's just that in all the years I've been using this, it has always worked. Granted, I'm only using it for reading data, not for saving stuff to /dev/stdin, which would obviously fail.

`file` on BSD/OSX has this notice for the option '-s':

> Normally, file only attempts to read and determine the type of argument files which stat(2) reports are ordinary files. This prevents problems, because reading special files may have peculiar consequences.

One example that comes to mind is /dev/urandom, which sucks randomy values out of the entropy pool (at least in Linux)—and the pool can be exhausted, or at least it could back in the day, not sure about now. Other possible cases are things in /proc (though unlikely), and particularly stuff like serial ports—where presumably reading could gobble data intended for some drivers or client software.

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#174
post #82

For everyone pining for a Jq with a different syntax: I have a bunch of links to alternatives collected, you might want to try some of them (some may be for different things than JSON): https://github.com/fiatjaf/awesome-jq https://github.com/TomConlin/json2xpath https://github.com/antonmedv/fx https://github.com/fiatjaf/jiq https://github.com/simeji/jid https://github.com/jmespath/jp https://github.com/cube2222/jql…

My personal favorite solves the same problem but attacks it differently.

> Make JSON greppable!

> gron[1] transforms JSON into discrete assignments to make it easier to grep for what you want and see the absolute 'path' to it. It eases the exploration of APIs that return large blobs of JSON but have terrible documentation.

  ▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author"
  json[0].commit.author = {};
  json[0].commit.author.date = "2016-07-02T10:51:21Z";
  json[0].commit.author.email = "mail@tomnomnom.com";
  json[0].commit.author.name = "Tom Hudson";
[1] https://github.com/tomnomnom/gron

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#175
post #81

Earlier quoted context omitted.

Much Unix software today is written by people who really don't appreciate or understand Unix. It leads to things like Homebrew (early on, at least) completely taking over and breaking /usr/local; to command-line utilities using a single dash (-) precending both short and long option names (granted, --long-opts is a GNUism, but it's a well-established standard); commands that output color by default even when the outp…

The `go` program uses -longopts and I think it would be hard to argue that Rob Pike lacks an appreciation of Unix traditions.

Rob Pike explained it thusly in a 2013 Google Groups reply:

> Rob 'Commander' Pike

> Apr 2, 2013, 6:50:36 AM

> to rog, John Jeffery, golan...@googlegroups.com

> As the author of the flag package, I can explain. It's loosely based on Google's flag package, although greatly simplified (and I mean greatly). I wanted a single, straightforward syntax for flags, nothing more, nothing less.

> -rob

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#176

Earlier quoted context omitted.

I think at least two people in the thread pointed out that you can use /dev/stdin as a file.

It's more than a little strange that isn't default behavior out of the box without specifying input. How do the authors think jq is used?

I'm pretty sure the author has also replied elsewhere saying he will add it since it was brought up as a concern.

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#177

Earlier quoted context omitted.

I think at least two people in the thread pointed out that you can use /dev/stdin as a file.

That’s a cumbersome extra step for unclear benefit. Yes, q is supposedly faster than jq. But it is exceedingly rare for me to ever have any performance problems with jq, especially since it’s essentially a one off utility I use occasionally, not as part of the hot loop of any workflow where performance matters.

In that case I suppose you wouldn't use it.

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#178
post #82

For everyone pining for a Jq with a different syntax: I have a bunch of links to alternatives collected, you might want to try some of them (some may be for different things than JSON): https://github.com/fiatjaf/awesome-jq https://github.com/TomConlin/json2xpath https://github.com/antonmedv/fx https://github.com/fiatjaf/jiq https://github.com/simeji/jid https://github.com/jmespath/jp https://github.com/cube2222/jql…

My personal favorite solves the same problem but attacks it differently. > Make JSON greppable! > gron[1] transforms JSON into discrete assignments to make it easier to grep for what you want and see the absolute 'path' to it. It eases the exploration of APIs that return large blobs of JSON but have terrible documentation. ▶ gron "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author"…

Gron and Jq are like peanut butter and jelly. Also gron has `gron -u` (ungron) to turn the pivot back into json.

Re: Q: A faster re-implementaiton of jq written in Reason Native/OCaml

#180
post #35

Curious, any description as to why it's faster? Something intrinsic to Reason Native/OCaml? Architectural changes? Reduced feature set?

Jq appears to have its own hand written json parser and requires flex/bison. I suspect something about the hand written parser is slow for large data sets. I was somewhat surprised it didn't use an existing json parser library.

I'm doubly surprised that such a popular utility uses bison; generated parsers tend to be slower than handwritten parser, and JSON isn't exactly the world's hardest language to parse
Post reply on HN