Hacker News new | past | comments | ask | show | jobs | submit login

It's tremendously freeing to have your application live as what amounts to vanilla python (or ruby, or php, or clojure, or insert-your-favorite-language-here). Once you've abstracted your core business logic from the HTTP layer, a lot of problems become easier to solve. If you want to replace Flask entirely it becomes very simple. If you want to replace REST entirely with a CQRS-style system, it's much easier. Testing gets easier. Wanna play with your app without firing up a web server? Build it so that you can use it from an ipython shell.

Vanilla is the holy grail. You mention manage.py commands but why not if __name__ == '__main__': do the thing. Or the multitude of tools like invoke (https://github.com/pyinvoke/invoke) and click (http://click.pocoo.org/5/). I digress...

Django is great for a monolith. Stack Django REST Framework on top of it and you're even bigger and nastier. I would never use it again because the amount of time spent bending it to my will often exceeds the time I'd spend building my own system. Fair warning, I have been using Django in production since version 0.96 and have built many companies on it. After ten years of building web apps, using every MVC under the sun, and working with every size/shape team under the sun you really start to appreciate simple things that compose well together. They're easier to reason about. They're easier to replace. They're easier to pull out and turn into a standalone library or shared service. Are you hitting the wall with one tiny part of your app? Replace it with something written in an entirely different language and communicate via JSON, or over a message bus. Not everything can be mapped to a WSGI request/response.

I am so glad aidos has the top comment on this post because his/her style is what we should all be aiming for from the get-go.

I'd definitely suggest reading up on the SOLID –https://en.wikipedia.org/wiki/SOLID_(object-oriented_design) – principles. Furthermore, the adapter concept is often explained with scary Java code samples, but the core of it is wonderful. Essentially you should consider your API as a vanilla system in your language of choice and you build adapters which then allow for external services to communicate. One adapter could be HTTP (via Flask perhaps) for a front-end website. One adapter could be HTTP but one that only speaks JSON, which you might serve under api.yourdomain.com. Another adapter might be via a queue system which allows for arbitrary commands from an external source to get written to a durable queue, so that they can be replayed later.

I took some melatonin so at this point I feel like I am just babbling and about to fall asleep.

tl;dr build things without frameworks, use your language well, be vanilla, compose tiny things to build big things.




I think you are biased to pick a "micro framework" as a starting point. Because of your experience, you have probably seen all the common patterns in building a web app. As a result, you probably have a solution, or know exactly where to look for a solution to any requirement you come across. However, less experienced team would need a lot more guidance and proven best practices to follow. An analogy is a driver in a foreign country. A GPS map might not provide her with the shortest or most enjoyable route, it gets the job done. Django is great for inexperienced team. It's also great for solo consultant.


I feel it's also a lot more about temperament than it is about experience. Some developers prefer to build from scratch and some prefer to maximise reuse.

I fall mostly into the second camp. For non-trivial functionality I will (in order of preference) 1. Find a good existing framework or library 2. Refactor something I've already written to be reusable 3. Develop something specifically for the task at hand.

Even when I plump for 3 I'll be thinking about how it could be made reusable - I just postpone actually putting any effort in that direction on the grounds of YAGNI.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: