News for hackers. Stuff that matters.
Re:Show HN: gq – like jq or zq, but you use Go by eatonphil on Wednesday April 27, 2022 @12:28PM (#31182106)
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

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?

Re:Show HN: gq – like jq or zq, but you use Go by errnil on Wednesday April 27, 2022 @12:36PM (#31182227)
Precisely. 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.
Re:Show HN: gq – like jq or zq, but you use Go by tedunangst on Wednesday April 27, 2022 @01:05PM (#31182680)
yaegi 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.
Re:Show HN: gq – like jq or zq, but you use Go by eatonphil on Wednesday April 27, 2022 @02:41PM (#31184053)
Curious what is your scenario for using yaegi and not Go itself?

You allow users to run arbitrary Go somewhere?

Re:Show HN: gq – like jq or zq, but you use Go by tedunangst on Wednesday April 27, 2022 @04:54PM (#31185660)
Instant reloads for changes.