I often see claims that modern functional strictly-typed languages are 'safer' than others. These statement mostly linked with type systems and their ability to explicitly express the following pitfalls:
- Alternatives in function result. Maybe and Either datatypes vs. exceptions and null-pointers in C++-like languages.
- Access to mutable state (possibly inconsistent behavior over time). State datatype in Haskell vs. variables in C++-like languages.
- Performing IO. IO datatype in Haskell vs. just doing things in C++-like languages.
Haskell allows to express constraints required for safe handling of these situations. And compiler is able to warn programmer when he doesn't follow them.
Although pitfalls above are definitely the most common ones I can think of much more, for example:
- Unexpected resource consumption. Memory, CPU, disk, bandwidth.
- Inconsistent access to shared resources. Like read and write interference, broken lock ordering.
- System-level failure. Like crashing process or pulled plugs.
- Unexpected execution time for IO, timing violation.
Is there languages, libraries or at least models which allow to express constraints from the second set and yield a warning when they are not met?