2 ms·
Do you code in a team? Let’s say you see this function written by a colleague Jon in 2013: processLedgers(ledgers) What do you pass in? An array? An object? W
by quickthrower2 8y ago
Do you code in a team? Let’s say you see this function written by a colleague Jon in 2013:
processLedgers(ledgers)
What do you pass in? An array? An object? What are the keys?
Without types you are relying on comments (notorious for being out of date) or reading the implementation.
Often the implementation will palm off the work to othe functions and objects and maybe event send it to an api or bits of it. To get a true picture of what ledgers needs to look like you need to either read a tonne of code or copy and paste some other code you hope is right.
With types you define in the type what is acceptable. Many times you don’t need to look at the function definition or the code it calls or the code it calls calls etc.
So types save you time, reduce bugs, and make you happy!
- shay_ker 8y agoI'm well acquainted with the merits of types in general (I've worked in Java & Scala for years). I'm curious why it's so special on the frontend. I can't tell if it's just part of the Javascript hype-train, or if there's legitimately something different about the frontend.
- quickthrower2 8y ago> I'm well acquainted with the merits of types in general (I've worked in Java & Scala for years). That's your answer - same merits for the front end.
- shay_ker 8y agoHm... I feel like that's not quite the full picture. On the backend, for instance, there are options - if you like typed languages, use them! And if not, use something else! But there appears to be a particularly strong movement towards TypeScript. I just can't tell if it's just yet another JS hypetrain, or if there is something else besides types that's a big win.
- mattmanser 8y agoBecause JavaScript is (still) a cluster fuck, where there is no formal, or even informal, shared code style and it often turns into a giant mess. Typescript makes it a little less likely you muck up, plus you can use new stuff like string interpolation without ever having to think about browser compatibility.
- madmaniak 8y agoIt's Microsoft paid. Before you had React - FB paid and before Angular - Google paid. For example Angular 1 was also promoted like - it's made by Google, so it makes sense. It didn't - Angular 2 is incompatible with 1 and rejects most of initial ideas. All these giants supported also by governments can change trends however they want. You call it a hypetrain.