FastAPI vs. Django vs. Flask

Поделиться
HTML-код
  • Опубликовано: 22 сен 2024

Комментарии • 89

  • @raazgoodboy
    @raazgoodboy 3 года назад +383

    "I saw a job post the other day. It required 4+ years of experience in FastAPI. I couldn't apply as I only have 1.5+ years of experience since I created that thing. "
    - Sebastián Ramírez 😁

  • @lowkeygaming4716
    @lowkeygaming4716 3 года назад +7

    Hopefully Django will pick up some of the good stuff from this because I'm still more comfortable making complicated tasks with it.

  • @TheWolverine1984
    @TheWolverine1984 2 года назад +2

    What does the GIL has to do with Async Await? Async Await run on an event loop. This always happens on a single CPU. Async Await are asyncronos operations for tasks with low computational load and the majority of the task's time is taken by simply waiting for a response. For example like a HTTP call. You make a call, and then you just sit and wait for a reply. And if it takes a long time, everything is stuck because your code is executing one line at a time. With async await you can say "While I wait for the HTTP call to give me a response, other operations can proceed running" and this is why async calls don't block the thread. This has nothing to do with working on multiple CPUs.

  • @realchrishawkes
    @realchrishawkes  3 года назад +2

    🔥 If you're learning to code, check out my website 👉 codehawke.com/all_access.html 🔥
    Learn more 👉 ruclips.net/video/fpp215OSRV0/видео.html

  • @steelwolf180
    @steelwolf180 3 года назад +13

    Nice interesting that you didn't jump into the difference between those 3 directly in speed and talk about async side.

  • @vncntjms
    @vncntjms 3 года назад +4

    So many frameworks built on top of each of these many languages that you could not decide which to use I might just go with no framework at all so I could have a peaceful life.

    • @lunarcdr3083
      @lunarcdr3083 3 года назад

      It's not that difficult really. If you know exactly what the app needs to do, what is your current experience is and/or what are you willing to learn, answers will become pretty obvious. Why choose python over php for example? It's generally a bit easier, there are ton's of algorithmic libraries for things like image processing, robotics, deeplearning etc. This will mostly lead you to Django, Flask or FastAPI. Django is overkill for small project, so your left with Flask vs FastAPI. This is over simplified but you get the deal.

  • @mindasb
    @mindasb 3 года назад +22

    GIL does not matter, since node/express are single threaded either way, and you seem to compare them somewhat. One would not use a python / js backend framework for CPU-bounded work that one wants to parallelize, you would use Scala, Java, C# or even C++.

    • @realchrishawkes
      @realchrishawkes  3 года назад +4

      True.

    • @TheMr82k
      @TheMr82k 3 года назад

      CPU bounded work is a big over simplification.

    • @mindasb
      @mindasb 3 года назад +2

      @@TheMr82k not sure what you mean, but the distinction of CPU vs. IO bound (not bounded, my mistake in the first post) is a simple rule to know if you need something more powerful than PHP / JS / Ruby / Python. It get's 80% there, doesn't it?

  • @tubeathrun
    @tubeathrun 3 года назад +5

    Fastapi
    Is the best python API solution

  • @TheMr82k
    @TheMr82k 3 года назад +6

    Asynchronous is the future, at least for the most part. The event loop is far easier to understand and manage than multi-threading. Indeed there are specific tasks best suited for multiple threading but still in most cases the async/await is more than enough and some alternatives like service workers or isolates in dart can compensate.

    • @zanityplays
      @zanityplays 2 года назад +1

      Asynchronous is not the future. It's already here.

  • @sthefanocarvalho2823
    @sthefanocarvalho2823 3 года назад +3

    This video is exactly what I was looking for!
    Thank you for sharing.
    I will definitely try FastAPI for new projects.

  • @ΓιώργοςΛειβαδιάς
    @ΓιώργοςΛειβαδιάς 3 года назад +4

    Because of your flask series im trying to create mafia movie-tvshows review site THANK YOU !!!

  • @nsambataufeeq1748
    @nsambataufeeq1748 3 года назад +1

    As of this writing Flask 2.0 provides support for async/await.

  • @11yoyomama
    @11yoyomama 3 года назад +2

    Sorry if this is too meta, but do you have a course or resource on building a course site? I would love to build a course site for myself in Django.

  • @b87b84
    @b87b84 3 года назад +6

    FastAPI > Flask > Other Python web frameworks > Django

  • @rishabhanand4270
    @rishabhanand4270 3 года назад +4

    Uhmm how is async even related to concurrency in anyway as async happens on the same thread ( i am coming from a nodejs world so maybe its different in python).

    • @ChumX100
      @ChumX100 3 года назад +4

      Async has everything to do with concurrency, as it allows for multiple tasks to start, run and complete at overlapping time periods (while one is waiting for an external process or service to complete, others can be running). As you point out, that doesn't mean that any two of them will ever run simultaneously, that would be parallelism. In node it's the same thing, you have threads (parallelism) and you also have async/await (concurrency). The key is to know when to use each one. For web servers what you'll want is concurrency most of the time, as most of the time you'll be waiting for databases and other web services and API's to complete, during that time you can start processing other requests.
      Edit: Seems like Node is characteristically single threaded, so you're probably doing mostly async stuff with it anyways ;)

  • @IgorRibeiroBraga
    @IgorRibeiroBraga 3 года назад +3

    Great video! I like Flask, but I think FastAPI very interesting...

  • @Rosenzweigjcb
    @Rosenzweigjcb 3 года назад +7

    The only time I ever set up a web API in Python is when I have an ML model that needs endpoints.

    • @tianlechen
      @tianlechen 3 года назад

      Why else lmao

    • @Rosenzweigjcb
      @Rosenzweigjcb 3 года назад +1

      @@tianlechen There's almost no reason to ever write a web service in Python unless you're forced to. It's probably the area where it does worst. It's painful without static typing for non trivial projects

    • @Rosenzweigjcb
      @Rosenzweigjcb 3 года назад +1

      @Yassin Zao Well at my work we use C# all the time, so that tends to be the defacto web server language. Though on my side projects, I tend to just use Rust. Been meaning to play with Elixir though.

    • @irustv7674
      @irustv7674 3 года назад

      ​@@Rosenzweigjcb following your logic it is better to write in C++ than in Assembly. Just waste of time and money.

  • @karimkazia
    @karimkazia 2 года назад +1

    Thank you! this video helped

  • @ko-Daegu
    @ko-Daegu 3 года назад +3

    If you wanna learn one first I would recommend start with flask after one day decide you want to continue or move to Django
    Don’t start with fastAPI
    If you learned flask pretty much fastAPI is the same and learning it is easy

    • @ko-Daegu
      @ko-Daegu 3 года назад

      And for Async I will use java if I really care about speed and it’s the de facto /deal breaker I will use rust

    • @alpstinger5083
      @alpstinger5083 3 года назад

      Thankss for this. Just a small thing, I started with DRF and I find django to be really awesome. The only problem is that it handles so much on it's own, that I feel like I am not understanding how things work. When I go to the docs, there is so so so much inheritance, that it is confusing as hell. If I shift to some other framework in the future, would it be troublesome, since dango handles so much on its own. If you can tell me something, it will be really helpful.

  • @vncntjms
    @vncntjms 3 года назад

    Off-topic: May I know the font you are using. Thanks.

  • @PouyaAtaei
    @PouyaAtaei 3 года назад +3

    thanks brother, it was a very good video

  • @jaymartinez311
    @jaymartinez311 3 года назад +3

    Any new gui frameworks for python you recommend checking out?

  • @mytechnotalent
    @mytechnotalent 3 года назад +1

    I can say asyncio is to me very complicated. The GIL does limit most applications however it can be done but it is very tricky IMO. This FastAPI seems very impressive.

  • @Meleeman011
    @Meleeman011 3 года назад +9

    wtf python is actually fast now?

  • @michellatch651
    @michellatch651 3 года назад

    Hi Chris, very interesting, do you have any thoughts on Django Channels ? Cheers

  • @aljon7992
    @aljon7992 3 года назад +1

    Teacher thanksnfor this. Can you make some djangorestframework advice?

  • @siphr
    @siphr 2 года назад +1

    I disagree, For ANY type of project it is always helpful if the framework's core has a light footprint so that development focus can stay on the app. I Also disagre with the intepertation that "flask is for basic apps", It is a lean framework where one may need to tiein extras if needed. fastapi maybe new but evauating it as a backend framework, it gives the developer a lot more to work with!

  • @yarokifor1425
    @yarokifor1425 3 года назад +3

    What about Django Channels?

    • @realchrishawkes
      @realchrishawkes  3 года назад +1

      Good question. github.com/django/channels/issues/1416
      I don't think its there yet, as in fully async.

    • @yarokifor1425
      @yarokifor1425 3 года назад +1

      @@realchrishawkes I looked into it a little bit more. Channels does have support for doing async http, but it's not really intended for that.
      channels.readthedocs.io/en/stable/topics/consumers.html#asynchttpconsumer

  • @akshattamrakar9071
    @akshattamrakar9071 3 года назад +1

    I will try it...
    I too like nest js because it's awesome...

  • @divyaanktiwari4713
    @divyaanktiwari4713 3 года назад +4

    Why didn't you use C# as your web backend for your website?

    • @orlandog1979
      @orlandog1979 3 года назад +3

      This video is about Python's frameworks......

  • @DefCantGame
    @DefCantGame 3 года назад

    Thoughts on something like DRF and react or just coding a site in django in 2021?

    • @heroe1486
      @heroe1486 3 года назад +2

      I would say if you need no to little interactivity django + the built in template engine is fine, else you could still use django + vuejs or alpine as a CDN like you'd do with jquery ( never tried react that way so I can't tell ), still with django's template engine. If you need an API + separated frontend yes DRF + React/Vue is the way to go, it involves a steeper learning curve and you'd have to think about things that were "just working" with vanilla django like authentication, but it also gives advantages ( excellent npm libraries ) and flexibility, seems to be the way to go nowadays

  • @mayanksharma7952
    @mayanksharma7952 3 года назад +1

    Just here to to support your work, found your channel through ( Bucky video ).I am from commerce background just guide me with the first thing I have to learn bcz their is not anything for where to start like competitive coding, projects, language, oops, data structures and algo ..
    Just give me first path so that I can make my own way🙏
    Which language can I learn first c or c++ or both

    • @alpstinger5083
      @alpstinger5083 3 года назад

      Hey I am also doing commerce for grad (from India), and had the same confusions. I also fell in love with coding. Maybe we can have a talk.

  • @ayomikunogunjuyigbe1286
    @ayomikunogunjuyigbe1286 3 года назад

    How do you know all these things!! Damn!

  • @elderofzion
    @elderofzion 3 года назад

    async frameworks are a big deal when building microservices. the current is turning towards those. but async support isn't there yet in many languages, so what to do? i found that from all things async nodejs is the easiest one to use. java has webflux, but i only had trouble with that. i think all of golang's http frameworks use goroutines which is go's way of doing async, so that's a good choice also. so either nodejs or go. all other things will just give you trouble

  • @jcb1orion
    @jcb1orion 3 года назад +3

    whatup chris!!!!!!

  • @tarirochimutopo1210
    @tarirochimutopo1210 3 года назад +2

    To me i think fastapi is better though its new i have worked with both Django and Fastapi its ... why fastapi is so flexible

  • @City__Walker
    @City__Walker Год назад +1

    And win knex😉

  • @Shivam_Manswalia
    @Shivam_Manswalia 3 года назад +1

    Please make a tutorial on fastapi
    And don't forget fronted.

  • @MarcelBornancin
    @MarcelBornancin 2 года назад

    Content is too good to have a misleading title like that

  • @Casimistico
    @Casimistico 3 года назад

    Check out HUG for small projects

  • @anonymous_anonymity
    @anonymous_anonymity 2 года назад

    When developers talk about which framework is better, just escape!! Not worth your your time.

  • @anonymous_anonymity
    @anonymous_anonymity 2 года назад +4

    "Django is ranked 354, FastApi is way faster at rank 270".. Definitely a typical web developer chit chat when logic is on a vacation.

  • @avisalon4730
    @avisalon4730 3 года назад +1

    Thank you. I realized python is bad language. People choose nodejs

    • @realchrishawkes
      @realchrishawkes  3 года назад

      I don't think it's a bad language, but it's bad for certain jobs. Some jobs it's great at. Why do you think it's a bad language?

    • @heroe1486
      @heroe1486 3 года назад +5

      @@realchrishawkes certainly because nodejs is more used nowadays and some people just swear by what is trendy instead of focusing on trying to find the right tool for the job, thus they focus on some premature optimization that aren't even relevant if you don't have reddit's trafic and do poor jobs for what really matters for their particular project. I'm sure Django + DRF is more than relevant for 95/100 of websites out here.

    • @jorge1869
      @jorge1869 3 года назад

      Noob

  • @ward7576
    @ward7576 3 года назад

    Correct answer: none of them

  • @DanielNistrean
    @DanielNistrean 3 года назад +1

    Why would someone use Python for web development instead of Node.JS or languages like C# and Java with (IMHO) much better performance?

    • @aaklii
      @aaklii 3 года назад

      🙄

    • @hasibuzzamantonmoy8845
      @hasibuzzamantonmoy8845 3 года назад

      What are you even doing here then? Lol.

    • @JC.72
      @JC.72 3 года назад

      @@hasibuzzamantonmoy8845 that question is still fair. i am here to see if python made some kind of big break thru and appreantly it just made small improvements.

    • @andreacazzaniga8488
      @andreacazzaniga8488 3 года назад +1

      If the business logic is the most important part of your project, python is easier to start with. I acknowledge c# and .Net core might be just as good, and give better performance, but I know python much better so i stick witj it

    • @alexwatson6370
      @alexwatson6370 2 года назад +2

      Because it's more readable and way less of a pain in the ass when dealing with databases and other systems programming situations...