Live data from Hacker News

Garbage collection for Rust: The finalizer frontier

soft-dev.org

51–60 of 184 posts

Re: Garbage collection for Rust: The finalizer frontier

#51
post #40

Earlier quoted context omitted.

it depends completely on what you put in "modern features"

Pattern matching, usable abstractions, non null types, tagged unions or w/e enums are, build tools etc

I'm not sure what you mean by "usable abstractions" and tagged unions are a little verbose because they are defined in terms of closed sets of subtypes, but otherwise Dart has all of those.

Re: Garbage collection for Rust: The finalizer frontier

#52
post #5

Before making criticisms that Garbage Collection "defeats the point" of Rust, it's important to consider that Rust has many other strengths: - Rust has no overhead from a "framework" - Rust programs start up quickly - The rust ecosystem makes it very easy to compile a command-line tool without lots of fluff - The strict nature of the language helps guide the programmer to write bug-free code. In short: There's a lot…

Also assuming one can mix garbage collection with the borrower (is that what its called in rust?) one should be able to use GC for things that arent called that much / that important and use the normal way for things that benefit from no GC interupts etc

Re: Garbage collection for Rust: The finalizer frontier

#53
post #40

Earlier quoted context omitted.

Pattern matching, usable abstractions, non null types, tagged unions or w/e enums are, build tools etc

I'm not sure what you mean by "usable abstractions" and tagged unions are a little verbose because they are defined in terms of closed sets of subtypes, but otherwise Dart has all of those.

Nothing like "oh you can do that but with this weird work around" or if they're clunky to use

Re: Garbage collection for Rust: The finalizer frontier

#54
post #18

Earlier quoted context omitted.

You've just listed "Compiled language" features. Only the 4th point has any specificity to Rust, and even then, is vague in a way that could be misinterpreted. Rust's predominant feature, the one that brings most of its safety and runtime guarantees, is borrow checking. There are things I love about Rust besides that, but the safety from borrow checking (and everything the borrow checker makes me do) is why I like pr…

What other language has modern features like rust and is compiled?

nim, zig and ocaml come to mind

Re: Garbage collection for Rust: The finalizer frontier

#55
post #33
post #5

Before making criticisms that Garbage Collection "defeats the point" of Rust, it's important to consider that Rust has many other strengths: - Rust has no overhead from a "framework" - Rust programs start up quickly - The rust ecosystem makes it very easy to compile a command-line tool without lots of fluff - The strict nature of the language helps guide the programmer to write bug-free code. In short: There's a lot…

In all honesty, there are three topics I try to refrain myself from engaging with on HN, often unsuccesfully: politics, religion, and rust. I don't know what you had to go through before reaching rust's secure haven, but what you just said is true for the vast majority of compiled languages, which are legions.

> politics, religion, and rust

Is there a real distinction between any of those?

Re: Garbage collection for Rust: The finalizer frontier

#56
post #20
post #15

Earlier quoted context omitted.

Just going to jump in here and say that there's another reason I might want Rust with a Garbage Collector: The language/type-system/LSP is really nice to work with. There have indeed been times that I really miss having enums + traits, but DON'T miss the borrow checker.

Maybe try a different ML-influenced language like OCaml or Scala. The main innovation of Rust is bringing a nice ML-style type system to a more low level language.

There are other nice things about Rust over OCaml that are mainly just due to its popularity. There are libraries for everything, the ecosystem is polished, you can find answers to any question easily, etc. I don't think the same can be said for OCaml, or at least not to the same extent. It's still a fairly niche language compared to Rust.

Re: Garbage collection for Rust: The finalizer frontier

#57

Earlier quoted context omitted.

One clear use case for GC in Rust is for implementing other languages (eg writing a JS engine). When people ask why SpiderMonkey hasn't been rewritten in Rust, one of the main technical blockers I generally bring up is that safe, ergonomic, performant GC in Rust still appears to be a major research project. ("It would be a whole lot of work" is another, less technical problem.) For a variety of reasons I don't think…

Would you plug Boehm GC into a first class JS engine? No? Then you're not using this to implement JS in anything approaching a reasonable manner either.

It looks like the API of Alloy was at least designed in such a way that can somewhat easily change the GC implementation out down the line and I really hope they do cause Boehm GC and conservative GC in general is much too slow compared to state of the art precise GCs.

Re: Garbage collection for Rust: The finalizer frontier

#58

The whole point of Rust is to not have a garbage collector while not worrying about memory leaks, though.

Not really, modern C++ already makes it about as hard to leak memory as it is in Rust.

Rust has loads of other advantages over C++, though.

Re: Garbage collection for Rust: The finalizer frontier

#59

The whole point of Rust is to not have a garbage collector while not worrying about memory leaks, though.

Worth highlighting: library-level GC would not be convenient enough to use pervasively in Rust anyway . library-level GC does not replace Rust's "point". It's useful to have when you have complex graph structures. Or when implementing language runtimes. I've written a bit about these types of use cases in https://manishearth.github.io/blog/2021/04/05/a-tour-of-safe... And there's a huge benefit in being able to narro…

This is a very important point, careful use of GCs for a special subset of allocations that say have tricky lifetimes for some reason and aren't performance critical could have a much smaller impact on overall application performance than people might otherwise expect.

Re: Garbage collection for Rust: The finalizer frontier

#60

Earlier quoted context omitted.

Would you plug Boehm GC into a first class JS engine? No? Then you're not using this to implement JS in anything approaching a reasonable manner either.

It looks like the API of Alloy was at least designed in such a way that can somewhat easily change the GC implementation out down the line and I really hope they do cause Boehm GC and conservative GC in general is much too slow compared to state of the art precise GCs.

It's not an implementation thing. It's fundamental. A GC can't move anything it finds in a conservative root. You can build partly precise hybrid GCs (I've built a few) but the mere possibility of conservative roots complicates implementation and limits compaction potential.

If, OTOH, Alloy is handle based, then maybe there's hope. Still a weird choice to use Rust this way.

Post reply on HN