Live data from Hacker News

Four years with Rust

words.steveklabnik.com

81–90 of 199 posts

Re: Four years with Rust

#81
post #47
post #4

For those of us who are getting to the party 3 years late, thank you. Just my 2p for others learning: for me, Rc::RefCell was what I was missing, even after I thought I was up to speed. I was fine using Channels for inter-thread communication and I never needed Arc, but use of Rc is common in the Rust ecosystem and a lot of my early fights with the borrow checker weren't fights I needed to have. In situations where i…

Reference counting can be a useful memory management technique. But reference counting may cause unpredictable pauses when large amounts of objects suddenly need to be freed (e.g. when dropping the last reference to a large array holding many references). At least a carefully written garbage collector can free objects incrementally, and concurrently. So memory management in Rust is certainly not a solved problem. EDI…

>Reference counting can be a useful memory management technique. But reference counting may cause unpredictable pauses when large amounts of objects suddenly need to be freed (e.g. when dropping the last reference to a large array holding many references).

How is it compared to other forms of GC?

Re: Four years with Rust

#82
What would be interesting if it would be possible to develop with GC on, but then if you benchmark and notice that it's too slow, turn on manual garbage collection for specific pointers.

I don't know if it's possible, though (considering libraries).

Re: Four years with Rust

#84
post #13

Earlier quoted context omitted.

> Just my 2p for others learning: for me, Rc::RefCell was what I was missing, even after I thought I was up to speed. I started (and then stopped) learning Rust a few months ago (before their docs rewrite) and the borrow checker and concepts weren't explain in a way that I could understand. Programs wouldn't work at all, and when I read about Rc::RefCell I was scared because I wasn't sure how much garbage collection…

> I wasn't sure how much garbage collection rust would do Rust doesn't do magical garbage collection. Rc does reference counting, which is a form of garbage collection, but you get to choose where it gets applied, so it's a linear cost with no magical GC pauses or whatever. Rc isn't unique to Rust, it exists in C++ too. RefCell makes mutation within an Rc safe. It panics if you misuse it. http://manishearth.github.io…

Reference counting is not a form of garbage collection. Both reference counting and garbage collection are types of automatic memory management.

Re: Four years with Rust

#85
post #72

Earlier quoted context omitted.

Is it ? According to [1] it should be available in 1.14, which is the current beta. [1]: https://internals.rust-lang.org/t/all-the-rust-features/4322

Must have been a bug, it landed in 1.13. I just tried it myself to triple check https://blog.rust-lang.org/2016/11/10/Rust-1.13.html (1.14 is tomorrow, so even if that was true, I'm off by a day.)

Good to know that this list must not be taken as Gospel. Thanks.

Re: Four years with Rust

#86
post #62

Earlier quoted context omitted.

Dream time, Microsoft gets to sponsor Rust on their stack and VS integration, and we can move on from C# + C++/CX to C# + Rust. :)

Have you tried VSCode with the Rust(racer,rustfmt) + lldb integration? I've been pretty impressed with it so far. FWIW C# Rust integration is really straightforward. You can actually pass delegates as C fn pointers and then treat them as a closures in Rust. Much less painful that I initially thought.

It is not yet the same as Blend + Visual Studio (C#, F#, C++/CX, C++/CLI).

Yes, I do use VSCode, but only for dabbling on Rust during plane/train travels. The language is not yet at a level it just fits on MS stack and is requested by our customers on their Requests For Proposals.

Regarding C# Rust interoperability, it is very badly documented. I gave up on searching for it, and just used C# C++/CX Rust instead.

Or I am very bad searching for it.

Re: Four years with Rust

#87

Getting rid of the syntactic difference between moving and copying seems like a huge step backwards. Ditto with abandoning mailing lists for some wanky "already solved-as-a-service" web app.

> Getting rid of the syntactic difference between moving and copying seems like a huge step backwards.

Did you ever use Rust back when you had to write "move"? I did. When you wrote stuff like:

    let (move x, move y) = (move z.a, (move z.b).append(move z.c));
It got old fast.

Re: Four years with Rust

#88
post #41

Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assign. The borrow checker will catch a reuse of something already moved away. This turns out to be effective enough in practice that the syntax distinction isn't necessary. That wasn't obvious up front. Not having exceptions tends to generate workarounds which are ug…

> There's still too much that has to be done with unsafe code. But the unsafe situations are starting to form patterns.

I think as long as those patterns can be abstracted out and moved into thoroughly-vetted libraries with a safe interface, unsafe code isn't really a problem. I expect that getting Rust's standard libraries to a place where regular applications very rarely need to create their own unsafe code blocks is going to be a major long-term effort.

(Of course, if there were some simple language feature that would make some common use case of unsafe code blocks unnecessary, by all means we should do that as well.)

Re: Four years with Rust

#89
post #79
post #58

Earlier quoted context omitted.

> Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assign. The borrow checker will catch a reuse of something already moved away. This turns out to be effective enough in practice that the syntax distinction isn't necessary. That wasn't obvious up front. Could you say a bit more about what you mean by "now"? You wri…

Never read "smallcultfollowing" before. The "implicitly copyable" problem is amusing. That was dealt with by Wirth in Modula 1 with the rule "if the programmer can't tell, it's up to the compiler". Thus, non-writable objects could be passed either by reference or by copy, depending on object size. This was up to the compiler. The usual rule was that anything up to 2 words in size was copied. Since the called function…

We tried making copy/move an optimization. The number of useless copies that ended up in the resulting code was absurd. You think compile times are bad now…

Re: Four years with Rust

#90
post #41

Rust as a language is now realizing the benefits of borrow checking. As the article points out, the syntax doesn't have to distinguish between move and assign. The borrow checker will catch a reuse of something already moved away. This turns out to be effective enough in practice that the syntax distinction isn't necessary. That wasn't obvious up front. Not having exceptions tends to generate workarounds which are ug…

[deleted]
Post reply on HN