Hacker News new | ask | show | jobs
by gibbitz 509 days ago
Dynamic languages require different approaches to problems than statically typed languages. Generally I design my APIs differently in dynamically typed languages. Reducing the opportunity to pass bad values, not using more than two function parameters and not overloading. Using scoped functions that are closed to end users puts you in control of the values passed in. Not using OOP if it isn't natively supported in the interpreter, etc. JavaScript makes simple checks easy by evaluating 0s, empty strings and undefined as falsy. Over tightening these checks increases development time and maintenance overhead with little actual additional "safety". It's better to take a minimal approach and add checks when errors occur than to try to predict errors that never occur with a comprehensive aproach. In this way adding types to dynamic languages is just premature optimization.

Another important factor here is the implementer's ability to troubleshoot. If you don't know how to detect and find a mistyped variable you need to accept that you don't know the language and ask someone who better knows how to run and troubleshoot applications to help you find it. Dynamically typed language interpreters/compilers provide feedback that is sometimes opaque but generally offer clues if you know where to look. It's not the same experience as having a compiler in your IDE that can show you the potential error as you enter it, but dogs are not cats either.