3 ms·
In a way, I think the problem is that TypeScript doesn't go far enough: it adds static typing, but has to awkwardly attach those types to APIs intended for a we
by jasonhansel 8y ago
In a way, I think the problem is that TypeScript doesn't go far enough: it adds static typing, but has to awkwardly attach those types to APIs intended for a weakly-typed language.
- jondubois 8y agoYes, JSON is by far the most popular data interchange format ever invented. This is for a good reason; it's the most compatible format possible; it works with any language and any system regardless of what kind of typing is used. As compatible as it is, there is definitely a lot of friction/awkwardness around type-casting JSON objects to typed objects within a statically typed programming language; there is an impedance mismatch. It's not as awkward as trying to type cast objects designed under one type system to a different type system (e.g. SOAP APIs) but it's still really awkward. The impedance mismatch goes away completely if you use a dynamically typed language like JavaScript. For example, JSON produced by a python program can be parsed by a JavaScript/Node.js program without any issues. The root reason why types are bad is because they're opinionated. There is no absolute right way to type something; and because of this, it's not correct to force other projects which interface with your project to adhere to your type definitions.