By: Gabriele Svelto (gabriele.svelto.delete@this.gmail.com), July 14, 2021 2:28 pm
Room: Moderated Discussions
FrankHB (frankhb1989.delete@this.gmail.com) on July 12, 2021 10:08 am wrote:
> Sorry, but under the impression the overall quality of mozilla-central is rather awful. I was shocked many times
> when I forked the codebase for my personal builds of the browser (because at that time I need the support for
> both XUL and WebExtensions addons and no upstream candidates worked with my existing profiles). Since the quality
> of the aged codebase is so poor, I don't think it a fair case to show the Rust-specific pros by code rewriting
> from C++ to Rust. I guess a rewriting to "modern" (whatever the concrete style it actually to be) C++ should
> also have more or less similar effects on LOCs if the paid employees of Mozilla are capable to that work in a
> sane way. Actually, some serious source bloats are fixed by simple and idiomatic C++ quite easily, e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=1141431.
> Rust won't do anything essentially better.
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.
> 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).
> 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.
> 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.
> Second, most C++ users may very likely have bad habits and intuitives on the coding style. Not all
> are their wrongs. Instead, many are the tech debts of the C++ source compatibility to C. For example,
> C++ textbooks traditionally teach the new-expressions before higher level resource management facilities
> like allocators and smart pointers, so users will likely to have "new" coming first in their mind when
> they need to allocate a new resource (object). This is bad because "new" should normally be the feature
> of last sorts, because all other facilities are more specific to the concrete intents and only "new"
> breaks the some important invariants (non-leaking guarantee, basic exception safety...) by default (not
> that bad in C because there are not many better choices, though). Noobs will hardly have these basic
> insights by themselves, no matter how long C++ they write. And I don't think feelings of most users are
> useful due to this reason. Nevertheless, in this sense, Rust deserves do better.
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.
> 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.
> I doubt if it will be in a better situation after aged Rust
> codebases are spread almost everywhere like C++ today.
We've obviously got little data about that - for now - but what we got shows that Rust codebases age much better than C++ ones. Mostly because of the tooling which makes it very simple to modernize old code, remove problematic patterns and exploit new features.
> 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?
> Sorry, but under the impression the overall quality of mozilla-central is rather awful. I was shocked many times
> when I forked the codebase for my personal builds of the browser (because at that time I need the support for
> both XUL and WebExtensions addons and no upstream candidates worked with my existing profiles). Since the quality
> of the aged codebase is so poor, I don't think it a fair case to show the Rust-specific pros by code rewriting
> from C++ to Rust. I guess a rewriting to "modern" (whatever the concrete style it actually to be) C++ should
> also have more or less similar effects on LOCs if the paid employees of Mozilla are capable to that work in a
> sane way. Actually, some serious source bloats are fixed by simple and idiomatic C++ quite easily, e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=1141431.
> Rust won't do anything essentially better.
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.
> 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).
> 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.
> 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.
> Second, most C++ users may very likely have bad habits and intuitives on the coding style. Not all
> are their wrongs. Instead, many are the tech debts of the C++ source compatibility to C. For example,
> C++ textbooks traditionally teach the new-expressions before higher level resource management facilities
> like allocators and smart pointers, so users will likely to have "new" coming first in their mind when
> they need to allocate a new resource (object). This is bad because "new" should normally be the feature
> of last sorts, because all other facilities are more specific to the concrete intents and only "new"
> breaks the some important invariants (non-leaking guarantee, basic exception safety...) by default (not
> that bad in C because there are not many better choices, though). Noobs will hardly have these basic
> insights by themselves, no matter how long C++ they write. And I don't think feelings of most users are
> useful due to this reason. Nevertheless, in this sense, Rust deserves do better.
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.
> 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.
> I doubt if it will be in a better situation after aged Rust
> codebases are spread almost everywhere like C++ today.
We've obviously got little data about that - for now - but what we got shows that Rust codebases age much better than C++ ones. Mostly because of the tooling which makes it very simple to modernize old code, remove problematic patterns and exploit new features.
> 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?
Topic | Posted By | Date |
---|---|---|
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/09 09:56 PM |
Is unsafe hell truly good for linux kernel in the future? | Brendan | 2021/07/10 12:59 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 01:37 PM |
Is unsafe hell truly good for linux kernel in the future? | anon | 2021/07/10 04:14 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 01:40 PM |
Is unsafe hell truly good for linux kernel in the future? | Gabriele Svelto | 2021/07/10 03:59 PM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 04:42 PM |
Is unsafe hell truly good for linux kernel in the future? | anon | 2021/07/11 06:11 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/12 12:40 PM |
Is unsafe hell truly good for linux kernel in the future? | Foo_ | 2021/07/10 06:56 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 09:59 AM |
Most RWT posters don’t decide what goes into the Linux kernel | Mark Roulo | 2021/07/10 12:55 PM |
Is unsafe hell truly good for linux kernel in the future? | Foo_ | 2021/07/22 11:10 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 10:22 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 10:24 AM |
Déja Vu | Dismissive | 2021/07/10 10:41 AM |
Déja Vu | cqwrteur | 2021/07/10 10:47 AM |
Déja Vu | Dismissive | 2021/07/10 10:51 AM |
Déja Vu | Michael S | 2021/07/10 01:11 PM |
Is unsafe hell truly good for linux kernel in the future? | Gabriele Svelto | 2021/07/10 12:51 PM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 01:32 PM |
Is unsafe hell truly good for linux kernel in the future? | Michael S | 2021/07/10 02:04 PM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 02:25 PM |
Is unsafe hell truly good for linux kernel in the future? | Gabriele Svelto | 2021/07/10 03:56 PM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 04:41 PM |
Is unsafe hell truly good for linux kernel in the future? | Rayla | 2021/07/10 05:33 PM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 06:27 PM |
Interesting response... (NT) | Rayla | 2021/07/10 09:02 PM |
perhaps just another lousy AI bot? (NT) | anonymou5 | 2021/07/10 09:33 PM |
perhaps just another lousy AI bot? | dmcq | 2021/07/10 11:26 PM |
perhaps just another lousy AI bot? | cqwrteur | 2021/07/10 11:56 PM |
perhaps just another lousy AI bot? | dmcq | 2021/07/11 03:29 AM |
perhaps just another lousy AI bot? | anon | 2021/07/11 06:16 AM |
perhaps just another lousy AI bot? | cqwrteur | 2021/07/12 03:56 PM |
perhaps just another lousy AI bot? | Rayla | 2021/07/11 06:13 AM |
perhaps just another lousy AI bot? | cqwrteur | 2021/07/11 11:59 AM |
When did I call you a bot, Kebabbert? (NT) | Rayla | 2021/07/11 08:51 PM |
Alternatives? | Brendan | 2021/07/11 01:54 AM |
Alternatives? | Michael S | 2021/07/11 06:01 AM |
Alternatives? | Brendan | 2021/07/11 06:51 AM |
Alternatives? | cqwrteur | 2021/07/11 11:58 AM |
Alternatives? | Gabriele Svelto | 2021/07/12 01:31 AM |
Alternatives? | Michael S | 2021/07/12 03:58 AM |
Alternatives? | anon2 | 2021/07/12 09:08 AM |
Alternatives? | Michael S | 2021/07/12 09:22 AM |
cqwrteur: Keep it polite | David Kanter | 2021/07/13 08:59 AM |
Alternatives? | dmcq | 2021/07/12 09:37 AM |
Alternatives? | cqwrteur | 2021/07/12 04:04 PM |
Alternatives? | dmcq | 2021/07/12 04:26 PM |
Alternatives? | cqwrteur | 2021/07/13 01:47 AM |
Alternatives? | dmcq | 2021/07/13 06:54 AM |
Alternatives? | Jörn Engel | 2021/07/13 04:53 PM |
Alternatives? | FrankHB | 2021/07/17 07:56 AM |
Differences between Rust and C/Go | Gabriele Svelto | 2021/07/14 05:57 AM |
Differences between Rust and C/Go | FrankHB | 2021/07/17 09:47 AM |
Alternatives? | FrankHB | 2021/07/12 10:08 AM |
Alternatives? | Gabriele Svelto | 2021/07/14 02:28 PM |
Inappropriate messages removed: cqwrteur | David Kanter | 2021/07/15 10:59 AM |
Alternatives? | FrankHB | 2021/07/16 06:43 AM |
Alternatives? | Anon | 2021/07/16 12:01 PM |
Alternatives? | Gabriele Svelto | 2021/07/16 01:44 PM |
Type abstraction and kernel programming | FrankHB | 2021/07/17 01:44 AM |
Type abstraction and kernel programming | dmcq | 2021/07/18 04:00 AM |
Type abstraction and kernel programming | dmcq | 2021/07/18 04:36 AM |
Type abstraction and kernel programming | Etienne Lorrain | 2021/07/19 01:03 AM |
Type abstraction and kernel programming | dmcq | 2021/07/19 02:01 AM |
Type abstraction and kernel programming | Anon | 2021/07/19 02:05 AM |
Type abstraction and kernel programming | dmcq | 2021/07/19 03:23 AM |
Type abstraction and kernel programming | Brendan | 2021/07/19 07:05 AM |
Alternatives? | gallier2 | 2021/07/20 04:57 AM |
Alternatives? | Anon | 2021/07/20 06:24 AM |
Alternatives? | Michael S | 2021/07/20 10:14 AM |
Alternatives? | Anon | 2021/07/20 10:53 AM |
Alternatives? | gallier2 | 2021/07/21 11:44 PM |
Alternatives? | Adrian | 2021/07/20 12:00 PM |
Alternatives? | Brett | 2021/07/20 11:13 PM |
Alternatives? | Michael S | 2021/07/21 02:12 AM |
Alternatives? | dmcq | 2021/07/22 12:58 PM |
Alternatives? | Anon | 2021/07/21 08:58 AM |
Alternatives? | Brendan | 2021/07/12 02:34 AM |
Alternatives? | FrankHB | 2021/07/12 10:57 AM |
Alternatives? | cqwrteur | 2021/07/12 12:55 PM |
Alternatives? | FrankHB | 2021/07/12 09:44 PM |
Alternatives? | Brendan | 2021/07/12 08:52 PM |
Alternatives? | cqwrteur | 2021/07/12 11:05 PM |
Alternatives? | Anon | 2021/07/12 11:42 PM |
Alternatives? | cqwrteur | 2021/07/13 12:42 AM |
Alternatives? | cqwrteur | 2021/07/13 12:44 AM |
Alternatives? | Anon | 2021/07/13 08:32 PM |
Alternatives? | cqwrteur | 2021/07/13 09:36 PM |
Alternatives? | cqwrteur | 2021/07/13 09:39 PM |
Alternatives? | Anon | 2021/07/13 10:02 PM |
Alternatives? | cqwrteur | 2021/07/13 10:18 PM |
Alternatives? | cqwrteur | 2021/07/13 09:49 PM |
Alternatives? | Anon | 2021/07/13 10:07 PM |
Alternatives? | cqwrteur | 2021/07/13 10:16 PM |
Alternatives? | Anon | 2021/07/13 11:31 PM |
Alternatives? | cqwrteur | 2021/07/14 12:30 AM |
Alternatives? | Anon | 2021/07/14 01:55 AM |
Alternatives? | cqwrteur | 2021/07/14 02:22 AM |
Alternatives? | Anon | 2021/07/14 03:05 AM |
Alternatives? | cqwrteur | 2021/07/14 03:11 AM |
Alternatives? | Anon | 2021/07/14 04:16 AM |
Alternatives? | cqwrteur | 2021/07/14 07:06 AM |
Alternatives? | Anon | 2021/07/14 08:20 AM |
Alternatives? | cqwrteur | 2021/07/14 08:51 AM |
Alternatives? | Anon | 2021/07/14 12:33 PM |
Alternatives? | Gabriele Svelto | 2021/07/14 01:19 PM |
Alternatives? | FrankHB | 2021/07/16 07:07 AM |
Alternatives? | cqwrteur | 2021/07/14 12:33 AM |
Alternatives? | Anon | 2021/07/14 01:57 AM |
Alternatives? | cqwrteur | 2021/07/14 02:21 AM |
Alternatives? | dmcq | 2021/07/14 03:06 AM |
Alternatives? | cqwrteur | 2021/07/14 03:50 AM |
Alternatives? | ⚛ | 2021/07/15 08:33 AM |
Alternatives? | FrankHB | 2021/07/16 07:13 AM |
Alternatives? | cqwrteur | 2021/07/14 12:39 AM |
Alternatives? | Anon | 2021/07/14 02:08 AM |
Alternatives? | cqwrteur | 2021/07/14 02:20 AM |
Alternatives? | dmcq | 2021/07/14 02:46 AM |
Alternatives? | cqwrteur | 2021/07/14 02:52 AM |
Alternatives? | dmcq | 2021/07/14 10:13 AM |
Alternatives? | dmcq | 2021/07/14 10:23 AM |
Dealing with memory errors | Brendan | 2021/07/14 12:50 PM |
Dealing with memory errors | dmcq | 2021/07/14 04:27 PM |
Dealing with memory errors | Brendan | 2021/07/14 04:55 PM |
Alternatives? | cqwrteur | 2021/07/14 03:12 AM |
Alternatives? | Anon | 2021/07/14 04:16 AM |
Alternatives? | cqwrteur | 2021/07/14 06:55 AM |
Alternatives? | FrankHB | 2021/07/16 07:27 AM |
Alternatives? | cqwrteur | 2021/07/14 02:38 AM |
Alternatives? | anon | 2021/07/14 03:50 AM |
Stop feeding that troll | none | 2021/07/14 04:13 AM |
Alternatives? | cqwrteur | 2021/07/14 07:39 AM |
Alternatives? | Brendan | 2021/07/14 12:15 PM |
Alternatives? | Anon | 2021/07/14 04:19 AM |
Alternatives? | cqwrteur | 2021/07/14 07:12 AM |
Alternatives? | Anon | 2021/07/14 08:17 AM |
Alternatives? | cqwrteur | 2021/07/14 08:47 AM |
Alternatives? | Anon | 2021/07/14 01:00 PM |
Alternatives? | cqwrteur | 2021/07/14 01:44 PM |
Alternatives? | ⚛ | 2021/07/15 10:36 AM |
Alternatives? | Gabriele Svelto | 2021/07/14 01:26 PM |
Alternatives? | cqwrteur | 2021/07/14 01:46 PM |
Alternatives? | Gabriele Svelto | 2021/07/14 02:36 PM |
Alternatives? | cqwrteur | 2021/07/14 02:55 PM |
Alternatives? | Smoochie | 2021/07/15 12:07 AM |
Alternatives? | ⚛ | 2021/07/15 08:37 AM |
Alternatives? | Brendan | 2021/07/15 11:21 AM |
Alternatives? | Anon | 2021/07/15 01:15 PM |
Alternatives? | FrankHB | 2021/07/16 07:27 AM |
Alternatives? | None | 2021/07/14 02:50 AM |
Alternatives? | cqwrteur | 2021/07/14 02:54 AM |
Alternatives? | cqwrteur | 2021/07/14 02:55 AM |
Alternatives? | Rayla | 2021/07/14 05:47 AM |
Alternatives? | cqwrteur | 2021/07/14 06:54 AM |
Alternatives? | Gabriele Svelto | 2021/07/14 01:43 PM |
Alternatives? | FrankHB | 2021/07/13 12:47 AM |
Alternatives? | FrankHB | 2021/07/13 12:05 AM |
Alternatives? | Michael S | 2021/07/13 01:01 AM |
Alternatives? | FrankHB | 2021/07/13 01:25 AM |
Alternatives? | Doug S | 2021/07/13 12:29 AM |
Alternatives? | cqwrteur | 2021/07/13 12:48 AM |
Alternatives? | FrankHB | 2021/07/13 01:07 AM |
Is unsafe hell truly good for linux kernel in the future? | ⚛ | 2021/07/12 06:27 AM |
Is unsafe hell truly good for linux kernel in the future? | Anon | 2021/07/12 09:46 AM |
Is unsafe hell truly good for linux kernel in the future? | Etienne Lorrain | 2021/07/13 02:00 AM |
Is unsafe hell truly good for linux kernel in the future? | cqwrteur | 2021/07/10 01:38 PM |