Hacker News new | past | comments | ask | show | jobs | submit login

Many years ago, I used to code in OCaml. I used to think exactly like you (OCaml has extreme levels of type-inference, so you write as little code as Python and you get type safety). However, as I worked on larger codebases, I realized that most of these type hints on which I was saving a few keystrokes were actually part of the documentation. When I returned to older code, it looked smart, too smart, but I had no clue about my invariants.

And in your particular example, if you write `road = {}`, chances are that it will end up being typed as a `Dict[str, Any]`, which is basically worthless, both to avoid TypeError, but also as a suggestion of what you should and shouldn't put in the dictionary.

These days, I write my types aggressively.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: