Ruff is the FUTURE of Python development

Sdílet
Vložit
  • čas přidán 22. 08. 2024
  • Don't believe me? Just wait until you see how fast it is. ⚡
    -
    If you enjoy my content, consider supporting me on Patreon or becoming a member!
    patreon.carber...
    join.carberra.xyz
    If you need help with anything, feel free to join the Discord server:
    discord.carber...
    I get a lot of people asking, so here's my Visual Studio Code setup!
    • My Visual Studio Code ...
    -
    If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.
    #python #coding #howto

Komentáře • 83

  • @ksb2112
    @ksb2112 Před rokem +123

    The best thing about programming is that someone is inventing something new every few weeks so we all get to spend more time learning new frameworks instead of getting work done.

  • @jma42
    @jma42 Před rokem +36

    I really hate how flake8 chose not to have a toml configuration, this made me found ruff.

    • @Carberra
      @Carberra  Před rokem +7

      Yeah I only found that out recently myself -- I never really used Flake8 cos it seemed like a chore, but that was a dumb decision on their part honestly.

    • @jodydoolittle2850
      @jodydoolittle2850 Před rokem +1

      @@Carberra Flake8 team is....flakey

  • @Dr.Cosmar
    @Dr.Cosmar Před rokem +10

    I've probably only got about 4000 hours of self-taught python coding under my belt at this point. I always thought I was messy, it's nice to know it's normal to have a stray packages and errors when your project really starts to grow.

  • @scheimong
    @scheimong Před rokem +46

    Honestly Ruff might be one of the best example I can use to shill Rust to my boss. Rust is unique in that its strictness allows a small team of developers to take on massively complex problems (like a Python linter) in a "low-level" language (in the sense that it's close to as fast as it can possibly be), without needing to worry about annoying things like memory leaks and UB that are typically associated with traditional low-level languages like C.
    We are a small company (around 10 devs) currently developing an industry-specific high-performance computation library, which actually fits this requirement profile quite nicely. The current codebase is just shy of 20K lines of C++, and I've been bugging my boss to let us rewrite this thing in Rust. I believe in the long term, it's going to pay off much, much more than this initial investment. He is still somewhat hesitant (understandably; Rust is rather new when compared to C++), but I don't plan to shut up until I get my way.

    • @asandax6
      @asandax6 Před rokem +5

      If you want to make the sell even more convincing try rewriting some of the c++ in rust and show your boss that there won't be performance penalties. It would also help to show of the debugging tools that come with rust. It would also make a point that rewriting in rust would be feasible.

    • @ClaymorePT
      @ClaymorePT Před rokem +5

      The problem that you will have about shilling rust to your boss is that it will be very difficult for you to demonstrate an increase in value when reproducing the same work that was done in C++, but now in Rust. The increase in value could be little to none, which the financial department will not like. After all, if it aint broken, don't fix it.
      You will also have problem in demonstrating that Rust is more "secure" to code given that Rust also allows to have insecure code. Just use unsafe.
      Convincing that Rust will allow to write more secure and solid code could also be problematic. After all, all qualified software engineers should be able to write quality code, whatever the language is. Using the "you will forgot something" is just a synonym to "I did not properly test my code, nor I added the proper testing steps to the development pipeline"
      Then, going into the features, C++ with a good linter will also warn the developer about possible unsafe code. There's plenty of constructs on the standard library that allow quality code to be developed. Smart pointer is just one of them, but it will always come down to the knowledge the developers have about the language. C++ has been having new specifications releases every three years since 2011, so I would be careful about calling C++ an old language. After all, old can also mean seasoned and experienced.
      Absence of good Rust developers in the market when compared to C++ developers could also be something problematic when shilling Rust. The lack of quality libraries is also a complicated point, where even famous framework libraries like Rocket, are problematic due to requiring nightly toolchains.
      Pick up good arguments and stick with it. Don't try to bash C++ down. Keep the arguments business oriented.

    • @scheimong
      @scheimong Před rokem

      @@ClaymorePT thanks a ton for the great advice. I've never been great at persuading people, but the benefits of rust are just too obvious for a technically minded person like me to pass up. My boss has a less technical background, so my general strategy has been centered around showing him examples where other companies and developers have chosen rust for their high-performance applications. There's already plenty, but I can always use one more =)
      I think you brought up a great point in terms of the lack of competent developers, but I wouldn't say that rust is at a particular disadvantage here. Low level languages by their nature demand a lot from the developer terms of their background knowledge of computer systems and experience in avoiding common pitfalls. So IMO the hiring difficulty is more about finding people with a good mix of theoretical and practical knowledge than it is about any particular language.
      As of our actual project, I should clarify that it's still in very early prototype/alpha stage, and it was written entirely by two members in their spare time. They choose C++ because that's what they both knew, and there's little to no planning otherwise. So it's not late to switch languages at all IMO. Also this project (if successful) is likely going to become our company's primary business in the long run (I'm talking about more than a decade), so the ease of long term maintenance is definitely up on my list of priorities. And if you're looking at the next decade, I think it's fair to say that most factors are certainly in rust's favour.

    • @scheimong
      @scheimong Před rokem

      @@ClaymorePT and another word on the concept of competence. I would be the first to admit my incompetence in any language (rust included), and I've got a CS degree and 10 years of programming experience at this point. This is not showing off or anything, I'm just trying to make the point that I think we should expect incompetence as the norm.
      Well in this unfortunate reality, I believe rust undoubtedly fairs better than C++. While incompetence in rust wastes the time of a single person (your work won't compile), incompetence in C++ wastes the time of the whole team (deployment crashes at 3am and wakes everyone up). Bad rust code causes bad performance, but bad C++ code causes UB.

    • @jamesstevens2145
      @jamesstevens2145 Před rokem

      That "Shit, I should learn Rust" moment for me :D

  • @lunarmagpie4305
    @lunarmagpie4305 Před rokem +30

    Some of my favorites are ANN201, ANN202, ANN204, ANN205, ANN206. Enabling these makes you put a return type on your functions.

  • @Jyggafey
    @Jyggafey Před rokem +7

    The ad density while watching this was insane. 3x double unskippable ads within 3 minutes towards the end.

    • @Carberra
      @Carberra  Před rokem +2

      Jeez what, CZcams's having a field day apparently 😅 I'll check that out later cos I didn't set it up like that.
      Though CZcams just does this now -- on non-partnered channels you'll sometimes just get ads thrown in for shits and giggles.

    • @Jyggafey
      @Jyggafey Před rokem

      @@Carberra yeah I recognize that the creator has little control about that these days, especially with less than 4K ?) hours watched?

    • @Carberra
      @Carberra  Před rokem +1

      Yeah 4k p.a. is the min. Creators above that have control over where ads go, but judging by your experience, that's now "had" 🥴

    • @shivampundir3226
      @shivampundir3226 Před rokem

      Use youtube revanced with microg.

    • @PanduPoluan
      @PanduPoluan Před rokem

      Vanced CZcams ftw!!! 😎

  • @willemvdk4886
    @willemvdk4886 Před rokem +6

    Seems like a great tool! I've been at war with our automated build pipeline that includes a flake8 check step that makes the pipeline (understandably so) fail at any error. But somehow I can't get my own linter to produce anything that flake8 wouldn't barf over... Very frustrating. I'm going to try Ruff!

    • @Carberra
      @Carberra  Před rokem +1

      Yeah at work we use Pylint in our pipeline and it takes like 10 mins to scan the whole codebase, Ruff takes a second, if that. It's extraordinary. Bear in mind atm Ruff can't do *everything* flake8 can, but they seem to have gotten all the commonl used things at this stage.

  • @mariomedinahernandez6808

    There is a vscode extension named sourcery which read your code and gives u an alternative to the code you are using. I think these alternatives are better for the code performance

    • @Carberra
      @Carberra  Před rokem +2

      Holy crap, had a look into it and it looks amazing! Deffo gonna try it out some time.

  • @shamaldesilva9533
    @shamaldesilva9533 Před rokem +6

    been using this for a while and its incredible 🔥🥳 would love to see a video on pydantic in a future video 🤖

    • @Carberra
      @Carberra  Před rokem +3

      I wish I'd gotten on board sooner tbh, just thought migrating to using it would be a nightmare. That's why I made this video, to show it's not!
      Pydantic looks pretty interesting actually, will have to take a look sometime.

  • @EngineerNick
    @EngineerNick Před rokem +2

    Thanks very cool video :) I don't think type checking blocks are an optimization tho; if you are defining a function that uses datetime, then some other part of your codebase must have imported datetime already. Repeated imports don't cause much overhead because because they all happen at startup, and python doesn't actually re-import everything every time it encounters the same import. It is much easier to use a `from __future__ import annotations`. I think the type checking block only helps if you are dynamically importing optional dependencies which i think should be avoided unless there are super good reasons.

    • @Carberra
      @Carberra  Před rokem

      Yeah, that's a valid point, it's rare that won't be the case. It's good to see which imports in a file are actually used and which are only good for types though. I tend to use the block and the future import lmao.

  • @BeachFrontSolutions
    @BeachFrontSolutions Před rokem

    So what you’re saying is ruff is building towards the Rust toolchain but in Python (ruff seems a lot like Rust Analyzer) which is awesome - oxidize everything!

  • @mecrayavcin
    @mecrayavcin Před měsícem

    Should i turn on basic or off in vscode typechecking while using ruff?

  • @blendfile3_3
    @blendfile3_3 Před 28 dny

    i tried Pylance, mypy and pylint. But the Ruff the best what i used

  • @popovanatoliy4736
    @popovanatoliy4736 Před 3 měsíci

    added in my pre-commit

  • @wnuggy
    @wnuggy Před rokem +1

    hey there, really enjoyed the video! but really couldnt keep my eyes off your font, could i please have the name?

    • @Carberra
      @Carberra  Před rokem +1

      Fira Code Nerd Font (: Glad you liked the video!

  • @asdhuman
    @asdhuman Před rokem +1

    Interesting. Going to compare with solar-lint, which im using now, i liked --fix feature. Seems faster, Rust making his job

  • @PavithraSuLa
    @PavithraSuLa Před rokem

    Seems to be a great tool. thanks for sharing! 💯
    In a future video Could you please explain python Metaclasses?

    • @Carberra
      @Carberra  Před rokem +1

      You're welcome! That's on the list of to-dos, so yes (:

  • @nicowong2428
    @nicowong2428 Před rokem

    What fonts do you use for VSCode? Can you send your settings json? would appreciate it!

    • @Carberra
      @Carberra  Před rokem +2

      I've got a link to my setup in the description (:

  • @samymostefai7644
    @samymostefai7644 Před rokem

    how to add ruff in pycharm ?

  • @ImFantin
    @ImFantin Před rokem +2

    What is this theme name?

    • @Carberra
      @Carberra  Před rokem +4

      Ayu Mirage Bordered -- my full VS Code setup is in the description (:

    • @ImFantin
      @ImFantin Před rokem +4

      @@Carberra sorry I missed that haha. Cheers mate.

  • @schedarr
    @schedarr Před rokem +1

    How do Ruff compare to Flakeheaven?

    • @Carberra
      @Carberra  Před rokem

      Can't say I've ever heard of Flakeheaven, will have to check it out and get back to you.

  • @Aristocle
    @Aristocle Před rokem

    I'm waiting this for jupyterlab

  • @lunarmagpie4305
    @lunarmagpie4305 Před rokem +2

    ruff 🚀🚀🚀

  • @ErmandDurro
    @ErmandDurro Před rokem

    Great video. Really useful for me. Thank you 😃

  • @ivankudinov4153
    @ivankudinov4153 Před rokem

    250k LOC in 1 second? Wow

  • @tridibbiswas3361
    @tridibbiswas3361 Před rokem

    I am a noob. Thank you for the video. You have nice colorscheme - could you please share what it id

    • @Carberra
      @Carberra  Před rokem

      You're welcome! Link in description for the theme (:

  • @shwetagk5362
    @shwetagk5362 Před rokem +2

    What is ruff?why ruff for future python development?

    • @robertpietraru1939
      @robertpietraru1939 Před rokem +3

      You could watch the video to find out

    • @NostraDavid2
      @NostraDavid2 Před rokem +3

      It's the fastest linter available. Replaces flake8, isort and a few others, while being 10x faster, which you'd think doesn't matter until you experience it.

    • @scheimong
      @scheimong Před rokem +1

      A better question is, are you a bot?

    • @DajesOfficial
      @DajesOfficial Před rokem +2

      @@scheimong what is bot? Why is him a bot?

  • @motbus3
    @motbus3 Před měsícem

    Ruff is cool and fast. But they never contribute anything to the sources they are taking from. I am not sure if I want to be part of this.

  • @18.j
    @18.j Před rokem +1

    So its like eslint for javascript

  • @DAB009
    @DAB009 Před rokem +1

    What if and that's a big if. We rewrite python itself in rust? 😂
    Jokes aside. Good job ruff team.

    • @Carberra
      @Carberra  Před rokem +3

      Someone's already done it! github.com/RustPython/RustPython

  • @tjbwhitehea1
    @tjbwhitehea1 Před rokem

    Funny too small as ever!

  • @swordsimkid23
    @swordsimkid23 Před rokem

    Woof

  • @SP-db6sh
    @SP-db6sh Před rokem

    Now make a video on ruff + Blockchain dev, it's millionaire idea

    • @sadhlife
      @sadhlife Před rokem +4

      make it then, be the millionaire

  • @labret4250
    @labret4250 Před rokem

    wust? uwu

  • @crap2642
    @crap2642 Před rokem +2

    Urm... have you considered using a real IDE like PyCharm or IntelliJ instead of your plugin-enhanced text editor?

    • @HaroldR
      @HaroldR Před rokem +1

      This tool has nothing to do with vscode. Have you considered thinking about what you're typing before you start being an asshole?

    • @CJCJCJCJ
      @CJCJCJCJ Před rokem

      Nope, get fucked lmao

    • @wifim821
      @wifim821 Před rokem

      Do u even know what "IDE" stands for? I would claim that VSCode is the most powerfull IDE out there and yet the most simple. Had used Eclipse a lot because of my Java background and it was kind of okay for c++ but as one has to switch between diffrent langs and data formats daily its a pain to have multiple IDEs. VSCode is a relief. Cant imagine to ever use something else again.

    • @yes-vy6bn
      @yes-vy6bn Před rokem +17

      have you considered not using proprietary spyware?

    • @fueledbycoffee583
      @fueledbycoffee583 Před rokem +11

      when i started coding i started with pycharm and i must say: VScode is just so much more superior. Pycharm is just so bloated and feels so slow... and when it has to index the workspace, yeah... You can go take a good rest for some hours. Beside, plugins based design is also alot better than propietary design. If i want a feature, i just download it from the marketplace... If i want a feature in pycharm i have to hope that jetbrains one day add it to the IDE, also licensing is a mess nowadays with jetbrains. In the past i had licences for their products but they just start lacking against the competition. heck i even used webstorm the first 3 years of my fron end dev career... But again, vscode is just so much better and flexible