5 ms·
My observation is most people who suggest Rust alternative don't use Rust. People who actually use Rust known it is worth to rewrite C/C++ software in Rust, eit
by ultimaweapon 1y ago
My observation is most people who suggest Rust alternative don't use Rust. People who actually use Rust known it is worth to rewrite C/C++ software in Rust, either the whole or part by part. There is a tool to convert C source into Rust too so you can retain the whole functionalities while migrating to Rust. I have done this with Lua and it work wonderfully.
The good news is Linux now adopt Rust. In the end it will be all Rust although it may take a long time to migrate from C.
- alberth 1y ago> I have done this with Lua Do you by chance work at Cloudflare, who has migrated away from Lua to Rust? Curious to hear observations on productivity hit going from Lua to Rust.
- pornel 1y agoIn Cloudflare's case, Rust is much more productive. Rust modules can handle any traffic themselves, instead of a split between native code and Lua that is too slow to do more than config (Lua is relatively fast for a scripting language, but on the critical path it was a "peanut butter" slowdown adding latency). At the size and complexity of a server serving 20% of the Web, Lua's dynamic typing was scary. Modules in Rust can enforce many more requirements. Rust's solid dependency management also helps share implementations and config logic across modules and even different products, instead of everything having to go literally through the same server. https://blog.cloudflare.com/20-percent-internet-upgrade/ https://blog.cloudflare.com/20-percent-internet-upgrade/
- alberth 1y ago> instead of a split between native code and Lua that is too slow to do more than config In case you’re not aware, Cloudflare ran on LuaJIT (not just for config) until not that long ago. https://news.ycombinator.com/item?id=23856875 https://news.ycombinator.com/item?id=23856875
- steveklabnik 1y agoFive years ago is a pretty long time, and kornel does (or did) work at Cloudflare.
- woooooo 1y agoCarbon is made for companies like Google with millions of lines of C++ using very C++ interfaces. They can't incrementally rewrite without refactoring everything to C-style headers, and that would probably involve a ton of void-pointer nonsense if its even possible.
- dmoy 1y ago> millions s/m/b/ too
- jandrewrogers 1y agoIn my experience, rewriting C++ into Rust is non-trivial because idiomatic C++ expresses things that Rust cannot. This impedance mismatch breaks architecture, and that often isn’t allowed in a rewrite. I’ve seen multiple C++ rewrite attempts fail because of poor interoperability with Rust’s constraints. Language interoperability that is high quality and low friction matters to people, and in the case of C++ that is decidedly challenging. My view at this point is that you are better off starting from a clean sheet of paper in Rust than trying to make Rust do C++ things it was not designed to do. In the specific narrow case of performance-engineered code, Rust also seems to consistently produce slower code in my experience for myriad weird reasons, it isn’t one thing. In many cases I don’t even think it is the fault of the language per se, just a side effect of other factors. Nonetheless, customers don’t care about any of that, they won’t accept a performance regression just because you rewrote it.
- deleted 1y ago[deleted]
- zozbot234 1y agoIdiomatic "modern C++" as defined by the Core C++ Guidelines is very similar to Rust, it even has its own bespoke ownership+lifetime checking mechanism.
- steveklabnik 1y agoDo you know if any big public projects using the GSL or similar? I haven’t found any but I’d like to check them out.
- joz1-k 1y ago> My observation is most people who suggest Rust alternative don't use Rust. This is a very condescending statement. In fact, for most software, when given the option of a full rewrite from C/C++ to another language, Rust is usually the least reasonable option. Fully automatic memory-managed languages should be considered first. > People who actually use Rust known it is worth to rewrite C/C++ software in Rust, either the whole or part by part. A full rewrite is not a feasible option for many large projects, and Rust does not make it easy to rewrite C++ code piece by piece, as the linked article clearly explains. It's not true that developers don't like full rewrites. Most often, it's the path most developers would choose if they had enough time and funding. But in reality, you don't get either of those two. And even if you are willing to do a full rewrite, your project probably has non-trivial dependencies on large, mature C++ libraries. You are not going to rewrite those. This is why more new projects are started in C++ every day than in Rust.
- tormeh 1y agoYou can use C++ libraries from Rust. That's a very normal thing to do. People start new projects in C++ either because they themselves don't want to learn a new thing or because they don't want their employees spending time learning a new thing.
- Narew 1y agoAppart from cxx.rs. I think most binding between C++ and Rust are in fact C and Rust binding. So you need a C API to your C++ library (no template, no std etc...). So for me you can't use C++ library from Rust.
- tormeh 1y agoYou can just use CXX? Idk what to tell you. A coworker of mine is doing it. It's not some kind of weird thing.
- Narew 1y agocxx only support a part of c++ STL container. It doesn't support template and custom container implementation. So no generic, no variadic number of argument, no automatic type déduction etc...
- OvbiousError 1y agoMy observation is most people who mix up C and C++ use neither. How could you even automatically migrate when a lot of things you do in C++ are straight up illegal. Not to mention relying on third-party software like Qt.
- pjmlp 1y agoIt really hate libraries that call themselves C++ libraries, when they effectively are written in the common subset, with extern "C++" for C++ users. Technically correct by ISO C++, in practice that isn't the way to write modern code.
- northlondoner 1y agoLinux is only adopt Rust for device drivers and selective subsystems. I am not sure if it is a wide-adoption.
- tialaramex 1y agoThere are Linux targets which don't have Rust. So the drivers rule is because if we make the mm subsystem depend on Rust then a dusty architecture with no Rust can't run Linux any more. This is tolerable for userspace, realistically your Python document mangling code probably does not in fact need to work properly on a machine nobody has manufactured since the 1980s - but not acceptable to Linus Torvalds. The expectation is that over the next say, decade, Rust gets more trusted by Linux maintainers and perhaps grows more platform support e.g. via the GNU Compiler Collection, and simultaneously some of the dustier platforms "rust out" of Linux because the few maintainers stop caring about new Linux versions. So one day you can rewrite core subsystems in Rust if that makes sense.
- pornel 1y agoCarbon devs explicitly say use Rust if you can. Non-trivial C++ programs depend on OOP design patterns, webs of shared-mutable objects, and other features which Rust doesn't want to support (Rust's safety also comes from not having certain features that defeat static analysis). Rust really needs things written the Rust way. It's usually easier with C, because it won't have clever templates and deep inheritance hierarchies. Even if your goal is to move to Rust, it may make sense to start with Carbon or Circle to refactor the code first to have more immutability and tree-like data flow.