4 ms·
How about typescript? It supports union types, lambda functions and type aliases. Would you consider it on par with Kotlin?
by tejinderss 3y ago
How about typescript? It supports union types, lambda functions and type aliases. Would you consider it on par with Kotlin?
- gavinray 3y agoI adore TypeScript -- JS/TS has been my primary language for most of my career. Kotlin has a few things that TS doesn't have but overall, I'd rate it very similarly. I probably enjoy writing TS a bit more than Kotlin. EDIT: TS also has Opaque Types, sort of. They call them "brand types" or other names, it looks like this: declare const opaque: unique symbol declare type Opaque<T, K extends string> = T & { readonly [opaque]: K } type Email = Opaque<string, 'Email'> function mkEmail(email: string): Email { return email as Email } function takesEmail(email: Email) { console.log(email) } const email = mkEmail('foo@bar.com'); takesEmail(email); takesEmail('wrong'); // error
- tejinderss 3y agoYeah i think extension functions and operator overloading are biggest things in kotlin that are missing in typescript. Its very easy to add functions to existing types and chain the method calls in kotlin. Edit: didnt know about the brand types in typescript, TIL, thanks for the example.