Skip to content

Comment on Library patterns: Why frameworks are evil

Comments

If I'd have to spend my career developing and attending to a single product, a set of libraries would be all I need. I can fill in the blanks and connect them and write and maintain any missing pieces.

However I work for customers, many different projects, and I'm more than happy to work with Ruby on Rails, that enforces a common structure to every project, lets me predict where files are and what they do, etc. The advantage is in all the time not spent on learning from scratch every single project. I can start working on the very first day. Even Django, which is mostly anarchy compared to Rails, is better than complete anarchy with every single project using different tools and having a different architecture.

Furthermore projects started with Sinatra and Flask and similar tools quickly evolve into something as complex as Rails and Django, with tons of home made fragile code. There is never the time to make them robust, because nobody is working full time on those projects for years. Basically frameworks allow developers to multitask among projects which is great for consultants and also for customers, because they don't have to pay for the extra developers.

As much as I love Flask (or Bottle) and the Go approach, I find myself in the same boat.

Curious question, why you say Django is mostly anarchy compared to Rails? I haven't used Rails btw.

Django has a few features that can be taken for granted: the ORM, the templating language (ouch), the admin, the user/auth/permission system, the division in views (called controllers in Rails) and templates (called views in Rails.) They are well known entities but there is no well defined structure for the code. A project can have any shape and I've seen no two projects with the same shape. On the other side every Rails project has the same shape, often even across multiple versions of the framework. The greatest departures from the standard are some app/services directories but in general you can tell where a url is implemented without looking at Rails' equivalent of urls.py

Django allows multiple subprojects inside an app and code wherever one wants to place it. Rails also allows code anywhere but in practice it's always in the same places. Maybe it's Python, inviting developers to overengineer their code.

Ah that's a super explanation there, thank you!

Yeah the templating language is not so nice, I sometimes use Jinja instead. Also, I don't like the classic MVC so I have a completely different structure thus validation your point completely :P

If you ever end up in Django land (for some project), checkout Django Ninja for APIs, you'll end up avoiding having these annoying url files and just have a

@api.get("some/api") def some_api(request):

instead. Super simple and useful. I just recently discovered it and I don't know how stable it is but it seems pretty stable so far.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.