By: FrankHB (, July 16, 2021 5:43 am
Room: Moderated Discussions
Gabriele Svelto ( on July 14, 2021 2:28 pm wrote:
> mozilla-central is one of the oldest FOSS C++ codebases around going back over 25 years. One of the
> reasons why it doesn't use all of C++ latest features is that it's unfeasible unless you restrict
> yourself to very recent compilers. A lot of decisions in the past about which features to use were
> driven by compiler support and the need to support multiple C++ compilers. Since we started using
> clang exclusively (but we still accept patches to support other compilers) we've picked up a number
> of more recent features. However introducing them is often not simple and requires a lot of manual
> intervention on the codebase. Compare this to Rust where using new feature is often a simple matter
> of running clippy on the code; something we can do in automation with no user intervention.

So, the quality issue is mostly for historical reasons, not specific to the concrete language. This is not typical enough to show the differences between the languages.

Note I don't mean it is necessary to update the required language version to get the latest features available. AFAIK Mozilla-central is routinely tied to a quite small set of versions (if not a specific version; usually not latest, but also not too old) of the C++ toolchain targeting Windows. There are regular efforts to make updates work. However, updates of the build environment might fail, at least I've seen the attempts to move it to MSYS2 and to WSL died suddenly on the half way. This implies there may be quality issues unrelated to C++ code. There should be also something else (in the sense of engineering or project management) preventing a steady progress to make the codebase just work with some language versions (e.g. C++11 onward) without too many toolchain-specific patches. Using Rust does not magically make the underlying problem disappear; it just allows a simpler policy about the concerning toolchain updates, because there is only one vendor of the Rust toolchain and one "tip" (in hg parlance) of the language versions in production, hence less compatibility issues. Nevertheless, the actual improvement about the whole experience is limited (if not worse), because the dependency of the C++ toolchain is not removed; then you may have to deal with C++ + Rust (+ Python...) problems rather than merely C++ (+ Python...) ones.

> > I believe this dude is not that good at C++, or even any other PLs.
> Knowing him, if he'd really be not that good at C++ then everybody else must have been terrible. But
> more seriously, "being good" with a specific language in order to write decent code is an argument against
> the language rather than for it. To me it's really a matter of ROI; Rust is by far the language that
> allowed me to write better code WRT the time I spent learning it (which is not much really).
"Being good" with knowledge strictly specific to C++ is usually unnecessary. The most important points for programmers to learn in practice are definitely shared among multiple PLs. In particular, the ownership semantic is very important for both C++ and Rust users. While many C++ users are not enough educated in this area, Rust users often learn the essentials by fighting with the borrow checker in the compiler. For users not already familiar with the principles about the ownership rules, the Rust way can save much time. This is not always a good thing, because users are too encouraged to rely on the language implementation without sufficient caveats. Some other less-known knowledge is also important, but not easy to be identified with the help from the compiler; sometimes the compiler is even totally clueless by design (e.g. the compiler cannot tell users the confidently safe policies/criteria to use the "unsafe" keyword). Users who relying on the compiler too much may be not self-disciplined enough to handle such problems well, so there will be naturally more risks on the code quality and more pressure on the project management.

> > The real value of Rust's
> > methdology is to ease programmers on reviewing others' code (comparing to the case that most
> > C++ users are poor on the coding skills and reviewers have to spend a lot of efforts to make
> > the code as expected). It does not ease much in the coding otherwise, as claimed here.
> Oh yes it does! Mostly because one your code compiles you're pretty sure that it works, or if
> it does not fails in a fully controlled way that is easy to debug. And that's not taking into
> account all the niceties that make your life easier such as truly nice cross-platform abstractions,
> exhaustive and terse error-handling, a rich and pragmatic standard library, a build system that
> Just Works™, excellent tooling including auto-formatting... I might go on for a while.

Well, the nice tooling is a certain benefit, the design is not. Sometimes not even more "correct" than C++.

For example, the abuse of explicitly fixed-width machine numbers in the basic type system is totally against the abstraction purpose: consider the fact you should not have many chances to have an exactly fixed-with integer like "i32" in the real business logic (expect for some low-level [de]serialization works between some on-wire formats and some in-memory representations), you're routinely making the conversion unconsciously to fit the semantic gap between the code and the real design implicitly. Such implicity is dangerous before you leak "i32" to the design, and then you totally failed to abstract details like "32" away. (Rust certainly won't insert any check between the gap of "i32" and the_real_type_you_need_in_the_design!)

