3 ms·
Types in any modern statically-typed language should go well beyond simple "machine types" and also capture semantics. If one is representing everything with St
by willtim 9y ago
Types in any modern statically-typed language should go well beyond simple "machine types" and also capture semantics. If one is representing everything with Strings and Doubles, then the type system is not being fully exploited.
Refinement types can statically capture range checks and other similar assertions. There is a project to add them to Haskell (Liquid Haskell) which is already quite useable.
Of course, static types are machine checked prior to running the program. None of your Python "types" exist until runtime, by which point it is too late. The program crashing due to an assertion failed error is logically still a crash.
We will have to agree to disagree on the roll of static types when building large systems. I have also spent over a decade working on very large codebases. The more "dynamic" a system was (late binding, reflection, string-based lookup, variants), the harder it was to statically reason about the code and avoid introducing errors. In a fast-paced business where hundreds of people are changing the same codebase daily, I do not understand how one could stay sane without static types. Python was never designed with such use-cases in mind.
- jbednar 9y agoSounds like we'll have to agree to disagree about a lot of things! :-) Having types specified statically is a recipe for generating untold many different versions of the same thing, plus untold bits of glue between them, which leads to huge codebases that need hundreds of people to work on them. Python was designed to avoid huge codebases and let smaller numbers of programmers be more efficient. (Of course, so was Haskell, but that's mostly a straw man, given how few large-scale users of Haskell there are in industry...)
- tome 9y ago> Having types specified statically is a recipe for generating untold many different versions of the same thing, plus untold bits of glue between them Polymorphism is for addressing exactly that objection.
- jbednar 9y agoAnd Python's duck typing is for addressing the needless constraints that statically typed polymorphism introduces. Discussions like this can go on forever! :-)