4 ms·
Do you like writing jq? I really tried to like it, appreciated the ideas, but found even simple programs extremely hard to write in it. (Obviously, this is poss
by pasabagi 7y ago
Do you like writing jq? I really tried to like it, appreciated the ideas, but found even simple programs extremely hard to write in it. (Obviously, this is possibly just an artifact of me being thrown into a functional deep-end with an extremely terse syntax).
- cryptonector 7y agoIt took some getting used to... I "like" it the same way that I "like" writing XSLs: I thank my lucky stars that jq and XSLT/XPath exist, but if I didn't have to deal with JSON/XML I wouldn't use jq/XSLT. That reasoning seems circular, but at least jq is significantly more general than XSLT. Though to be fair I like jq a lot better than I like XSLT. All functional languages tend to take some getting used to, at least for me. Now that I have a mental model of jq, I do actually enjoy using it. The terse syntax is a double-edged sword.
- minxomat 7y agoThink of jq more like bash instead of a generic functional language. Blocks work on data and you pipe data along blocks. You can name blocks. That 99% of what you need to get to do jq. Here's a small example of a smaller ETL script a wrote a while ago for stats collection over scm repos: https://gist.github.com/turbo/36e87947a56cfaacec9d0356b3e521ba https://gist.github.com/turbo/36e87947a56cfaacec9d0356b3e521... As you can see it loads data from vars, fed by other jq scripts. Don't try to put everything in one script. Each script should basically just reduce and normalize.