3 ms·
There formed a subculture inside Ruby community, of people who love code that is as structured and declarative as possible, with an abstraction over anything th
by hakunin 2y ago
There formed a subculture inside Ruby community, of people who love code that is as structured and declarative as possible, with an abstraction over anything that has a name, and a hierarchy of namespaces that map onto paths or grouping of similar things, rather than parts of a module or a library. There are many examples of libs like these out there (I won't name names). For example, libraries that let you write "service objects" declaratively with some block/lambda trickery.
I find this to be a fun way to play with and explore Ruby, but once it comes to building stuff for production, I encourage to take a bunch of steps back and rethink what is really being gained. Many of these libraries end up turning Ruby almost unrecognizable. And the fact is that if you sit down and try to rewrite the same thing into plain imperative ruby, you'd lose nothing (it won't even be longer), but you'd gain clarity and maintainability, because code becomes simple and obvious. I know this because I've done all of the above in the past, and it humbled me a number of times. I wish more people were trying to do this exercise of ruthlessly comparing their lib's solution to the same thing done in plain ruby. It may feel bad at first because it bursts the bubble of excitement one may've inflated while building a lib. But then I find it actually makes you more excited about Ruby again.
I haven't personally used Hanami, been following it from a distance, and I might be wrong in this impression, but I found it to be leaning a little too hard into the camp described above. That said, performance gains are certainly welcome.
- Lio 2y agoHanami is often used with dry-rb + ROM + Hanami as an alternative to Rails. My experience has not been with Hanami itself but with the rest of the Dry ecosystem. Upgrading a legacy app with Dry-Validation put me off using anything else related to it. The breaking changes of DSL around the launch of 1.0 and the split into Dry-Validation + Dry-Schema was particularly painful. In contrast upgrading from Rails 5.0 > 6.0 > 7.0 has been much smoother. I prefer POROs for business logic plus ActiveModel for validation. If I needed small performance bump with minimal rewrite I'd probably migrate to some combination of Sequel + Roda.