Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Of course. I can buy for example that it's hard enough to learn Rust that you wouldn't want to teach say, Chemists to write Rust rather than Python when showing them some Computational Chemistry, even if maybe the ones who "got it" would be better programmers your focus is Chemists, not programmers.

Or on safety we should not write new codecs in general purpose languages, including Rust, because these languages necessarily (Rice's theorem) can not check the semantic constraints we want to deliver safe codecs. We should use WUFFS. WUFFS is also a hard language to learn and as a special purpose language it's not applicable to most problems people have, but it is inherently safe† and delivers extraordinary performance so that's the right choice for this particular work.

† In C++ bounds misses are Undefined Behaviour, likely a security disaster. In Rust bounds misses cause a panic, likely premature program exit. In WUFFS any code which can have a bounds miss isn't valid, you get a compiler diagnostic saying you wrote this wrong, fix it.



In C and C++, Undefined Behavior basically says it's safe for the compiler to assume this hasn't happened, because as a programmer it's your responsibility to ensure it's impossible. This might not have been so bad if completely normal things (such as signed integer overflow) weren't UB. It's not safe to assume the programmer did it correctly, and it never will be. So, these languages have tons of footguns.

UB also exists in Rust, however it's only supposed to exist in unsafe code, and even within unsafe code, you still benefit from Rust's great RAII, move semantics, deterministic destructors, and so on. It's still UB to index past the bounds of a memory region (well... uhh, insert Stacked Borrows or Tree Borrows here, this gets much more complicated, but you get the idea) but you can only do this unchecked from unsafe code, otherwise it'll always be checked and will panic if you attempt an out of bounds access.

When unsafe code is a special delineated section, you're less likely to forget to be very careful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: