Hacker News new | ask | show | jobs
by jdmoreira 2148 days ago
> Static vs Dynamic Typing

All research is inconclusive? Sure. I wonder what kind of type systems were in there? I guess Java and similars are accounted and yet I wouldn’t put any faith in them. ML, Swift, Haskell... now that’s something else.

3 comments

My interpretation of that is both that we need more research and that this is a very hard problem to study. One of the big challenges is that the things which are easy to study aren't representative of real world conditions: if you have CS undergrads doing new development on toy problems, that isn't representative of what experienced developers at most businesses do. Having people pick less common languages can select for programmers who aren't representative of the general field[1] and are probably going to invest extra time making their favorite language look as good as possible. You can hire people, train them in various languages, and have them implement something generally applicable but that's now a really expensive study.

1. e.g. what percentage of the gains attributed to Lisp were more likely due to the candidate pool in the 90s/2000s skewing heavily towards people who learned it at elite CS programs, especially if you're doing a challenge competition which benefits from having studied various algorithms?

It doesn’t account for the communication value of static types. Personally, I consider static types primarily a communication tool, so IMO the review’s interesting but not very useful per se. Also the main point of it seems to be “research on this topic is mostly bad, so far, so who the hell knows what’s true”. It could be that the research has sucked, not that there’s little discernible difference between the two on the dimensions measured.
It seems to me that tests are equally good as a communication tool.
They don’t save me from having to go look at other files to learn things about the code I’m actually interested in; they can be misleading in ways that types aren’t—in particular, it’s very hard to know what sorts of things an all-green test suite guarantees versus a passing static type build, without a great deal more information; and they are, in practice, prone to rot and neglect in a way static types rarely are, and are harder to bring back into a useful state when that happens.

They serve very different purposes and generally are not first and foremost good communication tools the way static types are, for a bunch of reasons. That doesn’t mean tests aren’t very useful and welcome things to have, however.

My experience is that tests tend to be much harder to read, and take more effort to understand, than types. Types are a higher-level approximation for your program.
That's fair
Seems like modern Python or TypeScript are close to sweet spot for typed code. You don't need to set types for everything, but just enough to get checks from a compiler in most important places (at least for TS, tooling for Python is still lacking). Java is slowly going there too, but from another direction.