4 ms·
"surprisingly typed" is a good term. It sounds, though, like you're using it to mean "dynamically typed", which is maybe overly harsh. What I think it captures
by bunderbunder 8y ago
"surprisingly typed" is a good term. It sounds, though, like you're using it to mean "dynamically typed", which is maybe overly harsh.
What I think it captures well, though, is an unfortunate habit among many dynamic languages' communities to pretend that types don't matter. Python is getting better, but it used to be really bad about this. The standard library's documentation, for example, would give only the names of a function's parameters, and leave it to you to figure out, presumably by guess and check (and prayer), what kind of input it was prepared to accept. It's still really common for the documentation to force you to go to the REPL to ask a function's return value what its type is.
- sevensor 8y agoI work in Python day to day and have done for several years, so I think I'm entitled to describe Python's type system as "surprising." I generally think duck typing is great, and I always appreciate the flexibility it gives me. But the flip side of that is -- surprise! -- you can't use me as an index! -- surprise! -- I'm not hashable! -- surprise! -- you can't pickle me!. I've been looking at how other languages handle this, and I think typeclass / trait systems seem to strike a good balance, allowing flexibility without surprises.
- bunderbunder 8y agoThe typeclass approach can be just as surprising. Possibly more so, because it means that a type's implementation of a class can come from literally anywhere. So the universe of surprises still includes "Surprise! It's not hashable!", but now also includes, "Surprise! It was hashable, but now isn't, because you stopped importing this seemingly unrelated package." If you do get surprised that X doesn't support Y, though, you have ability to provide your own implementation without resorting to monkey patching.
- sevensor 8y agoThat's a good point! I suppose the grass is always greener...