Code quality tools like linters and test frameworks are an important bit of the machine for developers. Linters play the part of keeping the code error free and ensure that it conforms to the rules implemented in the team. Conversely, when these tools are slow and sluggish, they can slow down development to a great degree. A new tool from this space called Ruff has been making noise in the community of late.
Origin of Ruff
Charlie Marsh, a Khan Academy alum released the tool last year on August 30 but in the five months that have gone by, Ruff has gained a lot of ground. Marsh admits that Ruff’s sudden popularity has taken him by surprise, and that is why he called it ‘Ruff’ (rough). “I don’t consider it production-ready, it’s only a proof-of-concept,” he said on a thread posted on Hacker News.
Last month, Marsh wrote a blog post discussing where he wanted to take Ruff in the future. ‘I meant to write this post after the first 100 releases, but now (v0.0.226) seems as good a time as any to recap the progress we’ve made over the last few months, and share more on where we’re headed,’ he stated.
Need for speed in Python tools
And there’s good reason to have more Rust-based tools. Karthik Devaraj, a full-stack developer with MachineHack explains, “While Rust is an object-oriented language like C++, it combines less energy consumption with faster speed. Earlier, it used to take me around 21 seconds, but once I switched to the Rust-based SWC, it took me between 2 to 3 seconds.”
Marsh felt that the Python environment too could gain from similar faster tools. Ruff has been found to be over 150X faster than Flake8, a popular Python lint wrapper; 75X faster than pycodestyle, the official linter to check Python for the PEP8 Python style; and 50X faster than pylint.
Why is it popular?
Ruff now has become the primary linter for some of the most important Python-based projects like Pandas, FastAPI, Apache Airflow and Jupyter on GitHub even as it gets high praise from the community.
A developer listed the advantages of Ruff – “I love Ruff. These are reasons it ended up being better than simply touching a ‘standard of excellence’. First off, it has a second-mover advantage. It has learned from all the existing tools. Secondly, it is deduplicated work which means it pretty much is a ‘do everything’ and does it all at once. (Using three separate linters meeting different needs would mean it parses through the code three times). And thirdly, Rust is faster than Python.”
Just yesterday, Marsh tweeted the happy news that open-source platform Hugging Face had adopted Ruff already. Sayak Paul, a developer at the company spoke about the tool saying, “It’s bloody fast and actually takes actions instead of just plain erroring out that you didn’t use a particular import.”
Sylvain Gugger, a senior ML engineer at the company, in fact, lauded Marsh saying, “Thank you so much for writing Ruff! With Transformers having so many files, you’re saving us a loooooot [sic] of time on formatting.”
Marsh, however, has always been transparent about what he thinks are Ruff’s limitations, “It supports only a small set of rules till now and isn’t extensible in any way, it’s missing edge-case handling and is significantly under-tested compared to existing tools.”
Since then Marsh has worked on improving the tool. There’s an official VS Code extension released to support Quick Fix actions to autofix lint errors, flake8-to-ruff which automates migration from Flake8 to Ruff as well as Conda and Homebrew distributions for easy installation of the tool.