Live data from Hacker News

My Rust experience after eight years

codecs.multimedia.cx

51–55 of 55 posts

Re: My Rust experience after eight years

#51
post #47

> Even more annoying is that I have to duplicate the iterator code: as I often work with frames that may be flipped bottom-up I want to write code like > > let mut iterator = if !flipped { > data.chunks_mut(stride) > } else { > data.chunks_mut(stride).rev() > }; > for line in iterator { ... } > > but I can’t since objects have different type (and probably size) and there’s no realistic way to coerce them to the same…

Another approach:

  let mut iterator = data.chunks_mut(stride);
  while let Some(line) = if !flipped { iterator.next() } else { iterator.next_back() } {
      …
  }
I sometimes wonder idly if the language would have been better off without a `for` loop (if `while let` had happened much earlier). `while let` is more verbose, mainly because iterator construction has to be an explicit separate line, but it’s also more amenable to alteration to make it more fit for purpose. (You can go down to `loop` and `break`, but I think this sacrifices too much in ergonomics and comprehensibility in the usual case. As `while let` also compromises, but I wonder if it’s closer to the sweet spot than commonly imagined, and `for` doesn’t actually get you so much.)

Re: My Rust experience after eight years

#52

> My criteria were subjective but simple to understand: the language should introduce new concepts (as Principia Discordia puts it, ’tis an ill wind that blows no minds) [...] I wonder how many people share this opinion. I derive as much if not more value from the refinement of existing concepts than the introduction of new ones. Wanting new concepts just for it's own sake is wild to me.

People are rarely willing to adopt 10% improvements. Every improvement, no matter how small, needs to be taught to the larger community of users and other stakeholders; it is relatively rare for you to be the sole stakeholder, and thus the cost of adopting the improvement is rarely worth the improvement itself, endangering making improvements. Only 10x-style improvements have a good chance of widescale adoption. Thinking that you can short-circuit this by passing 10% improvements in widely adopted languages is the mark of someone who never tried to get language features like the "var" keyword adopted in multi-million-line Java codebases.

Re: My Rust experience after eight years

#53
post #25

Earlier quoted context omitted.

You can not really write a formal spec without having prose first. It would be nice to have a formal spec for C, and C is one of the languages where this is feasible (and also partially done by various people).

> You can not really write a formal spec without having prose first. The WebAssembly folks might have done that? From the Wasm SpecTec blog post I linked in a sister comment (emphasis in original): > In fact, the formal version [of the Wasm spec] was written long before the prose, which was then created by manually transliterating the formal rules into natural language (for some definition of “natural”). To be fair,…

It is also clear that you can write a formal spec down before writing down prose, if your language is simple and low-level enough.

Re: My Rust experience after eight years

#54
post #46

Earlier quoted context omitted.

Those "evangelists" would be wrong, then. Rust prevents data races by default, but doesn't prevent deadlocks by default. It is possible to use Rust's type system to statically ensure the lack of deadlocks [0], but that's not provided by default. [0]: e.g., https://docs.rs/lock_ordering/latest/lock_ordering

I should have bookmarked the HN post that said it :) It was one of the usual "if you'd have rewritten it in rust you'd have had no problems" posts. But instead of the usual memory safety list, they also added no deadlocks to the benefits.

Hey now Rust is also garbage collected:

https://news.ycombinator.com/item?id=43555249#43592602

I wonder what they'll add to it by tomorrow...

Re: My Rust experience after eight years

#55
post #54
post #46

Earlier quoted context omitted.

I should have bookmarked the HN post that said it :) It was one of the usual "if you'd have rewritten it in rust you'd have had no problems" posts. But instead of the usual memory safety list, they also added no deadlocks to the benefits.

Hey now Rust is also garbage collected: https://news.ycombinator.com/item?id=43555249#43592602 I wonder what they'll add to it by tomorrow...

I think that's more a case of unnecessary pedantry. Rust "has garbage collection" in that you can opt in to the lifetime of some objects being handled by some kind of garbage collection. Rust doesn't "have garbage collection" in that Rust does not require a GC'd runtime to implement its semantics in a memory-safe manner. Two different concepts with similar terminology.

Edit: Also looking at that commenter's history I am rather skeptical they would reasonably be considered a "Rust evangelist"

Post reply on HN