Ruff is the FUTURE of Python development
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
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.
Just in case it is not framework it is linting btw 😂
I really hate how flake8 chose not to have a toml configuration, this made me found ruff.
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.
@@Carberra Flake8 team is....flakey
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.
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.
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.
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.
@@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.
@@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.
That "Shit, I should learn Rust" moment for me :D
Some of my favorites are ANN201, ANN202, ANN204, ANN205, ANN206. Enabling these makes you put a return type on your functions.
At this point just use a better language.
@@NoelmineZockt like what?
@@crusaderman6501 Rust. The answer is always Rust.
@@NoelmineZockt true
@@NoelmineZockt and thats why rust community is just a shit
The ad density while watching this was insane. 3x double unskippable ads within 3 minutes towards the end.
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.
@@Carberra yeah I recognize that the creator has little control about that these days, especially with less than 4K ?) hours watched?
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" 🥴
Use youtube revanced with microg.
Vanced CZcams ftw!!! 😎
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!
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.
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
Holy crap, had a look into it and it looks amazing! Deffo gonna try it out some time.
been using this for a while and its incredible 🔥🥳 would love to see a video on pydantic in a future video 🤖
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.
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.
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.
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!
Should i turn on basic or off in vscode typechecking while using ruff?
i tried Pylance, mypy and pylint. But the Ruff the best what i used
added in my pre-commit
hey there, really enjoyed the video! but really couldnt keep my eyes off your font, could i please have the name?
Fira Code Nerd Font (: Glad you liked the video!
Interesting. Going to compare with solar-lint, which im using now, i liked --fix feature. Seems faster, Rust making his job
Seems to be a great tool. thanks for sharing! 💯
In a future video Could you please explain python Metaclasses?
You're welcome! That's on the list of to-dos, so yes (:
What fonts do you use for VSCode? Can you send your settings json? would appreciate it!
I've got a link to my setup in the description (:
how to add ruff in pycharm ?
What is this theme name?
Ayu Mirage Bordered -- my full VS Code setup is in the description (:
@@Carberra sorry I missed that haha. Cheers mate.
How do Ruff compare to Flakeheaven?
Can't say I've ever heard of Flakeheaven, will have to check it out and get back to you.
I'm waiting this for jupyterlab
ruff 🚀🚀🚀
🚀
Great video. Really useful for me. Thank you 😃
You're welcome!
250k LOC in 1 second? Wow
I am a noob. Thank you for the video. You have nice colorscheme - could you please share what it id
You're welcome! Link in description for the theme (:
What is ruff?why ruff for future python development?
You could watch the video to find out
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.
A better question is, are you a bot?
@@scheimong what is bot? Why is him a bot?
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.
So its like eslint for javascript
What if and that's a big if. We rewrite python itself in rust? 😂
Jokes aside. Good job ruff team.
Someone's already done it! github.com/RustPython/RustPython
Funny too small as ever!
Woof
Now make a video on ruff + Blockchain dev, it's millionaire idea
make it then, be the millionaire
wust? uwu
Urm... have you considered using a real IDE like PyCharm or IntelliJ instead of your plugin-enhanced text editor?
This tool has nothing to do with vscode. Have you considered thinking about what you're typing before you start being an asshole?
Nope, get fucked lmao
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.
have you considered not using proprietary spyware?
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