Remix.run Logo
dathinab 4 days ago

yes

the main issue here is that it's basically a list of thing which are "lang_item"s, i.e. have a `#[lang = ...]` attribute or are build in `&/&mut/str/[T]` etc. (but then for some reasons lists combinations of them!?). But `#[lang]` is mainly there to map types to some compiler special casing which might be as trivial as a optimization hint...

and the thing with that is it's

- not useful for teaching *at all* as it's not representing the semantic/logical building blogs, or what "core" means in rust terms or what you have to learn when learning the language or anything. _It pretty much only is relevant if you write the compiler or the standard library for rust_.

- isn't really that useful for know what the "core" of rust is (as many of this items only have a lang tag to make sure some "special case" optimizations, compiler messages, etc. map correctly, and at least in the past you also didn't really have to have all lang items to use rust in a _very_ cut down way)

- conflicts with the term of lib-core (which is a very cut down version of lib-std for embedding use-cases where you e.g. might not have alloc, but you can even write rust without lib-core)

E.g. `Termination` isn't a "core" rust feature, it's a nice customization hook which main exist so that you can have all of `!, (), ExitCode, Result<T,E>` as return types of main, which is mostly irrelevant outside of some QoL edge cases. In general you don't need to know about it and in 99% of cases you shouldn't implement it either.

E.g. Deref,DerefMut, Index, IndexMut, the various Range types, the various operator aren't really special in any way except "hey they have first class syntax" and thats it, the #[lang] tag just tell the compiler "if you find += map it to AddAsing::add_assign".

E.g. the lang tag on `Ordering` is basically a optimization hint AFIK.

etc. etc.

there really is little use for the overview outside of a curiosity and calling it the "core elements" of rust is really just very very misleading

MeetingsBrowser 3 days ago | parent [-]

> not useful for teaching at all ... _It pretty much only is relevant if you write the compiler or the standard library for rust_.

This seems a little hyperbolic.

> isn't really that useful for know what the "core" of rust is

In the same way it isn't useful for python developers to know what the stack and heap are, maybe.

> conflicts with the term of lib-core

I don't know what group of people might see this and get it confused with lib-core. Most people looking at this will never encounter lib-core directly, the rest are unlikely to look at this and think it has anything to do with lib-core.

> Deref,DerefMut, Index, IndexMut, the various Range types, the various operator aren't really special in any way except "hey they have first class syntax"

first class syntax makes them pretty special IMHO

> there really is little use for the overview outside of a curiosity

I think its a great way to get a high level view of the Types/Traits provided by Rust.

dathinab 3 days ago | parent [-]

But what the author really mixes up is that lang item is in now way the same as "a core part of rust".

lang item is only a way to tag things to be special known to the compiler, which sometimes is related to implementation details of the compiler which have little to do with the language design

which also means the following statement

> The purpose is to demystify what can be built purely in library code.

is not fully right.

E.g. at least all of Ordering, Option, Result, Clone can be build just fine in library, the lang item is mainly there for optimization hints (and in case of Option FFI layout reasons), but it's an implementation detail which doesn't really needs them to be lang items it was just more convenient to do so when implementing the compiler. A compiler could just give similar properties to anything which "looks like" them. There are subtle fiddly reasons why you maybe don't want to do that for now but technically an implementation detail anyway.

And lot of the things which technically can be implemented in a library (e.g. Display) practically kinda can't, as this would cause major interoperability issues.

Oh also some special macros you can't implement in a library are missing, but that just seems like a minor oversight of the otherwise quite complete list.

But most importantly this is not the conceptual core of the language (but a overlap with it) which would include stuff which has no need to be lang tagged but is a fundamental core design aspect of rust (e.g. Waker for async rust).

For a technical aspect of what needs special handling Ordering, Result and some other parts do not, it's just conveniently makes certain things mostly related to optimizations easier to implement.

From a high level POV especially in context of teaching rust it contains too many low level parts for niche extension functionality (e.g. panic stuff, termination trait) or too advanced to belong in a high level overview IMHO. And misses a lot of things you would include in a teaching the core of rust for people which learn rust overview.

I mean without question the author put a lot of work into it and it's not useless, but IMHO badly named as a listing of lang items just isn't exactly core of rust language design, or core of how you use it.

It it an important listing for changing the rust compiler or writing your own lib-core, tho.

But that means the the thing its effectively most useful for is an advanced topic, so I wouldn't use it for teaching rust. Too many parts which are core of teaching rust missing (e.g. Debug) while exposing students to too many advanced topics in a way where they look as relevant as relevant parts.