6 ms·
You don't need to use any polymorphism (generics or traits) in Rust. You can use it as a pure structs and functions language like C (especially if you're not us
by gilgoomesh 8y ago
You don't need to use any polymorphism (generics or traits) in Rust. You can use it as a pure structs and functions language like C (especially if you're not using the standard library).
The argument in favour of at least some polymorphism is that it helps to minimise highly repetitive code that would be avoided in C through aliasing, type punning or other pointer conversion.
- enriquto 8y ago> You don't need to use any polymorphism (generics or traits) in Rust. You can use it as a pure structs and functions language like C This just means that the Rust language does not have the feature of being simple. Of course, there are sane subsets of C++ also (e.g., do not use new/delete), but this does not mean that C++ is a sane language. The same goes for Rust, probably.
- kibwen 8y ago> The same goes for Rust, probably. Well, at least you have the good grace to admit that you haven't used Rust. :P
- civility 8y agoI've used Rust. It's not simple. For instance, lifetime annotations are ugly and confusing. What a snarky reply from someone who already knows that Rust is not simple. The person you replied to was right, and yet you cast doubt on what he guessed to be true.
- kibwen 8y agoThe person that response was directed at was attempting to use a mistaken similarity to C++ to paint Rust as a language that is not "sane". You appear to be injecting your own interpretation as to what this subthread is about. :)
- civility 8y agoI assumed you were contradicting this quote: > This just means that the Rust language does not have the feature of being simple. I really don't know what it means for a language to be sane, so it didn't make any sense to me that you were replying to that part. My bad.
- NeedMoreTea 8y agoThat was the argument of C++ advocates in the 90s.
- kibwen 8y agoConsidering that C doesn't have any good facilities for polymorphism, it's going to continue to be the argument of any language that succeeds C. Unless, that is, that successor language also doesn't have any good facilities for polymorphism, in which case we have Go as a fascinating real-world study in how people will incessantly demand them and deride the language for lacking them (which is saying something, considering that interface{} in Go is already better than pretty much anything one would hack up in C via void pointers or macros).
- pjmlp 8y agoAt least C11 has light generics support.
- CyberDildonics 8y agoWasn't it originally a much bigger deal to be able to have the facilities for more generic programming before templates? These days people's threshold for bloat seems much higher, while the penalty for allocation and jumping around in memory are much higher as well.
- basementcat 8y agoApparently under certain conditions it is possible to emulate a crude form of ad hoc polymorphism in C. https://codegolf.stackexchange.com/questions/2203/tips-for-golfing-in-c/114619#114619 https://codegolf.stackexchange.com/questions/2203/tips-for-g...
- AnimalMuppet 8y agoI presume that you are defining C++'s virtual functions as "not a good facility for polymorphism". Why?
- int_19h 8y ago
- golergka 8y agoI love Rust, but I don't think that using a subset of Rust is a real option at this point. You'd have to stop using other libraries and even the standard library for this - and while it's possible, it definetly won't make your life easier. Rust has a wonderful community, but it's mostly filled with enthusiasts who're actively using nightly, so if you try to do things in a more limited way, you'll be on your own very often - much more often than for example I, personally, would be comfortable.
- steveklabnik 8y agoWhile many people use nightly, the statistics show that most use stable, with some using nightly in addition. You just hear about nightly more.
- Scarbutt 8y agoIs that still true for libraries? I think that's what he meant, not all rust users as a whole. My impression certainly agrees with him.
- steveklabnik 8y agoIf a library uses nightly, then you have to use nightly to use it. At this point, the only major library that requires nightly is Rocket, and Actix-web has been rapidly ascendant due to (rumordly) being used in production by Microsoft, and working on stable. The data, from last year’s survey, (which means even more stuff was nightly only, for example, the RLS) where you can choose multiple options https://blog.rust-lang.org/images/2017-09-05-Rust-2017-Survey-Results/which_version.png https://blog.rust-lang.org/images/2017-09-05-Rust-2017-Surve...
- golergka 8y agoThis is true, but doesn't refute my point. If you want not only to write something in Rust, but also to participate in the community and get help from it, it's much easier to do it if you're using nightly. I consider myself an experienced developer, but unlike other new technologies, which I almost always learn just from documentation, with Rust I often turn to community for help. I understand that this complexity is neccessary and I wouldn't Rust to be easier, of course. But still, with Rust's complexity and overwhelming amount of information that's already out of date with the best practices - it sometimes seems that over a half of google results on stack overflow are still about pre-1.0 Rust. And when we (people who learn Rust) turn to the community, it usually tells us (in the most helpful and nice way, of course) "just use nightly".
- j16sdiz 8y agoThis is exactly what c++ tried to do and failed. Of cause you can find a sane subset of c++ / rust that most comfortable with. But once your project accept c++ / rust, nothing can stop them using the other "features" of the language. Trying to enforce code style drain lots of energy from the project. Maybe a good linter can help......
- CyberDildonics 8y agoWhile I'm not a fan of polymorphism and actually avoid OO completely (except for making data structures out of classes of course) I feel like this could be something easily solved with tools, if making tools were easy.