3 ms·
This is exactly my feeling about Typescript. As a Go! developer, I'm fully for strong types, even to the point of restriction, but only if they are enforced. I
by chessturk 8y ago
This is exactly my feeling about Typescript. As a Go! developer, I'm fully for strong types, even to the point of restriction, but only if they are enforced.
I'm currently maintaining a massive spaghetti code TypeScript nightmare that escape-hatches with @ts-ignore and `any` about every other line. I'm not sure why they even chose to give up all of the imperative, dynamic power of JS and then not even adhere to the pre-processor's own rules.
I think there's an argument for imperative and functional approaches, but I also think trying to change an imperative language into a functional one is a bad idea, and trying to shoe-horn in type safety into a language that doesn't have it is just foolish.
I feel like languages come with trade-offs inherent in their design (Go! trades DRY for type safety, JS trades data validation/type safety for convenience), and if you don't like the trade-offs of the language for your project, then you are probably using the wrong tool for the job. However, when it comes to JS, you usually don't have a choice (unless you go with Dart or WebASM, which I admittedly know very little about).
I suppose TS could have a place (I particularly understand libraries that attempt to improve their data contract using it), but then I wish it didn't provide such wide variety of ways to escape or ignore it's restrictions. I feel like they are fake guard rails and provide a false sense of security.
- lugg 8y agoAgree wholeheartedly, I have no issue with typescript or typesafe languages. I actually enjoy them a lot for other reasons, being able to guarantee type is a nice feeling. But it doesn't guarantee correctness. And I think that is the problem. Developers see lack of type safety as a lack of correctness. Hell, I don't even blame them, a lot of code I deal with is impossible to reason about because of so many bad habbits code review is supposed to catch. My issue with TS is that people are using it to solve a problem that it does this actually solve: the developers reluctance to code clean.