3 ms·
> Scala is really lacking a way to easily support structural typing like typescript does. ES clearly wins here, since in Scala you have to define the case class
by nikitaga 5y ago
> Scala is really lacking a way to easily support structural typing like typescript does. ES clearly wins here, since in Scala you have to define the case class in advance. And while you can just use maps, you give up typesafety.
Looking at it the other way, Typescript is really lacking nominal typing and the safety and simplicity that it provides. Structural typing isn't needed if you don't care about Javascript / dynamically typed coding patterns. But Typescript is optimized for exactly that, that's why it has structural typing. Personally I much prefer Scala's type system, it is very rare that I long for more dynamism than it affords, even though I've coded in and liked Javascript for years prior to that.
- valenterry 5y ago> Looking at it the other way, Typescript is really lacking nominal typing and the safety and simplicity that it provides. True. > Structural typing isn't needed if you don't care about Javascript / dynamically typed coding patterns. I think this idea of yours is limited to what you do with Scala. Ofc, in Javascript you don't need it, because types don't restrict you. But do datascience or dataengineering and it becomes painful quickly - look at spark frameless for example. It needs a lot of typelevel machinery to make it work. "easy" is different.