Description
The C++ jsonnet implementation is orders of magnitude slower than the golang implementation. I hit the issue using std.sort() but the issue may very well be broader than that. Both were run with v0.16.0. The attached example uses a 10000 element list but the issue is still obvious down with lengths around ~1000. Based on my testing it appears the C++ version also scales worse than golang as the problem size increases.
C++
$ time $(./jsonnet test.txt &> /dev/null)
real 0m18.887s
user 0m18.800s
sys 0m0.085s
golang
$ time $(~/.go/bin/jsonnet test.txt &> /dev/null)
real 0m0.079s
user 0m0.095s
sys 0m0.017s
As far as I can tell C++ is still the recommended "reference" implementation, so it's quite surprising to see it perform so poorly. I originally hit the problem evaluating jsonnet through Python bindings ("jsonnet" module) -- there is an analogous gojsonnet module but that requires installing the entire golang toolchain, which is an absurdly heavy dependency just for evaluating jsonnet.
I know nothing about the jsonnet codebase, but just poking around for 5 seconds it appears they supposedly share the same std library implementation (which is written in jsonnet), so at first glance this behavior was even more surprising. Digging slightly deeper, however, it looks like the golang implementation ends up overriding certain functions in builtins.go (presumably to fix performance issues). If that's true, it seems like the same steps should have also been taken in the true "recommended" C++ implementation (or better yet just fix in the std library itself and remove the implementation-specific behavior).