Live data from Hacker News

Rust 1.46

blog.rust-lang.org

31–40 of 157 posts

Re: Rust 1.46

#31

Awesome! Any idea when relative links will be available in rustdoc? Seems like it's just on the edge of stabilizing ( https://github.com/rust-lang/rust/pull/74430 ) but I'm curious how long it takes to see in a release after this happens.

There can be fuzziness here depending on exactly when it lands, but generally, if something lands in nightly, it'll be in stable two releases after the current stable.

Re: Rust 1.46

#32
post #17
post #7

Earlier quoted context omitted.

Never worked with Rust, but I am pretty sure that having a function be pure is not enough to evaluate it at compile time.

Why not? By definition the output does not depend on runtime property so you should be able to compute it at compile time right?

Pure functions are functions where the return value only depends on the function arguments. If the function arguments are not known at compile time, obviously you can't evaluate it at compile time. It would only be possible to do that when all the arguments are also known at compile time (constants).

Re: Rust 1.46

#33

If anyone wants to know more about const fns, see https://doc.rust-lang.org/reference/items/functions.html#con... It is the Rust way of specifying a function as being _pure_. In other words the output is dependent only on the function arguments, and not on any external state. This means they can be evaluated at compile time. I suppose in the future, it could also allow better compiler optimizations.

Rust has no notion of purity. This would require something like an effect system.

const functions can't directly do any IO or even allocation - at the moment.

But this can be easily circumvented, eg by using a proc macro that does IO.

Sidenote: even in Haskell the function signature doesn't guarantee purity, due to unsafePerformIO.

Re: Rust 1.46

#34
post #6

I’m learning rust right now and there is a lot to like. Steady updates like this are also very motivating. The ecosystem feels very sane - especially compared to npm. Top notch Wasm support, cross compiling is a breeze. That said, coming from a FP background (mostly Haskell/JS, now TS) Rust is... hard. I do understand the basic rules of the borrow checker, I do conceptually understand lifetimes, but actually using th…

This echoes my experience with learning Rust over the past few weeks (coming from Elixir).

There is a lot to like, understand lifetimes conceptually, but it's hard.

Re: Rust 1.46

#35
post #6

I’m learning rust right now and there is a lot to like. Steady updates like this are also very motivating. The ecosystem feels very sane - especially compared to npm. Top notch Wasm support, cross compiling is a breeze. That said, coming from a FP background (mostly Haskell/JS, now TS) Rust is... hard. I do understand the basic rules of the borrow checker, I do conceptually understand lifetimes, but actually using th…

>the borrow checker, I do conceptually understand lifetimes, but actually using them is tricky.

I've been using Rust for a little over year, almost daily at work, and for several projects. I have a pretty good intuition about how the borrow checker works and what needs to be done to appease it. That said, I don't think I'm any closer to understanding lifetimes. I know conceptually how they are supposed to work (I need the reference to X to last as long as Y), but anytime I think I have a situation that could be made better with lifetimes, I can't seem to get the compiler to understand what I'm trying to do. On top of that very little of my code, and the code I read actually uses lifetimes.

Re: Rust 1.46

#36
`const fn` improvements are amazing!

I can't wait for when we'll be able to `const fn` all the things. Regex, expensive constants that feel as though they should be literals, etc.

Re: Rust 1.46

#37

If anyone wants to know more about const fns, see https://doc.rust-lang.org/reference/items/functions.html#con... It is the Rust way of specifying a function as being _pure_. In other words the output is dependent only on the function arguments, and not on any external state. This means they can be evaluated at compile time. I suppose in the future, it could also allow better compiler optimizations.

An interesting history note: Rust used to have an effects system which included actually being able to annotate a function as pure.

Re: Rust 1.46

#38

So, I want to learn Rust. I am a C# / Python programmer, experienced. Are there any particular set of problems that I can solve systematically, so that I can learn all the features of Rust?

Try to do some graphics programing with thr backend of your choice. There is also this cool nanovg port https://github.com/cytecbg/gpucanvas. Run the demo in examples to see the nanovg demo.

Re: Rust 1.46

#39
post #20
post #2

The most exciting component of this release is the const fn improvements. With loops and if available, you can now do non-trivial computation in const fn for the first time. It reduces the gap between Rust's const fn and C++'s constexpr to a large degree. Ultimately, the miri execution engine that this feature builds upon, supports a much larger set of features that even constexpr supports. It's been a project spanni…

> supports a much larger set of features that even constexpr supports This sounds promising. Can you give examples? I don't know Rust at all, and the reason I like C++ is its metaprogrammability.

I believe in a talk[1] it was mentioned that Rust's const eval will support heap-allocated values (accessed as references). A quick search suggests that C++20 will also support this, although it may be safer in Rust as it can give a stronger guarantee that the static memory won't be written to.

[1]https://youtu.be/wkXNm_qo8aY?t=888

Re: Rust 1.46

#40
post #20
post #2

The most exciting component of this release is the const fn improvements. With loops and if available, you can now do non-trivial computation in const fn for the first time. It reduces the gap between Rust's const fn and C++'s constexpr to a large degree. Ultimately, the miri execution engine that this feature builds upon, supports a much larger set of features that even constexpr supports. It's been a project spanni…

> supports a much larger set of features that even constexpr supports This sounds promising. Can you give examples? I don't know Rust at all, and the reason I like C++ is its metaprogrammability.

Basically, the interpreter interpret's rustc's internal IR, so it can theoretically support the entire language. That's not a good idea for various reasons, though, so its capabilities are effectively on an allowlist, that we expand over time as we're sure we want to enable a given feature.
Post reply on HN