4 ms·
To be fair, the thing that makes a working C++ standard library unreadable is also a hazard in understanding Rust's std. Macros. The macros in a C++ standard li
by tialaramex 5y ago
To be fair, the thing that makes a working C++ standard library unreadable is also a hazard in understanding Rust's std. Macros. The macros in a C++ standard library are horrible, because it is here that essential compliance and compatibility are squirreled away, and because the C++ macros aren't hygienic they're bigger than they'd otherwise need to be (e.g. you mustn't call it foo, say __x5_foo instead). But while they're far more readable on their own terms, the Rust macros littering std do mean it's harder to see how say, a trivial arithmetic Trait is implemented on u32 because a macro is implementing that trait for all integer types.
A macro-pre-processed std might be easier for the non-expert rustacean to grok even though it isn't the canonical source.
The symbol thing is pure insanity, machines have no problem knowing what symbol8164293 refers to, but humans can't get that right, and programming languages, including in theory C++ are intended for humans to write.
- khuey 5y agoThe thing that makes the C++ standard library source difficult to understand in my experience is heavy usage of templates and very deep inheritance chains.
- pcwalton 5y agoThe _Weird_identifier_naming_convention that the STL has to use to avoid colliding with potential user-defined macros doesn't help either.
- afdbcreid 5y agoRemember that expanding macros includes things like `println!()`. I'm not sure beginners will find the following particularly easy to read: { ::std::io::_print(::core::fmt::Arguments::new_v1( &["Hey ", "!\n"], &match (&name,) { _args => [::core::fmt::ArgumentV1::new( _args.0, ::core::fmt::Display::fmt, )], }, )); }; Although, to be honest, I don't think there are many usages of these macros in std.
- tialaramex 5y agoGood point. I hadn't considered panic!() in particular which is used in std, and the Debug implementations in std won't make a huge amount of extra sense after macro-pre-processing either.