Hacker News new | ask | show | jobs
by sagichmal 4339 days ago
Strongly agree. A verbose `main` carries the benefit of being explicit and unambiguous. Components whose constructors take all of their dependencies are simple to reason about and straightforward to test.

The code described in the article seems like it's burdened with patterns from other languages and ecosystems, and which are pretty nonidiomatic Go: "AppLoader"? The complexity of their final solution seems to be a result of not challenging those patterns and assumptions.

1 comments

Yeah. I think the fear of a verbose `main` is wrong. It's OK for complicated code to look complicated. If your app needs to initialize a lot of complex network dependencies at startup, then maybe your startup routine is going to have a lot of code. No big deal.

Software is complex. We all repeat, and try to follow, the mantra of writing simple code that does one thing. We succeed a lot of the time. But sometimes, we just need to do something f'n complicated. Better to express the complexity in type safe, debuggable code that everyone understands, than to hide it behind some framework.

I think developers should be more accepting of a code base that's 95% clean and 5% messy. "The perfect is the enemy of the good."