Comment

Comment by serbuvlad

> Any new language that works with the dev on writing correct code or outright refuses to compile with incorrect code (hinting at Rust here)

I've started writing Rust in the past year and... honestly... I LOVE it.

But what kept me away from Rust for a long time is this talking point of rejecting incorrect code which is so obviously wrong it made proponents of Rust sound very cultish to me.

Rust cannot prevent incorrect code, nor is this possible (halting problem).

What Rust can do is enforce a very specific type of correctness, which may be termed resource-use-correctness. Basically it can enforce that every resource that is used, is properly opened, is properly accessed, has (one writer) OR (multiple readers and no writer) at a time, and is properly closed. It can do this for memory, files, sockets, as well as arbitrary constructs of your choice.

This ability is extremely valuable!

But it is also quite easy to write incorrect buggy programs in Rust, for the very simple reason that it is very easy to write incorrect buggy programs that do not misuse their resources.

parent serbuvlad 2 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton