3 ms·
> add to Ruff a way to write rules in a DSL But if you start going down that route, isn’t it likely that you’d end up making Ruff into a full-blown interpreter
by codetrotter 4y ago
> add to Ruff a way to write rules in a DSL
But if you start going down that route, isn’t it likely that you’d end up making Ruff into a full-blown interpreter?
Or that you end up embedding an interpreter into Ruff. Such as for example.. Python.
At either of which point, the motivation to use Ruff instead of e.g. Pylint might begin to disappear?
- Yoric 4y agoGiven how easy it is to write Rust code that calls Python or Python code that calls Rust, it might even be possible to write Ruff rules in Python.
- oblio 4y agoDo you happen to have handy a good article about these 2 way calls?
- KptMarchewa 4y agoThere is something better than article: documentation. https://pyo3.rs/v0.18.1/ https://pyo3.rs/v0.18.1/
- coldtea 4y ago>But if you start going down that route, isn’t it likely that you’d end up making Ruff into a full-blown interpreter? Not any more than with any other DSL. You can always stop at a subset enough to handle expressing linting rules. Or expressing many linting rules. Doesn't need to be able to express every possible rule -- which is the reason you'd make it a full blown interpeter. Pareto and all. Even if that's not possible (and you need turing completness to handle custom rules), then: >At either of which point, the motivation to use Ruff instead of e.g. Pylint might begin to disappear? Well, Ruff would still have crazily faster parsing and built-in rules. It's not like you'd be forced to use custom interpreted rules. And even in that case, a purpose-specific built interpeter, even if general, could be way faster (because it's optimized for a specific task and doesn't need to carry garbage as the GIL and other CPython decisions), and with better task-focused primitives, compared to embedding CPython.
- avgcorrection 4y agoJust AOT compile the DSL? :)