logoalt Hacker News

baranultoday at 12:32 PM2 repliesview on HN

True, defaults matter. In many cases, however, using a language that defaults to a GC for memory safety is often preferable or easier.

The argument is often about when ownership and borrowing is truly necessary. Rust has its uses, but arguably not all the time and with everything, because of its defaults.


Replies

kibwentoday at 1:41 PM

I'm going to thoughtfully disagree here. The more I use Rust, the more I feel like we got it wrong all the way back in the mists of ALGOL, and that copy-by-default (which, in (non-immutable) managed languages, translates to multi-ownership-by-default) was a mistake in the same league as null. Being able to convincingly express resource consumption in a first-class way is just too broadly useful, IMO. Certainly we can imagine a "high-level Rust" that doesn't make you care so much about pointers and the stack/heap distinction, but I still think such a language would want to make single-ownership the default. To that end, rather than any of the aforementioned languages, I'll suggest Austral as looking fairly interesting, although it's still far from high-level: https://austral-lang.org/

simonasktoday at 2:03 PM

I’m writing some C# code at the moment, and the fact that `ObjectDisposedException` exists should give you a clue that “consume” semantics are desirable in all languages.

It opens up entirely new avenues for statically error-free programming, letting you model things like “if the caller has an instance of this type, I can guarantee that this other larger proposition is true”. Namely without also having to handle the case where the user smuggled another instance from another call site.

This is really, really useful.