logoalt Hacker News

bouktoday at 9:56 AM2 repliesview on HN

I highly recommend anyone to look at jq's VM implementation some time, it's kind of mind-blowing how it works under the hood: https://github.com/jqlang/jq/blob/master/src/execute.c

It does some kind of stack forking which is what allows its funky syntax


Replies

functional_devtoday at 10:19 AM

The backtracking implementation in jq is really the secret sauce for how it handles those complex filters without getting bogged down

vbezhenartoday at 10:12 AM

Looks like naive implementation of homemade bytecode interpreter. What's so mind blowing about that? Maybe I missed something.