5 ms·
Cool project, but why engage in language flame war on the project readme: > I think Scala is the best mainstream language with a sophisticated type system. Sop
by mihaifm 7y ago
Cool project, but why engage in language flame war on the project readme:
> I think Scala is the best mainstream language with a sophisticated type system. Sophisticated type systems are money in the bank. Going from TypeScript to Scala is like going from JavaScript to TypeScript.
- paulddraper 7y agoNot only that, accusing TypeScript of being "unsophisticated" is just dumb. Unsound, inconsistent, overly complicated, poorly abstracted, improper paradigms.....any of those would be a more legitimate criticism than "unsophisticated".
- codesushi42 7y agoTypescript is flawed, but it is a godsend compared to using straight JS. You can use it like Java until you can't. And then you are forced to muck around with JS hacks just to please the transpiler. Usually that happens using generic types. They are almost completely worthless in Typescript, and have no analog whatsoever in JS. So you are mucking around just to please the transpiler but adding a type unsafe hack anyway in place of a generic argument. Typescript should have just stuck with providing checks on type declarations. That's it. Stop adding features from Java/C# when they make no sense in JS. I would pick another language in a heartbeat, given a choice.
- nicoburns 7y agoTypeScript's type system is actually much more expressive than Java or C#'s. You can't express OR types (sum types) like `string | number` nicely in those languages. It's the main thing that made me hate statically typed languages until I tried Rust (which also lets you express this).
- codesushi42 7y agoHuh? You would just overload the method then in another language. That is a lot safer than manually checking the argument type inside the method with the hack you proposed. You're right if by "more expressive" you meant "not really safe at all". By using the types of hacks you proposed, you end up losing type information and safety guarantees. So why bother using Typescript in the first place then? Your example is the perfect argument against Typescript. If you were referring to generic types, then there's no good reason to do that in the first place. Use a base type. Polymorphism 101. Anything else would be duck typing, and not safe. There's no middle ground with type safety: it is either safe or not. And if there's a chance it's not, then you've lost and all of your efforts are pointless without resorting to manual checks. And if you were somehow referring to C++ like templating (unlikely), then Typescript doesn't support that anyway.
- dragonwriter 7y ago> Not only that, accusing TypeScript of being "unsophisticated" is just dumb. Probably, but the thing you are doing doesn't accuse TypeScript of being unsophisticated but of having an unsophisticated type system (these are as different as describing a person as being short is different from describing them as having short hair.) And, yeah, a type system that lacks soundness, lacks consistency, is overly complicated and poorly abstracted, and uses improper paradigms can fairly and succinctly be described as unsophisticated compared to one that does not have those shortcomings; the descriptions you point to may be more specific, but are not more legitimate, nor are they more appropriate when the context isn't a detailed dissection of the language.
- AlexITC 7y agoUntil tsc compiles just fine even when you wrote a function that uses an undeclared variable.
- paulddraper 7y agoThose are called globals. Avoid them.
- dmit 7y agoThat wouldn't quite work because all of > Unsound, inconsistent, overly complicated, poorly abstracted, improper paradigms apply to the current stable version of Scala as well. You'd be comparing Typescript as it is in production right now to a best case scenario of where Scala could end up in a couple years.
- sideeffffect 7y agoI think the author was trying to point out that Scala has type system features, like Higher-kinded types, which (although very useful in practice IMHO) are non-existent in other mainstream languages, including TypeScript. I think that's a legitimate and, most importantly, factually correct point to make. If you're interested in what these "Higher-kinded types" are: https://typelevel.org/blog/2016/08/21/hkts-moving-forward.html https://typelevel.org/blog/2016/08/21/hkts-moving-forward.ht...
- paulddraper 7y agoThat's true. Though since TypeScript 2.8, you can use "conditional types". An HKT encoding using conditional types: https://github.com/pelotom/hkts https://github.com/pelotom/hkts
- spir 7y agoThanks for the feedback. I have updated the README to use less inflammatory language and be more specific that the comparison is just for the type system. The new text is For me, from a type system perspective, going from TypeScript to Scala is like going from JavaScript to TypeScript. (I love TypeScript and write a lot of it!)
- paulddraper 7y agoHaving written massive amounts of both Scala and TS, I'd say the #1 issue Scala has the the impossibility to understand a simple variable reference. If I see `A`, the search space to understand where that comes from is quite large for most Scala.
- mruts 7y agoI’m a professional Scala dev, what exactly do you mean? Structural sharing instead of copying? Implicits?
- paulddraper 7y agopackage mypackage import shapeless._ import anorm._ import mything.MyObject._ import com.seriouscompany.Foo object MyThing { val a = new A() } What does A refer to? Where does it come from? One of the 15 files in the anorm package? Does it come from one of the 40 files in the shapeless package? What about mything.MyObject and the dozen mixin traits that it has? Alright, let me clone the repo, startup my 4GB IDE, wait 15 minutes for it to download JARs and index eveything and then I can get an answer to where `A` is defined. Scala wildcard imports are very common in practice, but even if I eschew them, there still another 50 files in the mypackage package that could contain its definition. --- The same thing can happen in TS with globals, but those are rather few.
- dmit 7y agoAnecdotally, this is a non-issue depending on the tools you use. IntelliJ IDEA and Metals both have Go To Definition support.
- beders 7y ago> Sophisticated type systems are money in the bank. You better have money in the bank to allow for all the refactoring you will be doing once you realize your data model needs to change in unforeseen ways ;)