Ruff is the FUTURE of Python development

Поділитися
Вставка
  • Опубліковано 20 сер 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

КОМЕНТАРІ • 83

  • @ksb2112
    @ksb2112 Рік тому +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.

  • @Dr.Cosmar
    @Dr.Cosmar Рік тому +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.

  • @jma42
    @jma42 Рік тому +36

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

    • @Carberra
      @Carberra  Рік тому +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 Рік тому +1

      @@Carberra Flake8 team is....flakey

  • @lunarmagpie4305
    @lunarmagpie4305 Рік тому +30

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

    • @NoelmineZockt
      @NoelmineZockt Рік тому +4

      At this point just use a better language.

    • @crusaderman6501
      @crusaderman6501 Рік тому

      @@NoelmineZockt like what?

    • @NoelmineZockt
      @NoelmineZockt Рік тому +2

      @@crusaderman6501 Rust. The answer is always Rust.

    • @crusaderman6501
      @crusaderman6501 Рік тому

      @@NoelmineZockt true

    • @apstl7106
      @apstl7106 5 місяців тому

      @@NoelmineZockt and thats why rust community is just a shit

  • @scheimong
    @scheimong Рік тому +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 Рік тому +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 Рік тому +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 Рік тому

      @@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 Рік тому

      @@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 Рік тому

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

  • @willemvdk4886
    @willemvdk4886 Рік тому +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  Рік тому +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
    @mariomedinahernandez6808 Рік тому +4

    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  Рік тому +2

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

  • @shamaldesilva9533
    @shamaldesilva9533 Рік тому +6

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

    • @Carberra
      @Carberra  Рік тому +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.

  • @Jyggafey
    @Jyggafey Рік тому +7

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

    • @Carberra
      @Carberra  Рік тому +2

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

    • @Jyggafey
      @Jyggafey Рік тому

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

    • @Carberra
      @Carberra  Рік тому +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 Рік тому

      Use youtube revanced with microg.

    • @PanduPoluan
      @PanduPoluan Рік тому

      Vanced UA-cam ftw!!! 😎

  • @EngineerNick
    @EngineerNick Рік тому +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  Рік тому

      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 Рік тому

    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!

  • @asdhuman
    @asdhuman Рік тому +1

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

  • @PavithraSuLa
    @PavithraSuLa Рік тому

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

    • @Carberra
      @Carberra  Рік тому +1

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

  • @popovanatoliy4736
    @popovanatoliy4736 3 місяці тому

    added in my pre-commit

  • @wnuggy
    @wnuggy Рік тому +1

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

    • @Carberra
      @Carberra  Рік тому +1

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

  • @mecrayavcin
    @mecrayavcin Місяць тому

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

  • @blendfile3_3
    @blendfile3_3 26 днів тому

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

  • @ErmandDurro
    @ErmandDurro Рік тому

    Great video. Really useful for me. Thank you 😃

  • @lunarmagpie4305
    @lunarmagpie4305 Рік тому +2

    ruff 🚀🚀🚀

  • @nicowong2428
    @nicowong2428 Рік тому

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

    • @Carberra
      @Carberra  Рік тому +2

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

  • @schedarr
    @schedarr Рік тому +1

    How do Ruff compare to Flakeheaven?

    • @Carberra
      @Carberra  Рік тому

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

  • @samymostefai7644
    @samymostefai7644 Рік тому

    how to add ruff in pycharm ?

  • @Aristocle
    @Aristocle Рік тому

    I'm waiting this for jupyterlab

  • @ImFantin
    @ImFantin Рік тому +2

    What is this theme name?

    • @Carberra
      @Carberra  Рік тому +4

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

    • @ImFantin
      @ImFantin Рік тому +4

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

  • @tridibbiswas3361
    @tridibbiswas3361 Рік тому

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

    • @Carberra
      @Carberra  Рік тому

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

  • @18.j
    @18.j Рік тому +1

    So its like eslint for javascript

  • @shwetagk5362
    @shwetagk5362 Рік тому +2

    What is ruff?why ruff for future python development?

    • @robertpietraru1939
      @robertpietraru1939 Рік тому +3

      You could watch the video to find out

    • @NostraDavid2
      @NostraDavid2 Рік тому +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 Рік тому +1

      A better question is, are you a bot?

    • @DajesOfficial
      @DajesOfficial Рік тому +2

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

  • @ivankudinov4153
    @ivankudinov4153 Рік тому

    250k LOC in 1 second? Wow

  • @DAB009
    @DAB009 Рік тому +1

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

    • @Carberra
      @Carberra  Рік тому +3

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

  • @swordsimkid23
    @swordsimkid23 Рік тому

    Woof

  • @motbus3
    @motbus3 Місяць тому

    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.

  • @tjbwhitehea1
    @tjbwhitehea1 Рік тому

    Funny too small as ever!

  • @SP-db6sh
    @SP-db6sh Рік тому

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

    • @sadhlife
      @sadhlife Рік тому +4

      make it then, be the millionaire

  • @labret4250
    @labret4250 Рік тому

    wust? uwu

  • @crap2642
    @crap2642 Рік тому +2

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

    • @HaroldR
      @HaroldR Рік тому +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 Рік тому

      Nope, get fucked lmao

    • @wifim821
      @wifim821 Рік тому

      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 Рік тому +17

      have you considered not using proprietary spyware?

    • @fueledbycoffee583
      @fueledbycoffee583 Рік тому +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