4 ms·
> Notably, no language will ever be able to catch pure logic errors by itself. It's true you'll never be able to catch all logic errors automatically, partly b
by roca 5y ago
> Notably, no language will ever be able to catch pure logic errors by itself.
It's true you'll never be able to catch all logic errors automatically, partly because you need full correctness specifications for that.
But languages like Rust with powerful static type systems can catch lots more important logic errors than C, or C++ --- e.g. using typestate (catches bugs with operations on values in incorrect states), affine types (catches bugs with operations on "dead" values), newtypes (e.g. lets you distinguish sanitized vs unsanitized strings), sum types (avoids bugs where "magic values" (e.g. errors) are treated as "normal values").
Also modern languages like Swift, and Rust to a lesser extent, are treating integer overflow as an error instead of just allowing it (or worse, treating it as UB).
- andrekandre 5y agotypestates are great, but in rust i wonder if it would be more ergonomic and easier to get right if it was officially a feature instead of a pattern you have to implement...?
- steveklabnik 5y agoAmazingly, typestates used to be a headline feature of Rust, in the very, very, very old days. Like, "Wow, Rust is the language that's going to make typestates mainstream!" was a thing people thought when seeing it. Eventually it was removed. https://pcwalton.github.io/2012/12/26/typestate-is-dead.html https://pcwalton.github.io/2012/12/26/typestate-is-dead.html
- andrekandre 5y ago> The reason was that “in practice, it found little use” thats a real shame...