1# jrsonnet2345## What is it67[Jsonnet](https://jsonnet.org/) is a data templating language89This Rust crate implements both jsonnet library and an alternative `jsonnet` executable based on it. For more information see [bindings](#Bindings).1011## Why?1213There already are multiple implementations of this standard implemented in different languages: [C++](https://github.com/google/jsonnet), [Go](https://github.com/google/go-jsonnet/), [Scala](https://github.com/databricks/sjsonnet).1415This implementation shows performance better than all existing implementations. For more information see [benchmarks](#Benchmarks).1617In the end, it's always fun to implement something in Rust.1819## How to install?2021We build x64 binaries for Apple, Windows MSVC, and Linux GNU during the release process. If your system is one of those, you can check out the [latest release](https://github.com/CertainLach/jrsonnet/releases/latest) to get your pre-built binary. Otherwise, you'll need to have a rust toolchain and install the package through cargo with `cargo install jrsonnet`.2223## Compliance with the [specification](https://jsonnet.org/ref/spec.html)2425- Passes all the original `examples` tests2627- Passes all the original `test_suite` tests except for those which require stacktraces identical to the default implementation (while also being available, vanilla-like stacktraces are not 100% identical):2829 ```jsonnet30 ## Explaining format31 ```32 RuntimeError("3")33 --> /home/lach/jsonnet-rs/a.jsonnet:1:2534 |35 1 | local a = "%0 10.20d" % error "3";36 | ^^^^^^^^^ error statement37 |38 --> /home/lach/jsonnet-rs/a.jsonnet:1:1139 |40 1 | local a = "%0 10.20d" % error "3";41 | ^^^^^^^^^^^^^^^^^^^^^^^ function <mod> call42 |43 --> /home/lach/jsonnet-rs/a.jsonnet:6:644 |45 6 | a: a,46 | ^ variable <a>47 |48 --> /home/lach/jsonnet-rs/a.jsonnet:3:649 |50 3 | b: self.a,51 | ^^^^^^ field access52 |53 --> /home/lach/jsonnet-rs/a.jsonnet:9:154 |55 9 | e.b56 | ^^^ field access57 |58 ```5960 ## Compact format (default)61 ```62 RuntimeError("3")63 /home/lach/jsonnet-rs/a.jsonnet:1:25-35: error statement64 /home/lach/jsonnet-rs/a.jsonnet:6:6-8 : variable <a>65 /home/lach/jsonnet-rs/a.jsonnet:3:6-13 : field access66 /home/lach/jsonnet-rs/a.jsonnet:9:1-5 : field access67 ```6869 ## Vanilla format70 ```71 RUNTIME ERROR: 372 a.jsonnet:1:25-34 thunk <a> from <$>73 <std>:237:21-22 thunk from <function <anonymous>>74 <std>:754:20-24 thunk from <function <anonymous>>75 <std>:32:25-26 thunk from <function <anonymous>>76 <std>:32:16-27 function <anonymous>77 <std>:754:8-25 function <anonymous>78 <std>:237:7-23 function <anonymous>7980 a.jsonnet:6:6-7 object <d>81 a.jsonnet:3:6-12 object <c>82 a.jsonnet:9:1-4 $83 During evaluation84 ```85 ```8687## Bindings8889Jrsonnet provides a standard `libjsonnet.so` shared library and should work as drop-in replacement for it9091WASM bingings are also available, Java bindings (Both JNI and WASM compiled to .class) are in progress9293See [bindings](./bindings/) for more information.9495## Benchmarks9697This is the fastest implementation of jsonnet both according to official benchmarks and real-life cluster configuration templating speed.9899Official benchmark results are available [in this gist](https://gist.github.com/CertainLach/5770d7ad4836066f8e0bd91e823e451b) which may get updated sometimes. It shows tests against Golang, C++ and Scala implementations showing the best performance in all cases.100101You can generate this report via provided nix flake102103## TO-DO list104105- [ ] Create docker container for easier benchmarking and/or benchmark in CI106- [ ] Implement and utilize mutable strings, arrays and objects instead of COWing when possible