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

Agreed. But every production language that I'm aware of has an out that allows you to escape its type system, with the exception of languages whose type systems are intended to uphold strong security properties and verification languages that feature decidable logics. I can't remember for sure, but I think even Coq--which is eminently not a language designed for everyday programming--may diverge if you explicitly opt out (though I could be wrong about that).

The questions, to my mind, are

1. How easy it is to opt out?

2. How often do you have to opt out?

3. How easy it is to write well-typed expressions?

4. What guarantees does a program being well-typed provide?

For example, you almost never have to opt out of the type system in a dynamic language, but the static type system is very basic. In a language like Rust, you opt out semi-frequently (unsafe isn't common but it's certainly used more often than, say, JNI), and it can be hard to type some valid programs, but opting out is simple and the type system provides very strong guarantees. In a language like C, you never have to opt out of the type system, and the annotation burden for a well-typed program is minimal, but the type system is unsound--being well-typed guarantees essentially nothing in C.

All languages fall somewhere along this spectrum, including Go. It's just a question of what tradeoffs you're willing to make.



I think it's worth clarifying that Rust's `unsafe` doesn't opt-out of the core type system per se, it allows the use of a few additional features that the compiler doesn't/can't check. I think this distinction is important because, as you say, `unsafe` isn't very uncommon and so it is nice that one still benefits from the main guarantees of Rust by default inside `unsafe`. :)




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

Search: