A GPIO driver in Rust
A GPIO driver in Rust
Posted Jul 19, 2021 22:40 UTC (Mon) by marcH (subscriber, #57642)In reply to: A GPIO driver in Rust by Paf
Parent article: A GPIO driver in Rust
But even that could be deceiving because one language or its code style could be "too terse" requiring more comments which would make the code longer in the end.
> it’s interesting to ask why at least.
Comparing the lengths of two solutions in the same language has some value but for two totally different languages it's apples versus oranges because pretty much every language difference can affect the end total. These differences are worth discussing individually, not as an aggregate basket of disparate things.
If the main discussion topic that comes up when comparing equivalent C and Rust code is a 20% difference in the number of lines then maybe it was not very useful to have them side by side.
Posted Jul 19, 2021 23:49 UTC (Mon)
by tialaramex (subscriber, #21167)
[Link] (1 responses)
Or conversely, maybe it was useful because it turned out one of the main topics was "This one is a bit longer/ differently formatted" which suggests a Rust driver and C driver are not so very different after all.
I think it's much easier to convince programmers that a new language is utterly alien and terrifying if you present some random snippet they're unfamiliar with. Stuff whose equivalent they would never dream of writing at all, may convince them the language is ill-suited to their purpose. If we showed this device driver code to somebody wondering if they can rewrite their web app in Rust they're going to freak out. Interrupts? Register banging? What's going on? Well, it's a kernel device driver, those things are exactly to be expected, and contrariwise, this kernel code lacks string interpolation, asynchronous function calls, and so on you'd find in the web app.
Idioms don't translate 100% and I think the ensuing summit list discussion shows people feeling their way around and this LWN discussion likewise. I can imagine some kernel style being enforced for kernel Rust, I doubt Linus is going to demand that Rust macros yell louder, but he very well might insist on different indentation and line length rules, rustfmt should cheerfully fix that without any significant human labour.
So this example driver was a great idea, and I think the side-by-side layout was, though not essential, a useful contribution to understanding.
Posted Jul 20, 2021 0:44 UTC (Tue)
by marcH (subscriber, #57642)
[Link]
That's much more optimistic perspective of "bikeshedding" and I genuinely appreciate it, thanks!
A GPIO driver in Rust
A GPIO driver in Rust
