How to select a web framework
Numerous web frameworks exist for almost every programming language you might want to use (we list a few of the more popular frameworks in the following section). With so many choices, it can become difficult to work out what framework provides the best starting point for your new web application.
Some of the factors that may affect your decision are:
- Effort to learn: The effort to learn a web framework depends on how familiar you are with the underlying programming language, the consistency of its API, the quality of its documentation, and the size and activity of its community. If you’re starting from absolutely no programming experience then consider Django (it is one of the easiest to learn based on the above criteria). If you are part of a development team that already has significant experience with a particular web framework or programming language, then it makes sense to stick with that.
- Productivity: Productivity is a measure of how quickly you can create new features once you are familiar with the framework, and includes both the effort to write and maintain code (since you can’t write new features while old ones are broken). Many of the factors affecting productivity are similar to those for “Effort to learn” — e.g. documentation, community, programming experience, etc. — other factors include:
- Framework purpose/origin: Some web frameworks were initially created to solve certain types of problems, and remain better at creating web apps with similar constraints. For example, Django was created to support development of a newspaper website, so is good for blogs and other sites that involve publishing things. By contrast, Flask is a much lighter-weight framework and is great for creating web apps running on embedded devices.
- Opinionated vs unopinionated: An opinionated framework is one in which there are recommended “best” ways to solve a particular problem. Opinionated frameworks tend to be more productive when you’re trying to solve common problems, because they lead you in the right direction, however they are sometimes less flexible.
- Batteries included vs. get it yourself: Some web frameworks include tools/libraries that address every problem their developers can think “by default”, while more lightweight frameworks expect web developers to pick and choose solution to problems from separate libraries (Django is an example of the former, while Flask is an example of a very light-weight framework). Frameworks that include everything are often easier to get started with because you already have everything you need, and the chances are that it is well integrated and well documented. However if a smaller framework has everything you (will ever) need then it can run in more constrained environments and will have a smaller and easier subset of things to learn.
- Whether or not the framework encourages good development practices: For example, a framework that encourages a Model-View-Controller architecture to separate code into logical functions will result in more maintainable code than one that has no expectations on developers. Similarly, framework design can have a large impact on how easy it is to test and re-use code.
- Caching support: As your website becomes more successful then you may find that it can no longer cope with the number of requests it is receiving as users access it. At this point you may consider adding support for caching. Caching is an optimization where you store all or part of a web request so that it does not have to be recalculated on subsequent requests. Returning a cached request is much faster than calculating one in the first place. Caching can be implemented in your code or in the server (see reverse proxy). Web frameworks will have different levels of support for defining what content can be cached.
- Scalability: Once your website is fantastically successful you will exhaust the benefits of caching and even reach the limits of vertical scaling (running your web application on more powerful hardware). At this point you may need to scale horizontally (share the load by distributing your site across a number of web servers and databases) or scale “geographically” because some of your customers are based a long way away from your server. The web framework you choose can make a big difference on how easy it is to scale your site.
There are many other possible factors, including licensing, whether or not the framework is under active development, etc.
If you’re an absolute beginner at programming then you’ll probably choose your framework based on “ease of learning”. In addition to “ease of use” of the language itself, high quality documentation/tutorials and an active community helping new users are your most valuable resources.
Resource from the article Server-side web frameworks