And compared to exception handling, the typical error handling mechanism in Rust is somehow enforcing the designers of API to go against separation of concerns, because the error information is always forced explicitly (equally significantly to the non-error "workloads") in the type signature of API (also often bad for ABI compatibility, but this is an implementation detail).

Such glitches are often not obvious for most users, making it even more error-prone in everyday programming. I don't expect my life easier working with these users.

> > First, It is the programmer's responsibility to maintain the sane contracts in the code. Lacking
> > of safety checks is the normal case. In C++, to widen a contract (in the WG21 parlance) is
> > a bad practice, so C++ users are obliged to insert build-specific checks like assertions where
> > the compiler cannot enforce the contracts, in their daily work. This is somewhat laborious and
> > Rust has some limited improvents here (via the typechecking), but there is no execuse to miss
> > it. Explicit typechecking on dynamic types are the widen version of this discipline.
> Rust makes this a lot easier IMO, especially WRT ownership and error-handling which are two of
> the most difficult things to get right in C and C++. For example assertions are rarely needed
> because the type system allows you to fully control what gets in and goes out of a function.

Decreasing the need of the assertions for the contracts is promising, but I suspect it not feasible in the long term, because the type system is still to weak to express many things a user of interface may be interested in. And once ABI compatibility is concerned, it will be further limited because the cost of update of API can be significant. It is already an improvement to current C/C++, but I'm not sure it will perform better than C++ contracts in future.

There are some other uncertainty. The popularity of the idiomatic use is significant one. As we have known, C++ has the improvement of built-in non-nullable references besides the nullable pointers, but many C++ projects still avoid pointers in the interface even they are never nullable (and always non-owning). Thus, there is no actual improvement. I see Rust having less similar problems, though.

> Yes, absolutely. But that's also the reason why it just makes sense to use it. It's better
> in many respects because it's not bound by legacy and design decisions made in the late
> '70s. And I'm sure that ten or twenty years from now someone will come up with an even
> better language because of the same reasons. Lessons learned are important.

Lessons are learned inefficiently in the industry. I'm not too patient to wait for the changes.

For a motivation, I have already hit the performance bottleneck of stateful allocators in C++ due to too much register bandwidth consumed by the parameter passing, compared to simple replacing malloc by LD_PREOLAD. The allocator is necessary not just for performance reason, so I can't replace it by malloc. And there are apparently other problems to use namespace-scope or thread-local variable to hold the allocator. To mitigate the problem, using some opted-in dynamic scoped variable should be a good choice. But this way is just hard to hack (in the sense of the design, not only the implementation) within ALGOL-like languages. Other languages allowing easier hacks usually rely on GC, which mostly defeats the purpose to having an allocator.

I'd make up my own languages, anyway.

> > Third, there are many compromises in Rust. To list a few: missing the normative language specification,
> > missing a formal semantic model, missing the proper tail call guarantee, missing the orthogonality
> > on the mutablity and the sharing property on objects, missing the ability of user-defined side effects
> > on parameter passing, missing non-local control operators, etc. Some are so obvious that if some user
> > does not realize any of them, I'd suspect he/she not familiar with the language enough.
> Among those things I really don't understand why people keep bringing up the lack of a formal spec. Seriously,
> Rust has incredibly good documentation when C and C++'s specifications haven't even been public for a ridiculously
> long time. And in spite of the presence of a formal spec C and C++ compilers have systematically implemented
> divergent behaviors which lead pretty much any non-trivial codebase to have compiler-specific provisions in
> order to work (and require compiler-specific testing!). That's without even going into thorny arguments such
> as the debate around strict aliasing where a large portion of the language users preferred to ignore a part
> of the spec and deliberately chose a non-standard option because it worked best for them.
Well, lacking of a formal spec is not a big deal because the language is already complicated enough and a formal model will not ease the analysis on program semantics too much. However, it is particularly useful to formally prove the expected properties of the type system (e.g. soundness), and it is a solid basis to extend the type system.

I am more interested in the normative spec: the clear unambiguous criteria of some implementations to be Rust (the conformance rules). This is not only useful to authors of alternative implementations, but also for users who want to derive the specification to get some other modified designs of the language, i.e. hacking the language design.

ISO C and ISO C++ are not shared in the spec-level except a few references to the C standard library in the C++ standard library. Most fundamental rules, like the base type system, or even the definition of "implementation-defined behavior", are totally rewritten, although (1) there are many things mentally compatible or even exchangeable between ISO C and ISO C++; (2) ISO C++ seldomly makes changes almost verbatim merged back to ISO C (like "sequenced before" v. "sequence point", and the concurrent memory model).

