Earlier quoted context omitted.
Because many people start learning in one of the industry incumbent, not necessarily good by design languages. Java, C, C++, python, Javascript, go... As a second language is a quite different selector than after education in language design or excursions to functional programming.
Java enums are also quite powerful versus what C, C++ and C# can do. They are real objects, can have associated data and methods. So if they are surprised by Rust, haven't learnt Java properly
Enums in Rust – and why they feel better
21–30 of 80 posts
Re: Enums in Rust – and why they feel better
#22Better enums, but not better ADTs. I didn’t write a lot of compilers in Rust yet, but I find it limiting that you can’t pattern match across a Box , and all ASTs require boxing for recursive references.
[0] https://doc.rust-lang.org/beta/unstable-book/language-featur...
Re: Enums in Rust – and why they feel better
#23I always hated the name. You're not enumerating anything. You are picking a variant, encoding a choice. Maybe "sum type" is too "monad", but surely "variant record" or even "variant" would have been a better name.
In early Rust, the keyword was `tag`. In order to improve familiarity with C++ programmers, bikeshedding raged between `enum` and `union` for years before finally landing on the former.
I really wonder how that decision making progress looked like :)
Re: Enums in Rust – and why they feel better
#24Better enums, but not better ADTs. I didn’t write a lot of compilers in Rust yet, but I find it limiting that you can’t pattern match across a Box , and all ASTs require boxing for recursive references.
what a pleb
Re: Enums in Rust – and why they feel better
#25> A commonly said piece of feedback from someone who's learning Rust as a second language tends to be that enums are far better supported in Rust than any other language. This is nonsense. I doubt that this is common feedback and it is just not correct that it is far better supported in Rust than in any other language. Why would anyone say that? Rust pretty much has support for ADTs, sum types and product types. Just…
(I come from C/Embedded world)
Re: Enums in Rust – and why they feel better
#26> A commonly said piece of feedback from someone who's learning Rust as a second language tends to be that enums are far better supported in Rust than any other language. This is nonsense. I doubt that this is common feedback and it is just not correct that it is far better supported in Rust than in any other language. Why would anyone say that? Rust pretty much has support for ADTs, sum types and product types. Just…
There is a group of folks that had learnt these features via Rust, and for whatever reason always praise Rust for "inventing" them.
Re: Enums in Rust – and why they feel better
#27I always hated the name. You're not enumerating anything. You are picking a variant, encoding a choice. Maybe "sum type" is too "monad", but surely "variant record" or even "variant" would have been a better name.
Re: Enums in Rust – and why they feel better
#28Earlier quoted context omitted.
In early Rust, the keyword was `tag`. In order to improve familiarity with C++ programmers, bikeshedding raged between `enum` and `union` for years before finally landing on the former.
TBH it's kinda funny how they narrowed it down to two options and then went with the "obviously" wrong option (also to get C++ programmers on board, wouldn't the obvious name not be "variant"? I really wonder how that decision making progress looked like :)
Re: Enums in Rust – and why they feel better
#29Better enums, but not better ADTs. I didn’t write a lot of compilers in Rust yet, but I find it limiting that you can’t pattern match across a Box , and all ASTs require boxing for recursive references.
I think what you want is to enable box_patterns[0]. I have no idea why it isn't stable yet. [0] https://doc.rust-lang.org/beta/unstable-book/language-featur...
Box patterns are likely to be superseded by one of these:
Re: Enums in Rust – and why they feel better
#30Earlier quoted context omitted.
In early Rust, the keyword was `tag`. In order to improve familiarity with C++ programmers, bikeshedding raged between `enum` and `union` for years before finally landing on the former.
TBH it's kinda funny how they narrowed it down to two options and then went with the "obviously" wrong option (also to get C++ programmers on board, wouldn't the obvious name not be "variant"? I really wonder how that decision making progress looked like :)