6 ms·
Do people really think Rust isn't a replacement for C? For the work I do - optimisation algorithms that must run As Fast As Possible - it absolutely is a much-s
by flooow 5y ago
Do people really think Rust isn't a replacement for C? For the work I do - optimisation algorithms that must run As Fast As Possible - it absolutely is a much-superior replacement for C.
I think what people mean is that Rust violates their perception of what C 'is' - 'simple, bare-metal, low-abstraction'. Well I don't think C is any of these things and Rust's memory model (borrow-checker) is a much more explicit and precise representation of the actual (implicit, undocumented) invariants of your C program. In that sense it is 'simpler'.
- vanderZwan 5y agoTo reword what you are saying in a slightly less dismissive tone: there are a lot people who stick to C because they don't like the added complexity of C++ (real or perceived). The same people are likely to look at Rust and perceive a lot of added complexity on their first impression, while also already feeling comfortable with C's complexity. With that combination switching over becomes a hard sell. Meanwhile Zig has a lot less perceived complexity, and most of it appears to be similar enough to the "C complexity" that C programmers are already familiar to not scare them off. (Again, I'm just giving outsider impression of someone who just read a ton of blog posts and basic tutorials + standard library stuff without really coding in either language)
- nicoburns 5y agoI think this is definitely a reasonable take. Having said that, Rust is not quite as complex as C++ so a lot of people who have rejected C++ are more open to Rust (the linux kernel being a prominent example).
- pron 5y ago> Rust is not quite as complex as C++ Yet. C++ wasn't as complex as C++ back when it was Rust's age. It wasn't even as complex as Rust. But if you pick a language for the next 20-30 years, you don't just care about where it is now, but also about where it is headed.
- tialaramex 5y agoIf you get things right first time, you don't need to add as much complexity on the journey to ship something usable. This is obviously easier coming from behind. You simply don't have to (and shouldn't) repeat other people's mistakes. > It wasn't even as complex as Rust I'm particularly dubious about this claim. Even counting from the genesis of C++ rather than standardisation, yet counting Rust as starting only in 2015, C++ after six years not only has multiple inheritance and overloading of everything, it also already has templates. That's a lot of complexity.
- pron 5y ago> If you get things right first time, you don't need to add as much complexity on the journey to ship something usable. There's no such thing as "getting things right the first time," because what's right depends on external, mutable, factors. The best anyone can do -- and most successful languages achieve -- is being well adapted to the environment. But the environment changes. For example, Java's object model was well adapted to an environment where memory access and computation were of roughly similar speed, but hardware changed so that computation is now faster than memory access, so Java is now changing to adapt to the current environment. On the other hand, its bet that memory is cheaper than computation has so far proven relatively long-lasting. But there's no telling what needs new hardware architectures or new software requirements will bring tomorrow. Both Java and C have adapted better, in my opinion, than C++, and it's not because of specific features, but because of their evolution ethos, which is different not only from C++'s but also from each other. My personal opinion is that C++ has tried for too long to be both high and low level, and that has shaped its particular evolution. I feel that Rust is repeating that same fundamental mistake, but, of course, others may disagree.
- deleted 5y ago[deleted]
- tialaramex 5y agoI don't agree that it's somehow impossible to get things right and I'm not even sure you really believe that. Take "explicit". In hindsight I suspect even many C++ proponents would agree that actually you don't want C++ conversion behaviour (when calling a function that takes a parameter of type X and you've provided a parameter of type Y, the C++ compiler will look for any way to construct an X that only needs a Y and then call that constructor rather than report that you've got the wrong type) by default. Perhaps C++ should have implicit conversion you can opt into, but it certainly should not have (as it does today) implicit conversion you must know about and opt out of to avoid blowing your feet off by mistake. But I argue that it goes much further than such superficial mistakes. Multiple inheritance is a mistake. Personally I'm sold on the theory that all type inheritance is a mistake full stop (heritability should be a property only of interfaces), lots of people don't agree, but far fewer support the choice C++ made to embrace multiple inheritance of types. It's just so rarely even useful let alone the best option to solve a problem.
- pjmlp 5y agoThey can even do use-after-free errors just like in C.
- vanderZwan 5y agoOh sure, but how many people who choose to be C programmers do you know who would be scared off by that? That's exactly what "familiar complexity" is about: people being comfortable with and not worrying about things that they're used to, even though they maybe should feel uncomfortable and worry a bit.
- pjmlp 5y agoMany people that choose to be C programmers think they can manage it, until their code runs under SonarQube or similar tools. It is like handling butcher knifes without metal gloves, they think they are worthless until they repent not wearing them.
- jerf 5y agoIf you're really, really good at C, you'll have realized that Rust doesn't add much to what you need to do. You're already doing what Rust does, you're just doing it manually without compiler support. Rust didn't create the issues associated with borrowing things, it merely surfaced them. They're always there, in any language you use, and since C is so manual, you better have figured that out if you plan on using it at a high level. I write mostly in Go, but I'm constantly tracking "ownership" issues in my language despite not having a "borrow checker", because the borrow checker doesn't create the issue. Plus if you're using C at a high level you ought to be using a static analyzer anyhow, that may not impose the exact same restrictions on you as Rust, but should be imposing enough discipline on you that using Rust doesn't seem so foreign.
- deleted 5y ago[deleted]
- mcguire 5y agoRust is, or was, explicitly a replacement for C++, and many of its features, including the borrow checker, are more supporting C++ generics/STL collections "done right".