Live data from Hacker News

Rust 1.45

blog.rust-lang.org

211–220 of 227 posts

Re: Rust 1.45

#211

Earlier quoted context omitted.

The Rust memory model is deviating from it a little in order to enable some norestrict-based optimizations that aren't really done for C, even though (as you know) LLVM can't really take advantage of them yet.

I imagine that in C if the compiler can prove that two pointers don't alias than it can elide a load?

It is very much compiler specific, and also depends if modifiers like volatile are present or not.

Re: Rust 1.45

#212

Earlier quoted context omitted.

`as` is not considered idiomatic in Rust code,. `.into()` for infallible cases and `.try_into()` for fallible cases are preferred in almost all cases (in the case of floats there's still discussion around the correct behavior of `.try_into()` for edge cases). > So I think this is again an example of rust making a decision that hurts program correctness. Could you expand on other examples?

> `as` is not considered idiomatic in Rust code Yes it is. It's used all the time . There's a reason as_conversions defaults to Allow in clippy. Of course, there are lots of situations where `as` is the wrong tool for the job, but I think it's a bit of a stretch to call `as` "not idiomatic". It's perfectly idiomatic in lots of situations. Whether or not it should be idiomatic is a separate question.

Your claim that “as” being used is incompatible with it being unidiomatic is false.

The docs, the reference, and the RFCs all regards “as” as a mistake that should not be used, and _many_ features have been introduced over the years to reduce the cases in which “as” is the only alternative.

There are cases in which there is currently no alternative, so people “must” use “as”. This does not imply that it is idiomatic to do so.

Re: Rust 1.45

#213

This rather niche fixing of unsafe behaviour is excellent: https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#fixin... I spent a few years as a scientific programmer and this is exactly the sort of thing that just bites you on the behind in C/C++/Fortran: the undefined behaviour can actually manifest as noise in your output, or just really hard to track down, intermittent problems. A big win to get rid of it.

Agree, a lot of people focus on Rust and memory safety vs C/C++, but the lack (nearly) of undefined behavior is at least as important/helpful.

Undefined behavior is memory safety; at least from Rust POV. A program with UB is not memory safe because the compiler makes no guarantees about the behaviors of those programs.

Re: Rust 1.45

#214

Earlier quoted context omitted.

>= 1.0 in semantic versioning universally means that it should be "stable enough"

I think you're missing the point of contention. > [...] it's not even 1.0 yet. Thus, it isn't stable enough for production use. API stability (i.e. how the API will change in future) is largely unrelated to the question of whether you can trust it to work in production. Maybe for some people API stability is a "must have" for production use, for the sake of minimizing churn when upgrading dependencies, but that's far…

"not even 1.0 [...] isn't stable enough for production use" This reasoning is as many others a probabilistic one but it make sense. Being production ready (technically everything can be with enough churn, and duplicate work production) here means that it is at least decently competitive with others offering regarding productivity, performance and feature completeness, translation: you won't get fired/risk your product by choosing this lib for production use on a medium scale project.

If we agree on the definition, then it generally follow that being productive (e.g ergonomic API), optimised (polishing work), not having rough edges, and having implemented the many required features (a server framework actually require a LOT) all those steps are done AFTER the foundational work of pre 1.0 Those after work will probably sometimes break API stability as we are not omniscient and forward compatibility is non trivial hence the needs for production ready frameworks to have had many breaking change releases so more like 3.x than 1.x Hence, it follows that the temporary but general API stability guarantees from a 1.0 are insufficient and general means that is can begin to be used, not that it should be used.

Rocket and any other rust server framework are not production ready as soon as you go beyond trivial use cases.they have dangerous foundational bugs and show stopper missing features. I have built a startup product with actix web (but studied rocket too) and those are dangerous economic bombs.

Re: Rust 1.45

#215

Earlier quoted context omitted.

I think you're missing the point of contention. > [...] it's not even 1.0 yet. Thus, it isn't stable enough for production use. API stability (i.e. how the API will change in future) is largely unrelated to the question of whether you can trust it to work in production. Maybe for some people API stability is a "must have" for production use, for the sake of minimizing churn when upgrading dependencies, but that's far…

> plenty of libraries with stable APIs that are buggy piles of hacks. E.g. the API: char *gets(char *s); has not changed in probably forty years. Rock stable!

Not A imply not B, does not imply that A imply B.

Re: Rust 1.45

#216
post #163

Earlier quoted context omitted.

They are doing it wrong then.

One could argue that if you are relying on magic number schemas to decide if a library is stable enough for your usecase, it is you that is doing it wrong.

It's no longer magic number once you follow semver https://semver.org Of course it only offer limited information but this information can tell you whether you should be not confident in it. Pre 1.0 is such a signal.

Re: Rust 1.45

#217
post #198
post #29

> Rust 1.45.0 adds the ability to invoke procedural macros in three new places! Rust 1.45 will be the Rocket Release. It unblocks Rocket running on stable as tracked here https://github.com/SergioBenitez/Rocket/issues/19 This is so excellent, and I love seeing long term, multiyear goals get completed. It isn't just this release, but all the releases in between. The Rust team and community is amazing.

For those out of the loop like me, Rocket is a web framework for Rust that apparently was using a lot of experimental features. https://rocket.rs/ Or maybe it's an explosive weapon crafted with metal pipe and gunpowder. https://rust.fandom.com/wiki/Rocket

It's the first, and it's linked in the post :)

Re: Rust 1.45

#218
post #133

Can we please deprecate the "as" operator? Something so lossy and ill-conceived should not be a two-letter operator.

What would you suggest for replacing e.g. `u8 as usize`?

For this one, you could use From/Into, because it cannot fail. For numerics that can fail, TryFrom/TryInto.

The numeric casts are the easy part of this.

Re: Rust 1.45

#219

Earlier quoted context omitted.

I actually find that people who aren't that familiar with programming are pretty quick to accept the idea that aliasing xor mutable is an okay rule... not because it's been exhaustively explained, but just because people have no real expectations at all about how things should work when they're starting out. A lot of language rules seem arbitrary at that point. Afterwards, when using other languages, they may even fi…

From someone who is self taught and learned C as a second language, is teaching rust at this stage a great idea? there is a lot of news about rust lately and it very much seems like people are seeing rust as a hammer and the world as nails.

I don't know. To be honest, having taught a lot of programming stuff, I don't think there is any one best approach to learning programming, and it's very hard to figure out what will be easy or hard for someone just learning. People also learn languages for different reasons--for many people, for example, the main reason they're learning is to get a job in the industry, and if that's the case learning Rust is not really a good idea regardless of any of that stuff, since there aren't that many Rust jobs compared to, say, Python or JavaScript jobs.

Re: Rust 1.45

#220

Earlier quoted context omitted.

The Rust memory model is deviating from it a little in order to enable some norestrict-based optimizations that aren't really done for C, even though (as you know) LLVM can't really take advantage of them yet.

I imagine that in C if the compiler can prove that two pointers don't alias than it can elide a load?

Sure, or with C++ TBAA it can do that too, but those rules work differently from the kinds of guarantees that Rust's type system provides. The C equivalent is (sort of) restrict, but it's used very rarely--so no one has really worked out what its semantics would be like if it were used at the same scale it is in Rust, and there are a lot of bugs.
Post reply on HN