Re:Hard-won lessons: Five years with Node.js
by cookiecaper on Thursday April 20, 2017 @01:35PM
(#14158898)
Unit tests are a completely inadequate replacement for typing even if they actually do exist, which, as you stated, is pretty rare.
I think the best compromise is optional typing. The language should encourage it by default, but allow some variables to be declared as dynamic/untyped. This greatly simplifies things like parsing of JSON data, which should essentially all be considered a string until there's some reason to consider it something else, but enforces consistency and safety through most of the application. Haxe does a pretty OK job with that.
Re:Hard-won lessons: Five years with Node.js
by _pmf_ on Thursday April 20, 2017 @01:50PM
(#14159050)
> I think the best compromise is optional typing. The language should encourage it by default, but allow some variables to be declared as dynamic/untyped.
Like C#'s dynamic keyword (not to be confused with its var keyword, which just does type inference).
Because 17 years ago, I had this same naive development workflow. With PHP, exactly as OP mentioned.
Whenever someone mentions static typing, the canned response from JS developers is "Oh, haha, we actually have unit tests for this" (usually accompanied with a patronizing smile for the obsolete waterfall programmer). Yet when dealing with a real world dynamically typed application from some mediocre company, there are (surprise) no unit tests at all.