9 ms·
This is exactly my experience with Rust as well, people keep thinking C++ is an alternative to Rust with all the same features, but it’s not true. Rust is in ma
by bluejekyll 2y ago
This is exactly my experience with Rust as well, people keep thinking C++ is an alternative to Rust with all the same features, but it’s not true. Rust is in many ways a simpler language than C++ and that can make it more productive, “To Kamp's assertion that developers should just use C++, Somers said that he was far more productive in Rust and his code had fewer bugs, too. He said he had used C++ professionally for 11 years, but was more skilled in Rust after six months. The problem, he said, was C++.”
- andrewstuart 2y ago>> "in many ways" These words are doing a lot of work.
- woodruffw 2y agoI think it’s accurate to say that Rust’s syntax and semantics are both simpler than those of modern C++. That isn’t to say that Rust is a simple language (it manifestly isn’t), only that being simpler than C++ is not a hard bar to clear. (The proxy I use for this is the ratio of years spent programming to insane acronyms known. C++ has given me SFINAE, CTAD, SIOF, etc. so far, while Rust has only given me RPIT.)
- stingraycharles 2y agoDon’t forget RAII and CRTP (Curiously Recurring Template Pattern). As someone who has extensive experience in C++, Haskell, and Rust, I can confidently say that none of them is simple, it’s just that C++ has a mountain of legacy / technical debt that Rust has to deal with. If C++ were to be invented today, it would look a lot more like Rust.
- lifthrasiir 2y ago> If C++ were to be invented today, it would look a lot more like Rust. I'm not sure about this, because the world without C++ would have been quite different from today. The main complication comes from the fact that C++ was considered a much higher-level language than today, so its absence would have made other alternatives evolve differently.
- recursivecaveat 2y agoDon't forget the illustrious PPYP: pre-pooping your pants (:
- raybb 2y agoLink for those who also would have to look it up https://cglab.ca/~abeinges/blah/everyone-poops/ https://cglab.ca/~abeinges/blah/everyone-poops/
- blub 2y ago“Simpler” is so fuzzy that it doesn’t accurately express what’s going on. Rust doesn’t have the backwards compat baggage that C++ has, so it’s simpler. However, I can today easily write clean C++ that’s easy to understand, and using containers, algos and smart pointers is also robust. This is what the C++ community has settled on, while pushing complexity into libraries. The Rust community has settled on async, moves and references (with the lovely lifetime annotations) and other cognitive overhead, because they think that getting errors at compile time offsets all the mental overhead of those constructs. Then they gaslight all the beginners which complain about that mental overhead. So in theory Rust may be simpler, but idiomatic Rust isn’t. It’s differently complex.
- vlovich123 2y agoC++ has exactly the same async mechanism as Rust. Moves and references are much simpler in Rust - values only ever move and copies require an explicit clone unless the type is copyable in which case the compiler will implicitly clone if there’s conflicting ownership in the code. This is orders of magnitude simpler than c++ overloading of copy/move assignment and constructors, even when you follow the rule of 0 (not least of which is that you don’t to teach people about it or how to keep code exception safe). It’s kind of amusing to claim that c++ is simpler than Rust when it’s demonstrably not true - a new person to Rust is more productive after 6 months than a person new to c++. That implies the bar to getting proficient is low. A person can reach intermediate more quickly implying the bar to the next levels is lower. And it’s easier to maintain a rust project due to cargo meaning a usable easy build system out of the box that the entire community uses vs opinionated choices each project has to do, and macros that are easier to manage than preprocesser mess. So easier to maintain and easier to jump into any project. Oh and tests and mictobenchmarks out of the box and a very rich ecosystem of supporting libraries. Idiomatic rust is simpler than idiomatic c++ and it’s clearer what constitutes idiomatic rust whereas c++ in practice is rarely idiomatic and there are going to be conflicting ideas on what is idiomatic. This is ignoring the very real benefits of rarely to never dealing with a whole class of difficult to debug bugs (threading and memory safety) in the vast majority of code you’ll write .
- 2y ago
- tialaramex 2y agoTo be fair RPIT is part of a family, but they're actually just a weird way to name a variety of features that it made sense to give similar syntax in Rust. "IT" in RPIT means "impl Trait" the syntax, but what that syntax does varies by position (the P). https://www.youtube.com/watch?v=CWiz_RtA1Hw https://www.youtube.com/watch?v=CWiz_RtA1Hw Return Position Impl Trait is Existential Types, but Argument Position Impl Trait is just a simpler syntax for some Generics, same syntax, different meaning. This is actually one of the places where Rust is probably easier to pick up in use than to understand in theory. APIT and RPIT both "feel" right, but in type theory these are radically different features. In that way it's like some natural languages, native English speakers don't notice a bunch of the grammar rules they learned as kids, those rules just "feel" right and not formally taught.
- blub 2y ago[flagged]
- lifthrasiir 2y agoThe exact context [1] is more nuanced: > Only because this stuff all evolved from C code. Smart pointers would certainly work. > [In a following reply:] Actually, TBH it's because I'm not real great with C++. It's a difficult language, and after 2016 I stopped even trying to improve my C++ skills. Instead, I've been focusing on Rust. Even when I wrote these tests in 2019, I strongly considered using Rust instead of C++. In the end, the only thing that forced me to use C++ is because I wanted them to live in the base system, rather than in ports. So he surely knows about smart pointers but intentionally didn't use them. [1] https://lists.freebsd.org/archives/dev-commits-src-main/2024-January/021129.html https://lists.freebsd.org/archives/dev-commits-src-main/2024...
- josephg 2y agoWhat a monster. But let’s be real. Language preference is a real thing. Some developers don’t want to learn C++ properly and would rather use their own favourite language when developing. Likewise, some people don’t want to learn rust and would rather stick to C++ or Go or whatever. Of course some devs prefer C++ and some prefer rust. How is that surprising? For a community systems project like FreeBSD, rust would be a great option for developers who prefer it. But it would fragment the ecosystem more for everyone else. Whether or not that’s worth it for the project is always going to be a hard choice.
- lifthrasiir 2y agoYeah, that's why I can't really blame phk for objecting against Rust per se. But FreeBSD apparently had Perl in the base system for a long time, so presumably there always were needs for more (or different) languages to serve different needs. This time FreeBSD would also care about its dependence on broader ecosystems that wouldn't be usable within the base system though.
- dvhh 2y agoThe point was also probably that there is already a C++ compiler in the base, vs adding new headaches for adding and maintaining a rust toolchain in the base.
- tialaramex 2y agoBut that's an interesting point. Why is there a C++ compiler in the base? Do I find a long discussion on the FreeBSD list about whether it should have a C++ compiler? If not, why not?
- BSDobelix 2y agoBecause the System has to be self-hosting, remember it's a whole OS and not just the Kernel, and as you can see ~25% of src is C++, 62% C etc. Rewrite everything C++ is not a small undertaking with (maybe?) not allot plus-sides, and even then you still need C++ because of LLVM. LLVM and GCC are both C++, and you have to compile the Compiler (self-hosting), and even if your a 100% Rust or C OS, you still need C++ because of LLVM/GCC....well if you want a modern compiler ;) https://github.com/freebsd/freebsd-src https://github.com/freebsd/freebsd-src
- tialaramex 2y agoBut when you look what all that C++ is doing in Base, it seems like it's basically LLVM and then a lot of code that's just there to help you write more C++ code. Not a whole lot of the FreeBSD Base userspace, the uilities and so on - is actually written in C++ despite that. It's getting a free ride because the compiler uses it.
- BSDobelix 2y ago>it seems like it's basically LLVM Not important, you have to compile your Compiler fini, btw for Linux (just the Kernel) you need Perl ;)
- dvhh 2y agoBecause most C compilers also include a C++ compiler, or that the compiler toolchain of choice for freeBSD happens to be LLVM (it was an old version of GCC before because newer version use an incompatible license, and before that I think gcc replaced pcc in the original bsd unix, the discussion to pcc with gcc is probably lost in time) that includes C and C++ compiler. I am guessing that performance of current standalone C compiler is not as good as the one produced by compiler suit. Following the conversation thread, rust also use llvm under the hood, but a customized one. Which would force the base system to have two versions of llvm.