News for hackers. Stuff that matters.
Re:Pointers Are More Abstract Than You Might Expect in C by gilgoomesh on Monday July 02, 2018 @08:02AM (#17440940)
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.

Re:Pointers Are More Abstract Than You Might Expect in C by golergka on Monday July 02, 2018 @09:26AM (#17441403)
I 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.
Re:Pointers Are More Abstract Than You Might Expect in C by steveklabnik on Monday July 02, 2018 @12:59PM (#17443355)
While many people use nightly, the statistics show that most use stable, with some using nightly in addition. You just hear about nightly more.
Re:Pointers Are More Abstract Than You Might Expect in C by golergka on Monday July 02, 2018 @02:35PM (#17444274)
This 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".

Re:Pointers Are More Abstract Than You Might Expect in C by steveklabnik on Monday July 02, 2018 @02:40PM (#17444307)
Yes, it is a bit unfortunate that many suggest nightly. It makes sense, given that they’re enthusiasts, and therefore know all about the latest and greatest. But, these days, it’s becoming rarer and rarer to actually need it. But that’s only generally; it’s true that embedded often still needs nightly, though that should change pretty soon!

I wish Google didn’t customize results so much; I rarely see anything pre-1.0. It really makes it hard to figure out how to best help :/

Re:Pointers Are More Abstract Than You Might Expect in C by Scarbutt on Monday July 02, 2018 @01:21PM (#17443580)
Is 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.
Re:Pointers Are More Abstract Than You Might Expect in C by steveklabnik on Monday July 02, 2018 @01:51PM (#17443871)
If 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-Surve...

Re:Pointers Are More Abstract Than You Might Expect in C by enriquto on Monday July 02, 2018 @08:17AM (#17441003)
> 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.

Re:Pointers Are More Abstract Than You Might Expect in C by kibwen on Monday July 02, 2018 @12:04PM (#17442802)
> The same goes for Rust, probably.

Well, at least you have the good grace to admit that you haven't used Rust. :P

Re:Pointers Are More Abstract Than You Might Expect in C by civility on Monday July 02, 2018 @03:33PM (#17444696)
I'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.

Re:Pointers Are More Abstract Than You Might Expect in C by kibwen on Monday July 02, 2018 @11:48PM (#17447352)
The 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. :)
Re:Pointers Are More Abstract Than You Might Expect in C by civility on Tuesday July 03, 2018 @01:36AM (#17447809)
I 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.

Re:Pointers Are More Abstract Than You Might Expect in C by j16sdiz on Monday July 02, 2018 @09:36AM (#17441476)
This 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......

Re:Pointers Are More Abstract Than You Might Expect in C by CyberDildonics on Monday July 02, 2018 @11:17AM (#17442362)
While 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.
Re:Pointers Are More Abstract Than You Might Expect in C by NeedMoreTea on Monday July 02, 2018 @08:18AM (#17441009)
That was the argument of C++ advocates in the 90s.
Re:Pointers Are More Abstract Than You Might Expect in C by kibwen on Monday July 02, 2018 @09:50AM (#17441564)
Considering 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).
Re:Pointers Are More Abstract Than You Might Expect in C by basementcat on Monday July 02, 2018 @12:10PM (#17442872)
Apparently 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-g...

Re:Pointers Are More Abstract Than You Might Expect in C by CyberDildonics on Monday July 02, 2018 @11:19AM (#17442390)
Wasn'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.
Re:Pointers Are More Abstract Than You Might Expect in C by AnimalMuppet on Monday July 02, 2018 @01:18PM (#17443540)
I presume that you are defining C++'s virtual functions as "not a good facility for polymorphism". Why?
Re:Pointers Are More Abstract Than You Might Expect in C by int_19h on Monday July 02, 2018 @03:21PM (#17444600)
OP said nothing about C++, just plain C.
Re:Pointers Are More Abstract Than You Might Expect in C by AnimalMuppet on Monday July 02, 2018 @03:46PM (#17444781)
Ah, I see. I agree.
Re:Pointers Are More Abstract Than You Might Expect in C by pjmlp on Monday July 02, 2018 @10:53AM (#17442112)
At least C11 has light generics support.
Re:Pointers Are More Abstract Than You Might Expect in C by marcosdumay on Monday July 02, 2018 @02:04PM (#17444002)
It was just recently that C++ got some underpowered kind of generics (beyond templates). So, no, I don't think anybody advocated that in the 90's.

Late 90's advocacy was much more on the lines of "OOP lets you reuse code" and "widget libraries are great, and they all but require OOP". One of those is blatantly correct.