from Hacker News

Show HN: Built JSONLogic in Rust in 5hrs with GitHub Copilot as pair programmer

by codetiger on 11/19/24, 1:37 PM with 1 comments

Hey HN!

Wanted to share a fun experiment - I implemented the full JSONLogic spec in Rust with Github Copilot (Claude) as my coding buddy. The entire implementation took less than 5 hours from start to finish. Here's how I approached it:

- Started with a clear architectural vision - broke down the operators into categories (logical, comparison, numeric, etc.) and explained this structure to Copilot. This helped set a consistent pattern for the implementation.

- Used test-driven development by importing JSONLogic's official test suite. Set up the test infrastructure and let all tests fail initially. This gave us clear targets to work towards.

- Implemented one operator (like 'var') completely, establishing the code pattern and error handling approach. Copilot quickly picked up on the style and helped extend it.

- For each operator category, explained the requirements and let Copilot generate the implementation following our established pattern. The test suite helped catch edge cases we might have missed.

- Final polish included running Clippy for Rust best practices, adding proper error messages, and some performance tuning like reducing allocations.

What surprised me was how smoothly it went when I gave Copilot clear context and patterns to follow. It's like pair programming with someone who types really fast but needs good direction

The library is now production-ready and handles all JSONLogic operations with proper error handling and type safety.

Would love to hear others' experiences pairing with AI tools for Rust projects!

  • by codetiger on 11/19/24, 1:43 PM

    Author here, please share your feedback for improving the library and your experience with Copilot or other tools.