Bootstrapping in itself is already a somewhat magical concept even when done in a serious way. I remember the first time I wrote a compiler quite distinctly. There is something special about building something that can build itself. I think it embodies the potential of programming in an absolutely unique way.
How is gojq different? Cursory look at the README and it seems like it implements the same language.
My problem is the infrequency with which I need to use jq means I don't create a good learning feedback loop. The last time I used it though, I was able to walk down a decently complicated structure (indexed val in an array in a key in a hash in an array) and extract the data I wanted only having to google once. Like awk, though, I know there's a world of functionality I'm just not using.
It is indeed a reimplementation of jq in go, and the reason I use it over jq is many, one of which is that it produces more helpful error messages. In fact, I've moved jq to ojq (sometimes I want to check compatibility), and ln -fs gojq jq.
The manual (https://stedolan.github.io/jq/manual/) somewhat provides that. Quite a few sections have helpful examples, with links to the sandbox at jqplay.org.
The IMO not so good parts of that page are
- Quite a few section headers don’t make sense to novices
- I think the table of contents would be better if it had subheaders, ideally with one-line descriptions of the features (that probably would solve the issue above)
- not every section has examples
- some examples use fairly advanced features, making them harder to understand then necessary
I use it a bunch to string together web APIs, and you're absolutely right. The longer I go relying on my library of pre-written strings of commands, the harder it is to write a new one. And you're right again with your second point, because that same library makes for great reference material for myself.
jq is not OK for that exact reason. It's like sendmail, dividing the world into people smart yet obtuse enough to sit and learn its idiosyncrasies, and regular people that go mad and claw their eyes out whenever they try.
I tried, more than once, but I guess I'm not smart enough.
gron is great, i have this in my init.jq file for fq (https://github.com/wader/fq). Sadly jq lacks a path_to_expr function so a bit harder to do it with that.
Have jq always been a fully-capable turing-complete language? Or did it become this monstrosity step by step, somewhat naturally? I wasn't even aware until today that it's… uh… a programming language.
I think it has been turing complete for a long while. Here is the first prototype in haskell before it was convert to C https://github.com/stedolan/jq/commit/eca89acee00faf6e9ef55d..., it's very basic but i would guess it has enough things to be turing complete.
How does this language implementations in the language itself works? Isn’t it trivial to implement any feature, given it’s already implemented? They use lower level features to implement higher level ones?
Sure, you can implement the primitives by just passing through to the host runtime if you want, but you still have to parse the source and walk the AST first.
Hi author of jqjq here. I don't know why Stephen Dolan designed the jq language the way he did. But for me the most attractive things about jq is the terse and pipe-friendly syntax. This allows you to write queries in shells and REPLs without the need of multiple lines, and it's easy to compose add addition pipes. And by using generators/backtracking you can do complicated traversals over tree and list without much syntax.
Now after using jq a lot think about it the other way around. The language itself is no that tied to JSON, it can be used for more things with other types then just JSON. If you interested have a look at https://github.com/wader/fq where i've tried to expand on it.
Has this happened to you? You're logged into a remote server and trying to read a config file or log file. The problem is its in a minified JSON format and looks like a solid wall of noise when you try to use `less`. You reach for your go-to JSON swiss army knife `jq` but it's not installed! You don't have root access to install it via `apt-get` so you need a script you can run locally. Just copy the `jqjq` and `jqjq.jq` files to your local directory, and now you can access the full power of jq just by running `./jqjq`. Problem solved! And the best part is that the only dependency is `jq`, which should be installed pretty much everywhere.
Jokes aside, this is a actually a pretty common scenario for some people, and I wrote a tool called Exodus to solve it [1]. Exodus makes it trivial to relocate Linux binaries like jq from your local machine [1]. You can simply run
exodus jq | ssh my-server
locally, and then immediately have access to jq on the server. I personally find it very useful when working with servers or containers that have limited package repositories or where I don't have root access.
>Exodus handles bundling all of the binary's dependencies, compiling a statically linked wrapper for the executable that invokes the relocated linker directly, and installing the bundle in ~/.exodus/ on the remote machine.
https://github.com/xoreaxeaxeax/movfuscator
Presentation of idea:
https://m.youtube.com/watch?v=R7EEoWg6Ekk