3 ms·
Scientist: A Ruby library for carefully refactoring critical paths
- techplex 3y agoThis is fantastic! Do folks do this manually in other languages or are there proven packages folks use?
- sanxiyn 3y agoThere is a list of packages in other languages at the bottom of the README.
- mberning 3y agoThis is pretty cool, but in my experience critical path code generally has side effects and most code is not idempotent. That is to say it may not be safe or feasible to run the old and new code in parallel, without some special considerations. Think bidding on a auction item or transferring a bank balance.
- rockwotj 3y agoSure but IMO most code can and should be structured to decouple the side effect from the logic that is being replaced. Example in the transferring a bank balance, you have some storage DB you interact with, but that is an abstraction and when you run the dry run of the new code you can have an implementation that just does verification on the data from the real implementation. Anyways, it does take discipline and effort, but you can still safely make changes in this manner.
- Manfred 3y agoThe library is specifically meant for safely replacing legacy implementations and they generally aren't that well structured.
- runako 3y agoI would imagine that applications that use a relational database could use transactions to reduce the impact of non-idempotent code.
- drwl 3y agoI’ve used this gem to remove a Rails Model that was heavily tangled and used in production. It had a bit of a learning curve, such as seeing how errors get handled in try {} blocks, but really nice otherwise when doing the equivalent of open heart surgery.
- nickspain 3y agoWe've used this extensively at my work and it has been great. As someone else pointed out it's a bit tricky if the code isn't idempotent. We used this as part of a data migration project and for writing we ran the experiment 100% of the time and read back the result to check it was correct - a bit of a performance impact but nothing that was noticeable. One super useful extension we've made to the gem is to have it update Prometheus metrics so you can easily see how often your experiment is showing that the candidate is different from the control.
- mdaniel 3y agopreviously: https://news.ycombinator.com/item?id=21489877 https://news.ycombinator.com/item?id=21489877 (178 pt, 19 comments)
- aeontech 3y agoDear lazyweb, is there a similar library for python? :)
- joshmanders 3y agoYes, at the bottom it lists all similar libraries in other languages. Python has https://github.com/joealcorn/laboratory https://github.com/joealcorn/laboratory
- boxed 3y agoI wrote one (https://github.com/boxed/scientist https://github.com/boxed/scientist) as I found the existing ones very complicated and that just gives me a bad feeling. Since I'm the author of mutmut (https://github.com/boxed/mutmut https://github.com/boxed/mutmut), I also made sure my implementation was 100% mutation tested before I used it in production. I used my implementation to replace number parsing in my work project: https://kodare.net/2021/04/04/safe_number_parsing.html https://kodare.net/2021/04/04/safe_number_parsing.html
- dieselgate 3y agoPretty cool to see the github of Github, never occurred to me but makes total sense.
- deleted 3y ago[deleted]
- thor24 3y agoCan anyone share their experience of the equivalent in Go? https://github.com/technoweenie/go-scientist https://github.com/technoweenie/go-scientist
- nextaccountic 3y agoThe readme (here https://github.com/github/scientist#alternatives https://github.com/github/scientist#alternatives) doesn't mention, but here is one for Rust: https://crates.io/crates/scientisto https://crates.io/crates/scientisto