Live data from Hacker News

Announcing Rust 1.20

blog.rust-lang.org

31–40 of 277 posts

Re: Announcing Rust 1.20

#31
post #27

Is f32 the only suffix for float literals? That seems really noisy compared to just f in C. I'm mostly concerned about vector and matrix declarations, but even in the examples given, 1.0f32 / 0.0f32 looks like a mess of numbers compared to 1.f / 0.f;

> Is f32 the only suffix for float literals? Nope. `f32` is for single-precision floats, and `f64` is for double-precision floats. There have been some people lobbying for `f16` and `f128` as well. Also, you don't need to use those suffixes. I imagine the OP is using them for maximum explicitness, but you can just write `1.0` and it will be inferred to a floating-point type as necessary (contrast `1`, which will be i…

> I imagine the OP is using them for maximum explicitness

I used them because that's the style that was used inside of std::f32;

  const INFINITY: f32 = 1.0 / 0.0;
totally works.

Re: Announcing Rust 1.20

#32

Is f32 the only suffix for float literals? That seems really noisy compared to just f in C. I'm mostly concerned about vector and matrix declarations, but even in the examples given, 1.0f32 / 0.0f32 looks like a mess of numbers compared to 1.f / 0.f;

_f32 is https://doc.rust-lang.org/std/primitive.f32.html _f64 is https://doc.rust-lang.org/std/primitive.f64.html

Re: Announcing Rust 1.20

#33
post #27

Is f32 the only suffix for float literals? That seems really noisy compared to just f in C. I'm mostly concerned about vector and matrix declarations, but even in the examples given, 1.0f32 / 0.0f32 looks like a mess of numbers compared to 1.f / 0.f;

> Is f32 the only suffix for float literals? Nope. `f32` is for single-precision floats, and `f64` is for double-precision floats. There have been some people lobbying for `f16` and `f128` as well. Also, you don't need to use those suffixes. I imagine the OP is using them for maximum explicitness, but you can just write `1.0` and it will be inferred to a floating-point type as necessary (contrast `1`, which will be i…

GLSL programmers may rejoice in learning that `1.` is accepted syntax too.

Re: Announcing Rust 1.20

#34

Earlier quoted context omitted.

What's funny about this is that I had worded it even less clearly, and it was changed due to feedback: https://github.com/rust-lang/blog.rust-lang.org/pull/192#dis... Guess I didn't go far enough :)

Maybe "In previous Rust versions you could already define traits, ..."?

Sounds great, thank you! https://github.com/rust-lang/blog.rust-lang.org/commit/e74c5...

Re: Announcing Rust 1.20

#35
post #23

Earlier quoted context omitted.

I, at least, don't really think of Rust as having classes. Rusty design patterns don't really look like many traditional OOP design patterns. This is often a hurdle for new Rust programmers. Chapter 17 of the book ( https://doc.rust-lang.org/book/second-edition/ch17-00-oop.ht... ) is trying to grapple with this question. Part of the difficulty here is nailing down what "class" even means, exactly. Rust doesn't fit in…

Obviously Rust is in the 4'th school which I like to call "The Rust School". All kidding aside, I think for any regular working day programmer Rust is obviously OOP. The debates are really just which parts of which favorite school of OOP you think Rust is inspired by. But what really matters is that Rust gives you: * Encapsulation * Polymorphism. * And Code Reuse. Which are the only three things anyone who reaches fo…

I agree that it's better to focus on encapsulation/polymorphism/reuse, but the reason why I personally object to the idea that "for any regular working day programmer Rust is obviously OOP" is because inheritance is usually taught above all of these as the fundamental property of OOP.

I doubt I'm the only one whose high school and college exposure to OOP was to model "Dog is-a Mammal, Cow is-a Mammal, Mammal is-a Animal", and if a newcomer to Rust tries to do the same as their "hello world" then they're going to be greatly frustrated. Again, this isn't to say that the phrase "Rust is OOP" is necessarily incorrect, only that it's going to backfire if we going around shouting it, due to misaligned expectations.

Re: Announcing Rust 1.20

#36
post #3

Interestingly, because Firefox chooses to use stable Rust exclusively, this is the version of Rust that will be used to deliver Quantum when Firefox 57 releases on November 14 (by which time Rust 1.21 will be out (releasing October 12), but Firefox 57 will be in beta by September 20).

To save others from searching, Quantum[1] is the new engine for Firefox replacing(/building upon) gecko.

[1] https://wiki.mozilla.org/Quantum

Re: Announcing Rust 1.20

#37
post #29

Associated functions and associated constants sound so yum! That's one thing I would love to have in Flowtype. But classes seem to serve that use case well enough.

> Associated functions and associated constants sound so yum!

In the simple (not trait) case they just seem to be the same as "public static" constants and functions in C#, java etc.

Re: Announcing Rust 1.20

#38
In case anyone else runs into this, I was getting this error trying to update from 1.19:

    $ rustup update stable
    info: syncing channel updates for 'stable-x86_64-apple-darwin'
    error: missing key: 'url'
After I updated rustup from 1.0.0 to 1.6.0 with rustup self update, it worked.

Re: Announcing Rust 1.20

#39
post #35
post #23

Earlier quoted context omitted.

Obviously Rust is in the 4'th school which I like to call "The Rust School". All kidding aside, I think for any regular working day programmer Rust is obviously OOP. The debates are really just which parts of which favorite school of OOP you think Rust is inspired by. But what really matters is that Rust gives you: * Encapsulation * Polymorphism. * And Code Reuse. Which are the only three things anyone who reaches fo…

I agree that it's better to focus on encapsulation/polymorphism/reuse, but the reason why I personally object to the idea that "for any regular working day programmer Rust is obviously OOP" is because inheritance is usually taught above all of these as the fundamental property of OOP. I doubt I'm the only one whose high school and college exposure to OOP was to model "Dog is-a Mammal, Cow is-a Mammal, Mammal is-a Ani…

Is-A does not and should not imply Inheritance. It merely implies polymorphism. I didn't get formally trained so I can't comment on what college/high school's teach but if they teach that Is-A relationships imply Inheritance then claiming Rust is OOP seems like a good way to educate the mis-educated regarding the difference.

Re: Announcing Rust 1.20

#40
post #2

"Associated functions" = class methods "Associated constants" = limited version of class variables Rust keeps approaching C++'s feature set.. I am amazed that the above wasn't in Rust to begin with, though. Can't think of any other languages which has classes but no class methods/variables.

> Rust keeps approaching C++'s feature set..

If there's one thing we C++ programmers can agree on, it's that having tons of features makes C++ a pleasure to work with... ?

Post reply on HN