Hacker News new | ask | show | jobs
by freedomben 806 days ago
> Languages don't make programmers leave out annotations where it aids readability.

This is true, but most people are not going to incur write-time penalties to benefit read-time later on. Annotations (usually) benefit read-time at the expense of write-time. Having had to work on codebases that were written by people who were furiously trying to "get things done" because not shipping or shipping late might mean going out of business, they take whatever shortcuts they can. It ultimately saddles other people with tech debt for years and in some cases decades.

2 comments

I think this is both right and wrong. Granting Sturgeon's law, most code is bad and hard to read and type annotations will usually help. On the other hand, in code that is very well written, type annotations are largely redundant visual clutter that do not improve the readability.

I'd say that for most people, use annotations most of the time is good advice, but there are exceptions and people should refrain from casting judgment on other's work due to a dogmatic instance on others using their preferred style.

I agree completely, well said. It's probably 1 in 10 (in line with Sturgeon's Law) but there are some devs out there for whom their code is like poetry, and reading it is a genuine pleasure. For those, types and annotations and such really do add clutter and make it worse.
This is why we have gradual typing, or static type analysis added to dynamic languages. I work in a large Ruby/Rails codebase that has high Sorbet type annotation coverage. There really is no excuse to keep avoiding adding type info, or at least recognize that the pain is self-inflicted.