Hacker News new | ask | show | jobs
by niggler 5002 days ago
" I still make mistakes."

There's a really interesting documentary about Edsger Dijkstra in which they looked back at his old notebooks. He wrote by hand, and when a correction was needed he'd tape a segment on top of it, and sometimes youd see stacks of these corrections. When all of the fragments were removed, the top version almost always was same as the original.

The point of the anecdote is that most professional developers I've met are incredibly disciplined and take time to understand the intricacies of what they are working with before starting. The types of mistakes that Typescript can catch stem either from carelessness (like mistyping) or memory loss (forgetting a function signature), but those can be obviated.

"I have found that type hints, code completion, intellisense, helps me discover mistakes sooner, often before I make them"

Code completion shields you from spelling mistakes. Intellisense saves you the need to remember the signature of various functions (most of which you should know anyway). Type hints help with nondescript names, but hopefully your variable names have the types implicitly embedded (e.g. 'count' or 'cnt' are almost always integer types)

I'm not saying most people don't suffer from these problems from time to time, but most professional developers I know are very careful and write good code the first time.

"Often, BTW, you are using a class (or JS function, whatever) that you didn't write"

Again, most APIs use sufficiently descriptive names that there should be little confusion. If there is ever a point where something is not clear from the outside, oftentimes there are issues on the inside that should be addressed (minimization notwithstanding).

I think Typescript misses the point. A high quality linter for javascript could pick up on most of the issues that TS picks up on. Furthermore, there are some quirks that break compatibility, which does to an extent suggest hijacking.

2 comments

However, when working with good type inference (i.e. Haskell)... 1: it's possible to relax on the discipline a little; mental resources are limited (at least for me). 2: typed-based dispatch; refactoring based on static types; etc.
I think you're misremembering the documentary. It was Dijkstra himself reminiscing about a composer, whose scores had corrections taped over them. He was illustrating the difference in mindset by comparing Mozart to Beethoven.