3 ms·
Nice work! I also learned about gojq [0] yesterday too. A Go clone of jq that you can also embed in Go code. [0] https://github.com/itchyny/gojq https://github
by eatonphil 5y ago
Nice work! I also learned about gojq [0] yesterday too. A Go clone of jq that you can also embed in Go code.
[0] https://github.com/itchyny/gojq https://github.com/itchyny/gojq
Edit: oh unlike jq/gojq your tool doesn't implement the jq language it allows you to script in Go. Cool! And interesting to see your use of the Yaegi interpreter for interpreting the Go.
I'm curious, did you find it faster to interpret with Yaegi vs just writing the Go code to a temp file and build/running that? I imagine at some point for larger datasets the latter approach would be faster?
- errnil 5y agoPrecisely. The first pass generated a temp file and compiled/ran it, but that lead to annoying pauses when trying to run simple scripts (probably 500ms latency? Maybe a tad more?). Yaegi cut that latency dramatically. I think you’re right that this may make it slower for larger scripts or for sufficiently large inputs, however the biggest bottleneck for me with jq isn’t performance but learning it’s language repeatedly.
- tedunangst 5y agoyaegi is pretty fast. Not compiled fast, but it can chug through some pretty large tree walks without trouble. (Using it for walking html processing.) Half the work is parsing, which is using the compiled library.
- eatonphil 5y agoCurious what is your scenario for using yaegi and not Go itself? You allow users to run arbitrary Go somewhere?
- tedunangst 5y agoInstant reloads for changes.