r/ruby • u/dtcristo • Oct 23 '26
Carton - Real boundaries for Ruby
https://carton.dtcristo.comCarton is my take on enforcing boundaries in large Ruby applications. It's similar to Packwerk, but it takes a more Ruby-like approach, with no manifest files. Constants, gems and monkey patches are isolated using Ruby 4's new Ruby::Box. It's not production ready yet, since Box itself is still experimental, but I'd love feedback on the approach.
41
Upvotes
8
u/keyslemur Oct 23 '26
Interesting, I will have to give this some more thought later, but on an initial read I think you're scratching an itch I've had with Packwerk which is that it tends far more towards polite enforcement rather than hard boundaries.
The danger, though, is that by going all the way to isolation the rungs of the ladder you might have had with Packwerk to progressively isolate are sawed off. It's very all-of-nothing, which is the same weakness that Ruby::Box will have used in Rails apps. Having worked now in several of the largest Rails monoliths not having a progressive ladder is a surefire way to have something lose funding and effectiveness. Packwerk is not perfect at this, no, but it feels like the framework is at least somewhat guiding you rather than providing an end state.
Where I could see this going is potentially isolate deploys, hotswap restarts (ala Erlang / Elixir), tree shaking CI tests, substantially easier dead code identification, and done well with layering a way to break down the worst ActiveRecord entanglements by progressively isolating "data" from "domain".
Depending on your tolerances for AI you could also include a series of agent skills that make migrations towards this endstate substantially cheaper for folks.
Will give this some more thought and sit on it for a bit, but interesting start.
2
u/azimux Oct 23 '26
Bookmarked it and will circle back to it next month and give feedback! I've always wanted something like package scope from Java. Private constants cause me random headaches but are almost close enough. This one aspect of Ruby that I wish I had a solid solution to besides raw discipline so I'm interested to take a peek when I have some stuff off my plate!
1
u/dtcristo Oct 25 '26
If you’re put off by the AI-assisted marketing copy (I’m not a good writer and needed help), check out the Carton Examples. They demonstrate carton’s capabilities quite well.
0
u/[deleted] Oct 24 '26
[removed] — view removed comment