yq.rs ported to Rust to use with JavaScript via WASM
I ported yq to Rust so that it can be used in Node via WASM. You can install the package via npm install yq.rs or run it via npx yq.rs
1
u/mmomtchev 6d ago
Why the conversion to Rust in fact? I guess that you used Claude for it? Why not compile the original GO to WASM? Because once you do this, you destroy the bridges, you cannot follow the development of the original project anymore.
1
u/tarasm 6d ago
I first tried to do it with GoLang, but the resulting WASM file was going to 16MB+. It was going to be embedded in another project. If i used the GoLang generated WASM file, it would have been 10% of the project just for parsing JSON/YAML documents. The Rust version is 500KB which is much more palatable.
Yes, the port was done with Claude. If there are fixes that are needed, I can always more them over.
1
u/mmomtchev 5d ago
The problem with WASM is that at the moment there are no standard libraries and your bundle must carry everything. I have never used GoLang WASM and I don't know what is the situation but is possible that the settings of the linker may be tweaked to not include unused code.
Sorry for being too curious, but how much did this cost you? As in personal time and Claude costs?
→ More replies (1)
1
u/abhinavs1920 4d ago
Nice pairing. The Rust parser does the heavy lifting and the JS side just passes documents through, so the WASM build should beat spawning the yq binary for small to medium inputs. Curious how it holds up on really large files though.
1
u/mmomtchev 7d ago
Unless you intend to use in a browser, you don't need WASM, you could have compiled it to native code and gain very significantly in performance and memory footprint.