5 ms·
Typescript also significantly reduces communication overhead and provides machine-verifiable documentation, making it way easier to figure out WTF is going on w
by asark 8y ago
Typescript also significantly reduces communication overhead and provides machine-verifiable documentation, making it way easier to figure out WTF is going on with unfamiliar or long-out-of-sight code. People who don't love TS compared with vanilla JS must work entirely differently from me—using it's the only time I've not hated writing JS. Tons of time-wasting poking about and background anxiety just gone. It's great, and costs almost nothing.
- phamilton 8y agoTypescript is a gamechanger with generated interfaces. We use it heavily with an RPC framework and pulling down the generated client and server packages have drastically minimized integration issues. It just takes away the mental overhead of making something conform to a spec. It probably doesn't save us much on production bugs, but it makes development faster.
- jondubois 8y agoGenerated interfaces are an anti-pattern. Types force tight coupling between clients and servers. What if a third-party project written in a different language wants to communicate with your server using their own client? Types will make it more difficult for them to integrate because: 1. If they're using a dynamically typed language, this gives them extra work to typecast everything back and forth whenever they need to communicate with your system. 2. Even if they use types, maybe their type system is not compatible with yours and they need to do a lot of tedious extra work to typecast everything.
- zwerdlds 8y agowhat is the solution? runtime errors?
- asark 8y agoHuh? Everything always has a type anyway. It's sometimes just harder to know what it is. Specifying doesn't make the types appear out of nowhere, it just documents them.
- true_religion 8y agoI wouldn't call that an antipattern. I treat other systems like I do the database and enforce consistency at the API level. I wouldn't ask for a database to be totally untyped (and thus silently coerce things into its internal types in reality), so I don't ask for the same in an API. Though, I can understand some people have differing preferences---MongoDB is popular for example---but I wouldn't call it an anti-pattern no matter which choice one makes.
- tom_ 8y agoNo, it makes it easier, because they have a specification to work from, and they can probably just use that spec to generate their own glue code, assuming any is necessary. I have never found option 2 to apply in any meaningful fashion, though I'm sure others have done much more of this type of work than I have.
- phamilton 8y agoI've found it to be annoying in the other direction. A type system like protobuf isn't rich enough for the problem domain. We end up building a lot of additional validation into the servers and clients that could have been enforced by the service/types spec.
- phamilton 8y agoWhich is why our rpc services accept json in addition to protobuf. Yay, problem solved.