A proper example of deriving a language from existing one is ECMA C++/CLI to ISO C++. The spec of C++/CLI only specifies the features not in ISO C++. This is far easier than maintaining a spec in parallel to ISO C++.

There are certain risks of fragmentation to encourage derivations of a programming language. But I don't think Rust can get everything just right in its official design, so having some divergent versions from the origin (namely, the dialects) may provide some locally better design choices to test for users who need them, which is also not bad for the remaining users.

Users of the divergent dialects should afford the cost of the code divergence. This is similar to the fact that C++ does not need to take care the decisions of C++/CLI, in contrast to the mess of mutually involved ISO C/C++ liaisons. Note that provided a spec, I don't think the divergence of unspecified behavior among conforming implementations a big problem; you already have them when there is only one implementation (since the reference cannot make everything as exact as the implementation, and there can be divergence between different versions).

Anyway, without a spec, it is even impossible to measure the fragmentation itself, and there are still the same risks after some unpredictable fork of the Rust's toolchain repo.

> > Ironically, all the compromises mentioned above except two (missing a formal semantic model and missing the
> > PTC guarantee) are accidentally better done in C++ than Rust. What a great evolution in this century!
> Do you have practical examples to prove this?

I don't know what kind of practical examples you want exactly.

The compromises mentioned above are all facts easy to see: you have no enough resources so you choose to skip to finish the spec; you have no resources to maintain the complicated C++ rules, to harmonize them to existing language rules and to take the risks they do not work well finally, so you do not support the some features as C++ (even if they can be coexisting consistently)... The reason I take the alternatives not in the current Rust "better" is in the sense that any work to explore the possibility is better than nothing (besides the decision of premature quitting the experiment), even the resulted design can have other problems.
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/09 08:56 PM
  Is unsafe hell truly good for linux kernel in the future?Brendan2021/07/09 11:59 PM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 12:37 PM
  Is unsafe hell truly good for linux kernel in the future?anon2021/07/10 03:14 AM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 12:40 PM
      Is unsafe hell truly good for linux kernel in the future?Gabriele Svelto2021/07/10 02:59 PM
        Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 03:42 PM
      Is unsafe hell truly good for linux kernel in the future?anon2021/07/11 05:11 AM
        Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/12 11:40 AM
  Is unsafe hell truly good for linux kernel in the future?Foo_2021/07/10 05:56 AM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 08:59 AM
      Most RWT posters don’t decide what goes into the Linux kernelMark Roulo2021/07/10 11:55 AM
      Is unsafe hell truly good for linux kernel in the future?Foo_2021/07/22 10:10 AM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 09:22 AM
      Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 09:24 AM
        Déja VuDismissive2021/07/10 09:41 AM
          Déja Vucqwrteur2021/07/10 09:47 AM
            Déja VuDismissive2021/07/10 09:51 AM
            Déja VuMichael S2021/07/10 12:11 PM
  Is unsafe hell truly good for linux kernel in the future?Gabriele Svelto2021/07/10 11:51 AM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 12:32 PM
      Is unsafe hell truly good for linux kernel in the future?Michael S2021/07/10 01:04 PM
        Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 01:25 PM
      Is unsafe hell truly good for linux kernel in the future?Gabriele Svelto2021/07/10 02:56 PM
        Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 03:41 PM
          Is unsafe hell truly good for linux kernel in the future?Rayla2021/07/10 04:33 PM
            Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 05:27 PM
              Interesting response... (NT)Rayla2021/07/10 08:02 PM
                perhaps just another lousy AI bot? (NT)anonymou52021/07/10 08:33 PM
                  perhaps just another lousy AI bot?dmcq2021/07/10 10:26 PM
                    perhaps just another lousy AI bot?cqwrteur2021/07/10 10:56 PM
                      perhaps just another lousy AI bot?dmcq2021/07/11 02:29 AM
                      perhaps just another lousy AI bot?anon2021/07/11 05:16 AM
                        perhaps just another lousy AI bot?cqwrteur2021/07/12 02:56 PM
                    perhaps just another lousy AI bot?Rayla2021/07/11 05:13 AM
                      perhaps just another lousy AI bot?cqwrteur2021/07/11 10:59 AM
                        When did I call you a bot, Kebabbert? (NT)Rayla2021/07/11 07:51 PM
              Alternatives?Brendan2021/07/11 12:54 AM
                Alternatives?Michael S2021/07/11 05:01 AM
                  Alternatives?Brendan2021/07/11 05:51 AM
                    Alternatives?cqwrteur2021/07/11 10:58 AM
                      Alternatives?Gabriele Svelto2021/07/12 12:31 AM
                        Alternatives?Michael S2021/07/12 02:58 AM
                          Alternatives?anon22021/07/12 08:08 AM
                            Alternatives?Michael S2021/07/12 08:22 AM
                              cqwrteur: Keep it politeDavid Kanter2021/07/13 07:59 AM
                          Alternatives?dmcq2021/07/12 08:37 AM
                            Alternatives?cqwrteur2021/07/12 03:04 PM
                              Alternatives?dmcq2021/07/12 03:26 PM
                                Alternatives?cqwrteur2021/07/13 12:47 AM
                                  Alternatives?dmcq2021/07/13 05:54 AM
                          Alternatives?Jörn Engel2021/07/13 03:53 PM
                            Alternatives?FrankHB2021/07/17 06:56 AM
                          Differences between Rust and C/GoGabriele Svelto2021/07/14 04:57 AM
                            Differences between Rust and C/GoFrankHB2021/07/17 08:47 AM
                        Alternatives?FrankHB2021/07/12 09:08 AM
                          Alternatives?Gabriele Svelto2021/07/14 01:28 PM
                            Inappropriate messages removed: cqwrteurDavid Kanter2021/07/15 09:59 AM
                            Alternatives?FrankHB2021/07/16 05:43 AM
                              Alternatives?Anon2021/07/16 11:01 AM
                                Alternatives?Gabriele Svelto2021/07/16 12:44 PM
                                Type abstraction and kernel programmingFrankHB2021/07/17 12:44 AM
                                  Type abstraction and kernel programmingdmcq2021/07/18 03:00 AM
                                    Type abstraction and kernel programmingdmcq2021/07/18 03:36 AM
                                  Type abstraction and kernel programmingEtienne Lorrain2021/07/19 12:03 AM
                                    Type abstraction and kernel programmingdmcq2021/07/19 01:01 AM
                                      Type abstraction and kernel programmingAnon2021/07/19 01:05 AM
                                        Type abstraction and kernel programmingdmcq2021/07/19 02:23 AM
                                      Type abstraction and kernel programmingBrendan2021/07/19 06:05 AM
                                Alternatives?gallier22021/07/20 03:57 AM
                                  Alternatives?Anon2021/07/20 05:24 AM
                                    Alternatives?Michael S2021/07/20 09:14 AM
                                      Alternatives?Anon2021/07/20 09:53 AM
                                        Alternatives?gallier22021/07/21 10:44 PM
                                      Alternatives?Adrian2021/07/20 11:00 AM
                                        Alternatives?Brett2021/07/20 10:13 PM
                                          Alternatives?Michael S2021/07/21 01:12 AM
                                            Alternatives?dmcq2021/07/22 11:58 AM
                                          Alternatives?Anon2021/07/21 07:58 AM
                      Alternatives?Brendan2021/07/12 01:34 AM
                        Alternatives?FrankHB2021/07/12 09:57 AM
                          Alternatives?cqwrteur2021/07/12 11:55 AM
                            Alternatives?FrankHB2021/07/12 08:44 PM
                          Alternatives?Brendan2021/07/12 07:52 PM
                            Alternatives?cqwrteur2021/07/12 10:05 PM
                              Alternatives?Anon2021/07/12 10:42 PM
                                Alternatives?cqwrteur2021/07/12 11:42 PM
                                Alternatives?cqwrteur2021/07/12 11:44 PM
                                  Alternatives?Anon2021/07/13 07:32 PM
                                    Alternatives?cqwrteur2021/07/13 08:36 PM
                                    Alternatives?cqwrteur2021/07/13 08:39 PM
                                      Alternatives?Anon2021/07/13 09:02 PM
                                        Alternatives?cqwrteur2021/07/13 09:18 PM
                                    Alternatives?cqwrteur2021/07/13 08:49 PM
                                      Alternatives?Anon2021/07/13 09:07 PM
                                        Alternatives?cqwrteur2021/07/13 09:16 PM
                                          Alternatives?Anon2021/07/13 10:31 PM
                                            Alternatives?cqwrteur2021/07/13 11:30 PM
                                              Alternatives?Anon2021/07/14 12:55 AM
                                                Alternatives?cqwrteur2021/07/14 01:22 AM
                                                  Alternatives?Anon2021/07/14 02:05 AM
                                                    Alternatives?cqwrteur2021/07/14 02:11 AM
                                                      Alternatives?Anon2021/07/14 03:16 AM
                                                        Alternatives?cqwrteur2021/07/14 06:06 AM
                                                          Alternatives?Anon2021/07/14 07:20 AM
                                                            Alternatives?cqwrteur2021/07/14 07:51 AM
                                                              Alternatives?Anon2021/07/14 11:33 AM
                                                              Alternatives?Gabriele Svelto2021/07/14 12:19 PM
                                                                Alternatives?FrankHB2021/07/16 06:07 AM
                                            Alternatives?cqwrteur2021/07/13 11:33 PM
                                              Alternatives?Anon2021/07/14 12:57 AM
                                                Alternatives?cqwrteur2021/07/14 01:21 AM
                                                  Alternatives?dmcq2021/07/14 02:06 AM
                                                    Alternatives?cqwrteur2021/07/14 02:50 AM
                                                  Alternatives?2021/07/15 07:33 AM
                                                    Alternatives?FrankHB2021/07/16 06:13 AM
                                            Alternatives?cqwrteur2021/07/13 11:39 PM
                                              Alternatives?Anon2021/07/14 01:08 AM
                                                Alternatives?cqwrteur2021/07/14 01:20 AM
                                                  Alternatives?dmcq2021/07/14 01:46 AM
                                                    Alternatives?cqwrteur2021/07/14 01:52 AM
                                                      Alternatives?dmcq2021/07/14 09:13 AM
                                                        Alternatives?dmcq2021/07/14 09:23 AM
                                                        Dealing with memory errorsBrendan2021/07/14 11:50 AM
                                                          Dealing with memory errorsdmcq2021/07/14 03:27 PM
                                                            Dealing with memory errorsBrendan2021/07/14 03:55 PM
                                                    Alternatives?cqwrteur2021/07/14 02:12 AM
                                                      Alternatives?Anon2021/07/14 03:16 AM
                                                        Alternatives?cqwrteur2021/07/14 05:55 AM
                                                      Alternatives?FrankHB2021/07/16 06:27 AM
                                                Alternatives?cqwrteur2021/07/14 01:38 AM
                                                  Alternatives?anon2021/07/14 02:50 AM
                                                    Stop feeding that trollnone2021/07/14 03:13 AM
                                                    Alternatives?cqwrteur2021/07/14 06:39 AM
                                                      Alternatives?Brendan2021/07/14 11:15 AM
                                                  Alternatives?Anon2021/07/14 03:19 AM
                                                    Alternatives?cqwrteur2021/07/14 06:12 AM
                                                      Alternatives?Anon2021/07/14 07:17 AM
                                                        Alternatives?cqwrteur2021/07/14 07:47 AM
                                                          Alternatives?Anon2021/07/14 12:00 PM
                                                            Alternatives?cqwrteur2021/07/14 12:44 PM
                                                          Alternatives?2021/07/15 09:36 AM
                                                  Alternatives?Gabriele Svelto2021/07/14 12:26 PM
                                                    Alternatives?cqwrteur2021/07/14 12:46 PM
                                                      Alternatives?Gabriele Svelto2021/07/14 01:36 PM
                                                        Alternatives?cqwrteur2021/07/14 01:55 PM
                                                          Alternatives?Smoochie2021/07/14 11:07 PM
                                                  Alternatives?2021/07/15 07:37 AM
                                                    Alternatives?Brendan2021/07/15 10:21 AM
                                                      Alternatives?Anon2021/07/15 12:15 PM
                                                  Alternatives?FrankHB2021/07/16 06:27 AM
                                          Alternatives?None2021/07/14 01:50 AM
                                            Alternatives?cqwrteur2021/07/14 01:54 AM
                                            Alternatives?cqwrteur2021/07/14 01:55 AM
                                              Alternatives?Rayla2021/07/14 04:47 AM
                                                Alternatives?cqwrteur2021/07/14 05:54 AM
                                              Alternatives?Gabriele Svelto2021/07/14 12:43 PM
                                Alternatives?FrankHB2021/07/12 11:47 PM
                            Alternatives?FrankHB2021/07/12 11:05 PM
                              Alternatives?Michael S2021/07/13 12:01 AM
                                Alternatives?FrankHB2021/07/13 12:25 AM
                            Alternatives?Doug S2021/07/12 11:29 PM
                              Alternatives?cqwrteur2021/07/12 11:48 PM
                              Alternatives?FrankHB2021/07/13 12:07 AM
              Is unsafe hell truly good for linux kernel in the future?2021/07/12 05:27 AM
                Is unsafe hell truly good for linux kernel in the future?Anon2021/07/12 08:46 AM
                Is unsafe hell truly good for linux kernel in the future?Etienne Lorrain2021/07/13 01:00 AM
    Is unsafe hell truly good for linux kernel in the future?cqwrteur2021/07/10 12:38 PM
Reply to this Topic
Body: No Text
How do you spell avocado?