Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Off the top of my head:

- Properly cross platform (including first-class JS/WASM interop)

- AOT & cross compilation

- Hot reload

- Static typing with many nice features (generics, extension types, enhanced enums, etc)

- Expressive without being overly verbose

- Well-supported by the language & SDK teams (i.e. it's not dead)

- Easy build/package system

The only things I really feel are missing are (1) union types and (2) access modifiers like protected/friend.



When coming from TS to Dart, the lack of union types was a huge bummer. But I saw a discussion somewhere that you can achieve something close with sealed classes to model union types combined with exhaustive pattern matching, but Idk.

Another user hinted at this package https://pub.dev/packages/extension_type_unions, have you seen it before?

Also it's worth noting that sum types can be achieved with Dart 3!


I'm a heavy user of exhaustive pattern matching with sealed classes, definitely a great feature. You can achieve the same outcome as union types, but it's a lot more leg work, e.g.:

```

sealed class MyParam {}

class Bar extends MyParam { String val; }

class Baz extends MyParam { int val; }

void foo(MyParam param) {

  switch(myParam) { 

      case Baz(val: final val):

      case Bar(val: final val):

  }
} ```

compared to:

```

void foo(Bar | Baz myVar) {

    switch(myVar) { 

        case Bar:

        case Baz:

    }
} ```

I hadn't seen the extension_type_unions package, though, I'll check it out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: