5 ms·
> It's singleton and union type support is leagues ahead of Scala and Dotty. What? I don't understand it's better than dotty which has a proven core? Typescrip
by eklavya 9y ago
> It's singleton and union type support is leagues ahead of Scala and Dotty.
What? I don't understand it's better than dotty which has a proven core? Typescript's type system wasn't (isn't? I don't know) even sound.
> Java devs that have a negative impression of Scala and prefer Kotlin
To each their own but if you learn Scala you can never go back to Java/Kotlin, there is not even a contest.
Edit: newlines added
- tytytytytytytyt 9y agoYou're the hero we deserve.
- seanmcdirmid 9y agoTypescript is incredibly unsound and at the same time incredibly useful. It rejects the notion that types are just for hard correctness guarantees and focuses on tooling.
- tytytytytytytyt 9y agoSo 'tooling' is it's real selling point? Wow... Last I checked it still used the same mean arrays and dicts, too. Scala's default libraries blow/blew it out of the water.
- seanmcdirmid 9y agoThat's not what tooling means. What you are talking about are called "libraries", which, using the same libraries with better tooling, is one of the core strengths of TypeScript.
- tytytytytytytyt 9y agoThose were 2 separate thoughts. I was not conflating tooling with libraries. And I'm still amazed that you seem to think tooling would be a main selling point or 'core strength' for it.
- seanmcdirmid 9y agoYes. The compiler catches most type errors (depending on how faithful you are to the type system), and code completion and refactoring are great also.
- dtech 9y agoYou should really check out how to do ADT's in TS. It's incredibly simple and intuituve thanks to the union and Singleton support. type Shape = Point | Circle interface Point { type: "Point" x: number } interface Circle { type: "Circle" center: number } let x: Shape = foo() if(x.type == "Circle") log(x.x) // Error It's enterily generic and flows through the whole type system. It makes nullability trivial and `Option` superfluous, since `Option<T>` is an alias for `T | null`. If you check it for null once the type will immediately become `T` from then on. Try something like this with Dotty's enums, it's super easy to hit the limits there.
- tytytytytytytyt 9y agoYou've already hit a limit when you're having to pepper your code with C style union type checks, imo.
- dtech 9y agoYou don't get it, you don't have to pepper the code. If you already have a `Circle` the check is unneeded. If you have done the check the type is constrained. You do exactly as much or less checks as you would do pattern matches on sealed traits in Scala, except that it works as you except in all instances, not just with sealed traits.
- tytytytytytytyt 9y ago> You don't get it, you don't have to pepper the code. If you already have a `Circle` the check is unneeded. That's not even what I was talking about...
- dragonwriter 9y ago“Option<T>” is not an alias for “T | null”, which is apparent when you try to puzzle out how to represent “Option<Option<T>>”.
- 9y ago