测试开发工程师web开发框架选择flask与django

结论

根据 JetBrain公司发布的Python Developers Survey 2020 Results的调查结果,Flask以46%的采纳比例超越了Django的43%成为最流行的Python界Web开发框架。同样以类似Flask风格的FastAPI也在快速增长。

Flask与Django分别代表的是两种设计理念,简约灵活VS全能强大。在每个语言中都有这两种设计理念的代表,比如SparkJava与Spring,Sinatra与Rails等。Flask的特点是入门简单、易用和灵活的组装特性,适合快速开发。Django是面向专业的网站开发工程师的设计的,所以更成熟稳定。测试开发工程师的核心工作主要是自动化、测试技术研发、测试服务开发。因为对能力的要求更全面,网站开发只是其中一部分的工作,所以更快速易用的框架是首选,推荐使用Flask与FastAPI。

我的建议是先使用这些迷你的开发框架,比如Python中的Flask或FastAPI,或者Java中的SparkJava。如果工作中频繁用到了太多的Web开发技术,再考虑切换到更复杂的框架,比如Python中的Django或者Java中的Spring全家桶,但是这个时候一定要慎重考虑,你是要做一名测试开发工程师,还是要做一名网站开发工程师,因为99%以上的企业与网站开发工程师都在使用Java与Spring全家桶,在Python的技术栈上去构建Web开发技术是不利于发展的。更建议的是前期使用迷你型框架,后面如何需要更专业的网站开发,并且你有意愿深入这个方向,那么最好是切换下到Java中的Spring全家桶。

作为测试开发工程师,需要同时具备两种语言的能力,顶层使用Python语言或者Kotlin这样的全能语言,底层语言在三个方向(Native、JVM、Web)上要掌握其中一种底层语言。Python虽然是全世界使用最广泛的编程语言,但是不适合企业级别开发。企业级别的方案主要还是JVM(Java、Kotlin、Scala)、Native(Go/Rust/C/C++)、Web(JavaScript/TypeScript/Nodejs)这些语言为主。将来我们要对这些研发的产出进行更多的测试,比如代码分析、代码审计、覆盖率统计、单元测试审计、精准测试、apm、全链路分析等等,就需要我们同时掌握一门底层语言的。

Difference Between Flask and Django 对比

Flask vs Django

Flask vs Django

Flask and Django are the two most popular Python- frameworks. Here are some important difference between Django and Flask.

Flask Django
Created in 2010 Created in 2005
Python web framework built for rapid development. Python web framework built for easy and simple projects.
Flask is WSGI framework. Django is a Full Stack Web Framework.
Flask provides support for API. Django doesn’t have any support for API.
Support Visual Debug. No support for Visual Debug.
Flask allows you to use multiple types of databases. Django doesn’t offer multiple types of databases.
Flask has no default support for forms, but you can use WTForms to fill the gap. Django comes Form with which can be integrate with the ORM and the admin site.
Flask does not offer dynamic HTML pages. Django offers dynamic HTML pages.
The request based object is imported from the flask module, which is a global variable in Flask. All views are set as an individual parameter in the Django.
Flask is much younger platform compared to Django. Django is a very mature framework.
Flask offers a diversified working style. Django offers a Monolithic working style.
It supports an extension which could be implemented in the framework. Django has its own module library. So, it stores several prewritten codes.
The structure of the project layout for Flask web framework is random. The structure of the project layout for the Django is conventional.
Flask web framework uses a Ninja2 template design. Django web framework helps you to utilizes the View web templating system.
URL dispatcher of the Flask web framework is a RESTful request. URL dispatcher of this Django framework is based on controller-regex.
Flask does not offer a built-in bootstrapping tool. Django-admin enables developers to start building web applications without any external input.
Flask is a good choice if you want a lightweight codebase. The best feature of Django is Robust documentation.
Flask framework is suitable for single application. Django framework allows developers to divide a project into multiple page application.
Flask Web Framework doesn’t offer support for third-party applications. Django Web Framework supports a large number of third-party applications.
Git hub stars 48.8 K Git hub stars 47.1 K
Best features of the flask is it is lightweight, open source, and offer minimal coding for developing an application. The best features of Django are Rapid development, Open source, Great Community, Easy to learn.
Famous companies using Flask are: Netflix, Reddit, Lyft, MIT Famous companies using Django are Instagram, Coursera, Udemy.

Python Developers Survey 2020 Results 关键数据

参考链接

https://www.guru99.com/flask-vs-django.html

关闭