Live data from Hacker News

A half-hour to learn Rust

fasterthanli.me

151–160 of 342 posts

Re: A half-hour to learn Rust

#153
post #70

Earlier quoted context omitted.

I should have said :) I am writing backtracking algorithms (think something like a Sudoku solver where we fill in values by guessing), and an 'Error' is when we can deduce the Sudoku cannot be filled in, so we have to backtrack. I find Rust's ? notation gives a very natural way of writing such algorithms. I don't care "why" filling in the Sudoku failed, particularly because the solver will typically fail millions of…

I would suggest Option is the more semantic type to use for your situation - None indicating no valid solution on this path

Oh, today I learned the ? operator works with Option as well as Result! I might try that out, thanks.

Re: A half-hour to learn Rust

#154

So Rust is Scala but with some extra complicated additional syntax around borrowing references and generic lifetime constraints.

Scala has many features Rust does not have as well.

Yeah, when reading this I was wondering if Rust has sealed traits like Scala, and also structural typing.

The extreme degree of shared syntax and shared semantics with Scala was really surprising to me.

Re: A half-hour to learn Rust

#156

Earlier quoted context omitted.

Scala has many features Rust does not have as well.

Yeah, when reading this I was wondering if Rust has sealed traits like Scala, and also structural typing. The extreme degree of shared syntax and shared semantics with Scala was really surprising to me.

Rust does not have sealed traits, though you can sorta contort the privacy system to do similar things if you want. We also do not have structural typing. (Generally; tuples are structurally typed but nothing else is)

A lot of Rust’s language people did a lot in Scala. The language’s are pretty different IMHO.

Re: A half-hour to learn Rust

#158

let x; foobar(x); // error: borrow of possibly-uninitialized variable: `x` x = 42; possibly-uninitialized - Why does the compiler sound uncertain while emitting an error?

The analysis is not perfect. It’s worded that way to acknowledge this fact.

It also is language that works well when something may be initialized in some control flow paths but not all.

Re: A half-hour to learn Rust

#159
post #15

That is the best article on Rust I've ever seen. Better than the Rust book. I've been saying that Rust needed a book that wasn't written by the designers of the language, who are too close to it. Now we have one.

Out of curiosity, what don't you like about the Rust book? I personally loved it, reading about a year and a half ago. I thought they covered most of what I needed, was well written, and had plenty of good examples.
Post reply on HN