Live data from Hacker News

My Rust experience after eight years

codecs.multimedia.cx

11–20 of 55 posts

Re: My Rust experience after eight years

#11
post #7
post #4

> no dick (or walrus) operator (for me it’s been a good sign that I’m not going to like the language, so far there were no false positives). This means that Go and Nim are out Not sure where they got that Nim has a walrus operator. Maybe because the syntax resembles Python? That'd make sense.

I was not familiar with the term, so I had to look it up. It's about code like this: a := b the `:=` looks vaguely like a walrus. The most common reference language seems to be Python [1]. The usage is for making assignment remain an expression, so you can do stuff like area = (width := get_width()) * (height := get_height()) or something, and have the top-level expression remain valid since the sub-expressions are a…

Its also one of the more controversial features and its introduction sparked Guido's stepping down.

Since it was introduced, I have been looking but there has been only a handful of times where I could use it to write clearer code.

I'm curious if anyone actually likes it.

edit: A quick search shows that I do use it regularly in while loops, e.g.:

  while result := my_fun():
    ...

Re: My Rust experience after eight years

#12
post #7
post #4

> no dick (or walrus) operator (for me it’s been a good sign that I’m not going to like the language, so far there were no false positives). This means that Go and Nim are out Not sure where they got that Nim has a walrus operator. Maybe because the syntax resembles Python? That'd make sense.

I was not familiar with the term, so I had to look it up. It's about code like this: a := b the `:=` looks vaguely like a walrus. The most common reference language seems to be Python [1]. The usage is for making assignment remain an expression, so you can do stuff like area = (width := get_width()) * (height := get_height()) or something, and have the top-level expression remain valid since the sub-expressions are a…

python's use is the unusual one; the most common use (dating all the way back to algol) is to use it for assignment, so you can use = for equality.

https://en.wikipedia.org/wiki/Assignment_(computer_science)#...

Re: My Rust experience after eight years

#13

"Of course you can argue that Rust recently adopted language specification, but if you take a second to learn more about it you’ll find out that it comes essentially from outside." It is worth noting that the Ferrocene specification is made for the certification of the Ferrocene compiler as its sole purpose. It is neither intended nor suitable to implement a compiler based on it.

I'm not familiar at all with the Ferrocene specification, but in general I do wonder if the ISO C/C++/Fortran (singling these out as I'm somewhat familiar with them, not saying there aren't other languages with similar spec processes) process of a prose spec is really the best way to go in this day and age? Those languages certainly have their historical reasons for the specs being the way they are, but I'm not convinced it's the only right way of doing a spec if starting from scratch today.

Say, what about something like a formal machine-parsable spec and/or a testsuite that describes the way the language should behave, rather than a prose description that then each compiler writer interprets to the best of their ability?

Re: My Rust experience after eight years

#14

For me lack of language specification is not a problem and it is good that Rust only have one implementation so I don't have a headache to support multiple compilers like C++. The only problems I have with trait is lack of const function and trait upcasting, which just solved by 1.86 that released yesterday. For iterator type mismatched it does not cause much problem since I can create a dedicated generic function to…

Open source implementation > open standard every time.

C++ is from an era open source was not yet well established.

Re: My Rust experience after eight years

#15
post #11
post #7

Earlier quoted context omitted.

I was not familiar with the term, so I had to look it up. It's about code like this: a := b the `:=` looks vaguely like a walrus. The most common reference language seems to be Python [1]. The usage is for making assignment remain an expression, so you can do stuff like area = (width := get_width()) * (height := get_height()) or something, and have the top-level expression remain valid since the sub-expressions are a…

Its also one of the more controversial features and its introduction sparked Guido's stepping down. Since it was introduced, I have been looking but there has been only a handful of times where I could use it to write clearer code. I'm curious if anyone actually likes it. edit: A quick search shows that I do use it regularly in while loops, e.g.: while result := my_fun(): ...

I have written Python since 2003 and used walrus only once. It's unnecessary.

Re: My Rust experience after eight years

#16
post #7
post #4

> no dick (or walrus) operator (for me it’s been a good sign that I’m not going to like the language, so far there were no false positives). This means that Go and Nim are out Not sure where they got that Nim has a walrus operator. Maybe because the syntax resembles Python? That'd make sense.

I was not familiar with the term, so I had to look it up. It's about code like this: a := b the `:=` looks vaguely like a walrus. The most common reference language seems to be Python [1]. The usage is for making assignment remain an expression, so you can do stuff like area = (width := get_width()) * (height := get_height()) or something, and have the top-level expression remain valid since the sub-expressions are a…

In math = is used for equality and := for definition[1] which is probably the closest thing to assignment in a programming language. That is why Pascal and similar languages use = for equality only and := for assignment.

That always made more sense to me than = for assignment and more =s for different kinds of equality, but in the end this syntax discussions are always just bike-shedding.

Re: My Rust experience after eight years

#18

For me lack of language specification is not a problem and it is good that Rust only have one implementation so I don't have a headache to support multiple compilers like C++. The only problems I have with trait is lack of const function and trait upcasting, which just solved by 1.86 that released yesterday. For iterator type mismatched it does not cause much problem since I can create a dedicated generic function to…

You can use the parking_lot mutex implementation crate, which includes support for deadlock detection. Personally, I also try to avoid using Tokio's async mutexes.

Re: My Rust experience after eight years

#20

For me lack of language specification is not a problem and it is good that Rust only have one implementation so I don't have a headache to support multiple compilers like C++. The only problems I have with trait is lack of const function and trait upcasting, which just solved by 1.86 that released yesterday. For iterator type mismatched it does not cause much problem since I can create a dedicated generic function to…

Sharing resources is always a source of deadlocks and bugs, I don’t see a feasible resolution to that in a programming language. I don’t think one gets into deadlocks more often than any other language with Rust, but you are not experiencing most other concurrency bugs, which makes it feel like deadlocks are a bigger issue.
Post reply on HN