6 ms·
> It's far more useful to implement validation and type checking via ... runtime in a dynamic programming language than to pedantically have to type all your va
by yawaramin 9y ago
> It's far more useful to implement validation and type checking via ... runtime in a dynamic programming language than to pedantically have to type all your variables.
How is that? I'm not seeing the increased utility.
> It's better to trade a fast and quick runtime type error....
What if the runtime type error crashes your app in production and loses your company money? What if it's something that slipped through your end-to-end integration testing because certain unlikely conditions never got covered, but they happened in production?
> ... than a lengthy compile-time type checking process,...
There are several modern compilers which are quite fast: D, OCaml, Java.
> ... because less code needs to be evaluated at run-time to expose the type error.
With static type checking, no code needs to be evaluated at runtime to expose a type error. Does dynamic typechecking offer a reduction over that?
> Wouldn't it be great if we can use the computer to figure out what the types should be by a runtime evaluation of the code and save precious human time for things only humans can do?
Wouldn't it be great if the computer would figure out the types at compile time and save us from having to manually input them? Well, the computer can do that, thanks to type inference. Several popular languages offer full, powerful type inference.