8 ms·
Rust doesn't solve any real problem. It's a meme language that is only used for writing blog posts and internet commentary.
by otabdeveloper4 4y ago
Rust doesn't solve any real problem.
It's a meme language that is only used for writing blog posts and internet commentary.
- hoten 4y agoI suppose Figma is a meme company sold for meme dollars? https://twitter.com/figma/status/991697942070333447?lang=en https://twitter.com/figma/status/991697942070333447?lang=en
- otabdeveloper4 4y agoUnironically yes.
- pjmlp 4y agoThe money maker WebAssembly part on the browser is still C++.
- Karellen 4y agoSo, Linus Torvalds, who rejected calls for code written in C++ to be accepted into the Linux kernel for decades because he thought that the extra features it provides were not worth the added complexity it would bring, has decided to allow Rust support in Linux because... he suddenly got infected with brain worms that made him want to be a crowd-following blogger writing commentary for internet upvotes? And not because he thinks Rust might be able to solve actual problems in kernel development? I want whatever drugs you're taking.
- fluoridation 4y agoTo be completely honest, I would wager it was more a matter of ego than anything rational. C++ kept improving over time and he knew that, but rather than revise his position and admit to an error, he stubbornly persisted until Rust came along, and that gave him an out. "Well, C++ is too shitty; but Rust, a language that has not been around for even a decade, that's was I want to add support for in the kernel". Rust has pretty much all the failings he accused C++ of having, it just has memory safety as an additional benefit.
- tsimionescu 4y ago> Rust has pretty much all the failings he accused C++ of having, it just has memory safety as an additional benefit. Memory safety is one hell of a benefit. In contrast, if you look at Linux' coding style, C++ really doesn't have any benefit over C. Not to mention, many of C++'s advantages come from the STL, which wouldn't work without extra work in kernelspace. Rust has been designed for running on bare metal from day 1.
- bluGill 4y agoLinux would benefit from a compiler to build a vtable where plugins are needed. Linux would benefit from a STL like library that might be home grown but will support more types than whatever they are doing now .
- fluoridation 4y agoYou're talking about migrating kernel code to C++, but I'm talking about supporting C++ code in the kernel. That is, if third parties wanted to write Linux drivers, the only supported way was to do it in C. That aside, the kernel does do polymorphism the hard way (with unions and arrays of function pointers) in a few places; the example I saw was some filesystem code, I think. C++ is also much more type-safe than C, mostly by refusing to implicitly convert between unrelated pointer/reference types and preventing you from inadvertently doing something absurd. References also make null checks unnecessary and convey to the caller that they're supposed to pass something valid, and RAII simplifies a lot of resource management. Templates also reduce boilerplate and are type-safe, although they're also a harder sell and not everyone's cup of tea. I agree that memory safety is a huge advantage (although on the other hand, a double linked list in Rust is currently impossible without unsafe blocks), but I refuse to believe this decision has nothing to do with stubbornness.
- tsimionescu 4y ago> the kernel does do polymorphism the hard way (with unions and arrays of function pointers) in a few places Using C++ classes has some disadvantages compared to C-style polymorphism - especially related to memory layout and allocation - in C++, memory is allocated by the code instantiating the object, not by the object's code, so you have to know the size of the type (including private fields) in any place where you are instantiating it. Not sure how relevant this is for kernel code. > C++ is also much more type-safe than C, mostly by refusing to implicitly convert between unrelated pointer/reference types and preventing you from inadvertently doing something absurd This part I agree with. > References also make null checks unnecessary and convey to the caller that they're supposed to pass something valid I think the distinction between references and pointers is one of C++'s worse ideas. You can't generally replace pointers with references either. > RAII simplifies a lot of resource management RAII doesn't work without bringing in a whole lot of other heavy-duty features: mainly exceptions, but also constructors and destructors. > Templates also reduce boilerplate and are type-safe Templates are more type-safe than macros, but not that much more (since the template language is essentially a dynamically-typed program, even though its output is a C++ AST that will be further type-checked). Like RAII, they also require you to use other features of C++, especially operator overloading, and likely also copy (and more recently, move) constructors. > I agree that memory safety is a huge advantage (although on the other hand, a double linked list in Rust is currently impossible without unsafe blocks), but I refuse to believe this decision has nothing to do with stubbornness. I do agree that stubbornness may well be a component. However, I believe that there is a coherent argument that can be made that supporting C++ for kernel modules is not worth it, while supporting Rust for kernel modules is. I'm not saying that this is the argument that Linus is making, but I do believe it can be made. Especially since we also need to remember that all kernel modules are part of the kernel source tree. Supporting an additional language has a significant cost for everyone who is maintaining the kernel, since they need to add tooling to handle that extra language for all targeted platforms. It should also be remembered that C++ compilers are even worse than C compilers at mis-using instances of undefined behavior to mis-optimize code, especially since they typically rely even more on optimization steps to have half-decent performance.
- otabdeveloper4 4y agoWake me up when some real kernel module actually gets written in Rust. (Actually, no, strike that, I don't want to sleep forever.)
- jobs_throwaway 4y agois memory safety not a real problem?