Comment by IshKebab

1 month ago

Dart is better in some ways and worse in others.

1. It has an actually sound type system.

2. The language and standard library are waaaaaaaay ahead of Javascript.

3. The tooling is top notch. Better than JS/TS.

But on the other hand:

4. Way smaller ecosystem.

5. Debugging is worse if you're compiling to JS. The fact that the code you run is basically identical to the code you write in TS can be a big advantage. Only really applies for web pages though.

6. Type unions are way nicer in TS.

7. Non-nullable types interact badly with classes. It can make writing methods correctly really awkward - you have to explicitly copy member variables to locals, modify them and then write them back.

8. Way smaller community.

As someone curious about learning more about type systems, would you mind elaborating on 1.? I'm assuming you mean the formal definition of "sound", not just as a synonym for "sensible". Sound typing is often something handwaved away as not being particulary consequential in practice; what benefits have you seen there?

  • It's not particularly consequential when the types are only used for type checking and then thrown away. That's how Typescript and Python work.

    But when the types are sound you can use them to compile better code. That's what most languages with "proper" static types (not just type hints) do.

  • From the official website: > Dart enforces a sound type system. This means you can't write code where a variable's value differs from its static type.

    I know you didn't ask me but I think that not ensuring soudness is a feature because it allows the type system to wrap something that could work without it. Would you like unit tests if removing them would break your code? Maybe it's not a fair comparison, or maybe it is...