ANALYSIS

How One Engineer Used AI to Rewrite JSONata in Go and Save $500K Per Year

E Elena Volkov Mar 27, 2026 Updated Apr 7, 2026 4 min read
Engine Score 8/10 — Important

This story details a highly successful, rapid AI-driven code rewrite of JSONata, resulting in significant annual savings and demonstrating practical AI application. It offers high actionability for companies seeking to optimize codebases and improve efficiency with AI tools.

Editorial illustration for: How One Engineer Used AI to Rewrite JSONata in Go and Save $500K Per Year
  • Reco principal data engineer Nir Barak used AI to rewrite JSONata from JavaScript to Go in seven hours, spending $400 in AI token costs.
  • The resulting Go library, gnata, achieved a 1,000x speedup on common expressions and eliminated $300,000/year in RPC fleet costs.
  • Combined with downstream pipeline optimizations the rewrite enabled, total annual savings reached $500,000.
  • The approach relied entirely on JSONata’s existing 1,778-test suite as a behavioral specification, with a seven-day shadow deployment to verify production equivalence.

What Happened

Nir Barak, a principal data engineer and architect at SaaS security company Reco, published a detailed case study describing how he used AI-assisted code generation to port JSONata, a widely used JSON query and transformation language originally written in JavaScript, into a pure Go implementation in a single working session.

The project produced gnata, a 13,000-line pure Go library implementing the full JSONata 2.x specification. Barak completed the initial working version in seven hours at a cost of approximately $400 in AI tokens. “Seven hours, $400 in tokens, a 1,000x speedup on common expressions, and the start of a chain of optimizations that ended up saving us $500K/year,” Barak wrote in the post. The case study quickly gained traction on Hacker News and engineering blogs.

Why It Matters

Reco’s policy engine evaluates JSONata expressions against billions of security events flowing through its data pipeline. The original architecture required Remote Procedure Calls between Go services and Node.js JSONata evaluators, adding approximately 150 microseconds of serialization overhead per evaluation. At Reco’s scale, that overhead translated to roughly $300,000 per year in compute costs for the RPC fleet alone.

Eliminating the JavaScript dependency removed the entire RPC layer. The native Go implementation runs in-process, cutting network serialization costs to zero. With JSONata evaluation now happening natively within the Go pipeline, Reco’s team was able to restructure the surrounding data processing stages, unlocking further pipeline optimizations that added another $200,000 in annual savings.

Technical Details

The rewrite used what has been described as “vibe porting,” a technique where an existing test suite serves as the complete behavioral specification for the target implementation. JSONata’s official test suite contains 1,778 test cases covering the full language specification. Barak fed these tests to an AI code generation model and iteratively built the Go implementation until all tests passed.

The approach mirrors a method Cloudflare used to port Next.js to its Workers platform. Rather than manually translating code line by line, the AI generates functionally equivalent code in the target language, with the test suite serving as the automated correctness checker.

After the initial implementation, Reco ran a seven-day shadow deployment. Both the original JavaScript and new Go implementations processed the same production traffic simultaneously, with outputs compared for equivalence. Only after confirming identical behavior across all production workloads did the team cut over to the Go version.

Who’s Affected

Engineering teams maintaining cross-language dependencies in performance-critical pipelines have the most direct parallel. Any system that shells out to a different runtime for a specific function, such as calling Python from Java or JavaScript from Go, pays a similar RPC and serialization tax that a native rewrite could eliminate.

The approach is most applicable when a comprehensive test suite already exists. Without one, the AI-generated code has no automated way to verify correctness, and the time saved on writing code would be consumed by writing tests and debugging edge cases. Projects with poor test coverage or undocumented behavioral quirks would require significantly more human oversight to port reliably.

What’s Next

The case study generated significant discussion on Hacker News, where critics noted that the $500,000 savings figure combines the direct rewrite benefit with broader pipeline optimizations, making it difficult to isolate the AI-generated code’s specific contribution. Others pointed out that the seven-hour timeline covers only the initial code generation and does not account for subsequent debugging, production hardening, or the week of shadow deployment validation.

Teams considering a similar approach should budget for shadow deployment infrastructure and expect the total effort to extend well beyond the initial code generation session. The gnata library is not publicly available, so other organizations cannot reuse it directly and would need to run their own AI-assisted porting effort against the JSONata test suite.

Related Reading

Share

Enjoyed this story?

Get articles like this delivered daily. The Engine Room — free AI intelligence newsletter.

Join 500+ AI professionals · No spam · Unsubscribe anytime