Dart 3.3
31 points by markdog12 1 year ago | 16 comments- irq-1 1 year agohttps://pub.dev/packages/web
> This package exposes browser APIs. It's generated from the Web IDL definitions and uses recent Dart language features for zero-overhead bindings.
Dart doesn't get the respect it deserves.
- chipweinberger 1 year ago> Dart doesn't get the respect it deserves.
For sure. Its only real use case is Flutter right now.
If Dart decided to expand things would get interesting.
That said, I really enjoy its focus on Flutter.
- mixmastamyk 1 year agoWhere it's commonly used is not its use-case. It can be used for a number of other cases.
- pjmlp 1 year agoOutside Flutter it has nothing to offer versus Java, Kotlin, Scala, Kotlin, C#, F#, OCaml, Haskell, Rust, Go, C++, ...
Lesser libraries, lesser IDE tooling, smaller community, no must have cases,...
- pjmlp 1 year ago
- mixmastamyk 1 year ago
- Alifatisk 1 year agoOh, the package is apparently supposed to replace dart:html
- chipweinberger 1 year ago
- seertaak 1 year agoIt seems every language starts with free functions and classes (even mojo). They then realize that isn't so great: third parties are at a syntactic disadvantage (no dot fn's). And then, the language designers "fix" the problem with extension methods. Now you have three different function kinds, and we haven't even broached async.
Why not have only structs, free functions, and UFCS?
- igorbark 1 year agothe historical expectation is that class methods will dispatch dynamically but free functions will not. so if you only have structs, functions, and UFCS you either: 1. don't dispatch on the first argument, 2. make the first argument privileged and dispatch on it, or 3. dispatch on all the arguments
the first solution is clean, but people really like dispatch.
the second makes calling functions in the function call syntax weird, because the first argument is privileged semantically but not syntactically.
the third makes calling functions in the method call syntax weird because the first argument is privileged syntactically but not semantically.
the closest things to this i can think of off the top of my head in remotely popular programming languages are: nim, lisp dialects, and julia.
nim navigates the dispatch conundrum by providing different ways to define free functions for different dispatch-ness. the tutorial gives a good overview: https://nim-lang.org/docs/tut2.html
lisps of course lack UFCS.
see here for a discussion on the lack of UFCS in julia: https://github.com/JuliaLang/julia/issues/31779
so to sum up the answer to the original question: because it's only obvious how to make it nice and tidy like you're wanting if you sacrifice function dispatch, which is ubiquitous for good reason!
- igorbark 1 year ago
- Alifatisk 1 year agoThe extension type was a bit alien to me, so it’s a type with functions in it?
Also, any plans on union types? There is like no way to tell Dart when something can either by type A or type B.
I believe pattern matching is the only way at the moment.
- steve_adams_86 1 year agoYou might already know of this since you mentioned pattern matching, but there is the `sealed` class modifier which allows for exhaustive matching on class subtypes. It's very limited: https://dart.dev/language/class-modifiers#sealed
I recall there being a reason unions aren't generally implemented, though I'm not sure where I read it. It was to do with union types being unnecessarily complex for the compiler and the code they tend to produce, at no real benefit to the programmer or the resulting program. Go's lack of unions is essentially based around the same reasoning.
It looks like it's an open discussion for Dart, but I can't see any explicit plans for an implementation.
- Alifatisk 1 year agoThe sealed class with the switch case pretty much solves my issue cleanly, thanks!
- steve_adams_86 1 year agoNice, I know hardly anything about Dart so I’m glad what little I know was of use.
- steve_adams_86 1 year ago
- Alifatisk 1 year ago
- steve_adams_86 1 year ago
- chipweinberger 1 year agoThe improved Web interop looks really nice.
Dart is evolving so quickly!
- dark__paladin 1 year agoDart is actually fairly nice to use. It's a shame it will probably end up in the Google graveyard in a few years.
- Alifatisk 1 year agoI don’t actually think it will, they have invested a lot in it and some of their products are still using Dart.
- Alifatisk 1 year ago