3 ms·
What kind of errrors do you think are not caught with static typing? Usually people who say this aren't familiar with languages that have type classes...
by runT1ME 9y ago
What kind of errrors do you think are not caught with static typing? Usually people who say this aren't familiar with languages that have type classes...
- flavio81 9y ago>What kind of errrors do you think are not caught with static typing? Citing awj's post above: "Some of the biggest errors are subtle failures in the implementation of business logic." Other examples: - bumping into unkonwn bugs of a library you are calling - implementation of an external (library) function behaving differently than the documentation - various memory leak problems - locking issues - race conditions etc
- runT1ME 9y ago>"Some of the biggest errors are subtle failures in the implementation of business logic Static typing can prevent errors in business logic. >various memory leak problems - locking issues - race conditions All are bugs that static typing has had tremendous success in preventing. Have you any experience in a HM like type system?
- flavio81 9y ago>All are bugs that static typing has had tremendous success in preventing. Please do elaborate, it could be a great post. But If you mean to say that locking issues can be prevented because you can apply STM (software transactional memory) by using suitable Monads, then, well, i can also have STM in a dynamic language, even applying it by wrapping code in an "atomic" context (i.e. see the STMX library for Common Lisp) so the statements contained within are performed atomically (and thus guaranteed to work or either roll-back.) As for memory leaks, Haskell (if that's the HM language you had in mind) automatically manages memory, so I would guess this isn't a problem at all. However, automatic management memory management is orthogonal to "static vs dynamically typed". Thus, i'm curious, and yes, i don't have enough experience with HM-type languages, which should be the way to go if one wants to use static typing...
- tome 9y ago> i can also have STM in a dynamic language How can you roll back failed transactions without explicitly typed effects?
- platz 9y agoClojure tracks and rollbacks the STM-bound variables according the STM rules; it is not intended to prevent you from doing other effects inside those transactions; you are supposed to have an understanding not to do that in the transaction blocks. It helps a bit that most clojure datastructures are immutable/persistant by default.
- tome 9y agoIn other words Haskell's STM prevents bugs that Clojure's merely supposes the programmer not to have written.