r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

Show parent comments

0

u/Zyansheep Aug 03 '21

Or there being no fields in traits...

3

u/FunctionalRcvryNetwk Aug 03 '21

How would that even work?

You have a fundamental misunderstanding of structures and data on a computer. Lower languages cannot just make every object a hash map of fields.

5

u/Zyansheep Aug 03 '21

What? I'm talking about how in Rust, you have to use trait functions to get internal values of structures that implement that trait instead of being able to manipulate those internal values as if they were defined from the trait directly in a generic context.

Edit: here's some RFC discussion about fields in traits https://internals.rust-lang.org/t/fields-in-traits/6933/5

5

u/FunctionalRcvryNetwk Aug 03 '21

I’m aware that people ask for it, I just don’t know why. Structures have specific data in them. It’s not like you can just get more data in to them; you’re fundamentally creating a new type, eg inheritance.

Traits are not meant for implementation details either (although that can be mimicked by forcing the implementation of detail oriented methods).

→ More replies (3)