4 ms·
Static (and even dynamic) type safety is always a shade of gray vs. a black and white thing. A language that is 100% type safe is a language that doesn't do ver
by seanmcdirmid 14y ago
Static (and even dynamic) type safety is always a shade of gray vs. a black and white thing. A language that is 100% type safe is a language that doesn't do very much (...or requires a theorem prover). Scala is very pragmatic in that regard.
- typetheoristic 14y agoI'm not sure what world you're living in, but Haskell and ML seem to offer some measure of type safety and are also quite practical. Sure there is unsafePerformIO. But the problem is with Scala you don't even need to use unsafe language features to get an unexpected class cast exception. Given that you worked on Scala I'm rather surprised you don't know about this already.
- seanmcdirmid 14y agoCould you be more specific? Is the compiler promising more than it can deliver, or are you saying the compiler could check something but simply doesn't? You can have 100% type safety in a straight jacket, but scala pushes what it tries to type check to an extreme limit; "safe" but then also not as conservative as Haskell or ML. I see scala as the c++ of statically typed languages, filling that niche where you need more from your managed language and are willing to take a leap, but this is controversial and a personal opinion.
- SourPatch 14y agoDo you have an example of code that will throw an unexpected ClassCastException?
- pkolaczk 14y agoI never, ever had a ClassCastException in Scala that I wasn't warned about by the compiler. Maybe in theory you are right. But what counts is practice.