What are people's impression of Dart as a language, compared to e.g. Typescript? Reviews so far seems lackluster. Does Dart have anything that sets it apart from JS, like immutable data structures out of the box? How's the support for functional programming, e.g. first order functions, closures, higher order functions like map, filter, reduce, etc?
How advanced is the typing system, are we talking Java level or significantly more powerful?
As an engineer that's written a lot of (old-skool) JS, Java, Obj-C, C++, and PHP, it is a real pleasure to develop web frontends with Dart.
Immutable Data Structures: Not out-of-the-box but we use the BuiltValue[0]/BuiltCollection[1] libraries extensively internally
Functional Programming: Dart's Iterable[2] and Stream[3] classes have all the standard higher-order functions, like map, filter/where, reduce, fold, etc.
Type System: With Dart 2.0[4], the type system is really great. Expressive with good type-inference, support for generic types, mixins, & typedefs. It's actually better than Java, IMO.
Also, the async story is fantastic! JS has caught up with Dart in some areas recently but Futures, Streams, async/await, & async*/yield, have long been first-class members of the Dart language.[5]
As a programmer with experience in C++, Java, Ruby, and Javascript, and someone who just wants to get things done, I love Dart.
In its syntax, its very similar to classic languages like C++ and Java. It's very easy to pass functions around, like Javascript/Ruby. I didn't really need to 'learn' it, it all seemed familiar from the beginning. It also has some nice little shortcuts, like null-safe member function calls.
As for the typing system, it is definitely compiled/typed, which I like, but it does not feel overbearing. I find it to be in a nice sweet spot between hard to refactor/you need unit tests for everything (ruby/javascript) and hard/wordy to write because the type system is too strict (C++/Java).
It also has a nice packaging system (like ruby/javascript), and it has been thoughtful about how you reference packages.
I've used both recently, deciding between them. Dart is better.
* Typescript is much more popular, and integrates with other Javascript things better. There are way more libraries available for Typescript.
* Typescript has proper support for non-null types, whereas in Dart everything is nullable (though they are fixing it, as announced here).
* Typescript has pretty nice support for anonymous sum types (i.e. `number | string`).
However:
* Typescript doesn't actually fix any of the insanity of Javascript - it just describes it. So you can still do insane things like using `var` or `==`. In Dart all of that nonsense has been removed.
* Typescript has `interface` and `class` which is needlessly confusing (it has no choice because Javascript).
* It's way too easy to give up on typing in Typescript. It has a setting "no implicit `any`" but it doesn't seem to be comprehensive. You can do still stuff like just omitting the return type of functions and then they instantly lose all type information. In Dart you have to explicitly opt in to `dynamic`.
* Because types are added to Javascript libraries (via DefinitelyTyped), there's nothing that really checks that they are correct and very often they are just wrong. It's pretty annoying to fix when that happens and even harder to know what the correct fix is because obviously the underlying Javascript library has no types! You basically have to ask the authors what they meant.
* A lot of libraries aren't fully typed. For example Vue has very minimal typing - lots of things are just strings. As a concrete example, AngularDart gives you compile errors if the types in your HTML template are incorrect. With Vue they are runtime errors.
* The Dart VSCode extension is literally amazing. It gives you perfect errors and completion and it does it instantly. Nothing else I've used comes close.
When I first started using Typescript I was kind of under the impression that it was a better language built on top of Javascript. That's not really the case - it's still Javascript, it's just a slightly less insane way of using Javascript.
Typescript has `interface` and `class` which is needlessly confusing
Java and C# have had a distinction between `interface` and `class` for decades. It shouldn't be that confusing? One describes a shape or a contract of an object and the other an implementation of a kind of object (which in turn might support multiple interface shapes/contracts). It's not something unusual to OOP languages with type systems. Perhaps the only thing to complain about Typescript interfaces is that they are far more on the shape side of things than the contract side of things, and it is tough to rely on them if you want more of the contract semantics (because the language can't enforce that contract).
It's way too easy to give up on typing in Typescript. It has a setting "no implicit `any`" but it doesn't seem to be comprehensive
Typescript gets as comprehensive as you want it to be. It's set of checks is an onion design to allow for various control needs, especially because projects may need to opt-in to only some of the checks in order to ease migration. If you want all the checks the flag to pass isn't `--noImplicitAny` it is `--strict` (or in tsconfig.json, "strict": true). I recommend that for all greenfield projects and most brownfield projects if they don't mind fixing lots of compile errors (for the betterment of their project).
Because types are added to Javascript libraries (via DefinitelyTyped), there's nothing that really checks that they are correct
Not all type information is from DefinitelyTyped anymore, and in many ways DT is smaller than it was at its peak. More and more libraries on npm themselves are written in Typescript and provide their own type information fresh out of the Typescript compiler itself. Even libraries that aren't written in Typescript are taking maintenance ownership of their Typescript types themselves and sometimes the JS authors are right there critiquing their own types.
There will always be a mismatch between untyped JS and what Typescript types represent of that world, but it is better than it used to be, and better all the time.
I don't really like Dart, but I put up with it in order to use Flutter, which is awesome.
Dart is basically ES6&(TypeScript|Flow), but randomly slightly different, and usually in a way that makes it slightly weaker or more Java-eque, neither of which I prefer.
Basically it's not different enough from ES6 (plus a typing system) to be useful, just different enough to be annoying.
To be fair they're not always that easily accessible on React Native either. A lot of the times they seem to break stuff in weird ways, if they work at all.
They're inherently similar. Both highly verbose and quite object oriented. Dart is less flexible and arguably less advanced, but unlike Typescript, it's sound (as in type soundness). For a very specific target (mobile) being a bit less advanced is completely fine, it has all the abstractions needed for mobile development.
Immutability is leveraged extensively in Flutter. That said, functional programming is a struggle with Dart. Although it's not particularly well suited to Typescript either. Some specific things like async stuff are better in Dart/Flutter. As Dart adheres more strongly to classes/inheritance its facilities for that are more extensive.
Dart is perhaps more Java-ish while Typescript is more C#-ish, if that makes sense.
Flutter's strength is certainly not the language, it's the SDK/platform. It's miles ahead React Native in my experience.
I think it is really comparable to TypeScript. I do miss (sometimes) Union operators (I know there are some ways to add that to Dart). And as a JS/TS dev first, some things about Dart drive me a bit bonkers - like their array methods and how some of them return void and some of them return a new array. Like forEach vs. map, but at least those two make sense. Some of the ones in Dart don't feel like they make sense, at least to me.
It's been ok for me, feels a bit half-baked in many places (i.e. enums, serialization, constructors, collection manipulation), especially coming from a well thought-out language like Swift or Kotlin. Apparently null safety and extensions are coming which is good. On the other hand it's surprisingly straightforward and simple, more so then Typescript. It has basic OOP, type system, generics, closures & co, all the things you know and need, nothing too fancy, just a good subset for productivity.
The real magic is Flutter though, and outside of that, not sure if Dart has many applications. Dart on Node could be a thing, but seems like more of a hassle right now.
Any language/toolchain that compiles to both native Android and native iOS is going to be a blessing, regardless of the features at the language-level.
Dart always seems to lag behind TypeScript, for example a lot of the built-in functions return dynamic type because they don't have utility types yet.
Personally I'm frustrated Google is investing so much in Dart/Java platform while Rust is far more promising but has a small fraction of manpower dedicated to it.
Comments
What are people's impression of Dart as a language, compared to e.g. Typescript? Reviews so far seems lackluster. Does Dart have anything that sets it apart from JS, like immutable data structures out of the box? How's the support for functional programming, e.g. first order functions, closures, higher order functions like map, filter, reduce, etc?
How advanced is the typing system, are we talking Java level or significantly more powerful?
Full disclosure: Google employee
As an engineer that's written a lot of (old-skool) JS, Java, Obj-C, C++, and PHP, it is a real pleasure to develop web frontends with Dart.
Immutable Data Structures: Not out-of-the-box but we use the BuiltValue[0]/BuiltCollection[1] libraries extensively internally Functional Programming: Dart's Iterable[2] and Stream[3] classes have all the standard higher-order functions, like map, filter/where, reduce, fold, etc. Type System: With Dart 2.0[4], the type system is really great. Expressive with good type-inference, support for generic types, mixins, & typedefs. It's actually better than Java, IMO.
Also, the async story is fantastic! JS has caught up with Dart in some areas recently but Futures, Streams, async/await, & async*/yield, have long been first-class members of the Dart language.[5]
[0]: https://github.com/google/built_value.dart [1]: https://github.com/google/built_collection.dart [2]: https://api.dartlang.org/stable/2.7.0/dart-core/Iterable-cla... [3]: https://api.dartlang.org/stable/2.7.0/dart-async/Stream-clas... [4]: https://dart.dev/dart-2 [5]: https://dart.dev/codelabs/async-await
How would you compare Dart to Kotlin, in both typing system and functional programming support?
As a programmer with experience in C++, Java, Ruby, and Javascript, and someone who just wants to get things done, I love Dart.
In its syntax, its very similar to classic languages like C++ and Java. It's very easy to pass functions around, like Javascript/Ruby. I didn't really need to 'learn' it, it all seemed familiar from the beginning. It also has some nice little shortcuts, like null-safe member function calls.
As for the typing system, it is definitely compiled/typed, which I like, but it does not feel overbearing. I find it to be in a nice sweet spot between hard to refactor/you need unit tests for everything (ruby/javascript) and hard/wordy to write because the type system is too strict (C++/Java).
It also has a nice packaging system (like ruby/javascript), and it has been thoughtful about how you reference packages.
Overall, I like it a lot.
I've used both recently, deciding between them. Dart is better.
* Typescript is much more popular, and integrates with other Javascript things better. There are way more libraries available for Typescript.
* Typescript has proper support for non-null types, whereas in Dart everything is nullable (though they are fixing it, as announced here).
* Typescript has pretty nice support for anonymous sum types (i.e. `number | string`).
However:
* Typescript doesn't actually fix any of the insanity of Javascript - it just describes it. So you can still do insane things like using `var` or `==`. In Dart all of that nonsense has been removed.
* Typescript has `interface` and `class` which is needlessly confusing (it has no choice because Javascript).
* It's way too easy to give up on typing in Typescript. It has a setting "no implicit `any`" but it doesn't seem to be comprehensive. You can do still stuff like just omitting the return type of functions and then they instantly lose all type information. In Dart you have to explicitly opt in to `dynamic`.
* Because types are added to Javascript libraries (via DefinitelyTyped), there's nothing that really checks that they are correct and very often they are just wrong. It's pretty annoying to fix when that happens and even harder to know what the correct fix is because obviously the underlying Javascript library has no types! You basically have to ask the authors what they meant.
* A lot of libraries aren't fully typed. For example Vue has very minimal typing - lots of things are just strings. As a concrete example, AngularDart gives you compile errors if the types in your HTML template are incorrect. With Vue they are runtime errors.
* The Dart VSCode extension is literally amazing. It gives you perfect errors and completion and it does it instantly. Nothing else I've used comes close.
When I first started using Typescript I was kind of under the impression that it was a better language built on top of Javascript. That's not really the case - it's still Javascript, it's just a slightly less insane way of using Javascript.
Dart, on the other hand is a better language.
Java and C# have had a distinction between `interface` and `class` for decades. It shouldn't be that confusing? One describes a shape or a contract of an object and the other an implementation of a kind of object (which in turn might support multiple interface shapes/contracts). It's not something unusual to OOP languages with type systems. Perhaps the only thing to complain about Typescript interfaces is that they are far more on the shape side of things than the contract side of things, and it is tough to rely on them if you want more of the contract semantics (because the language can't enforce that contract).
Typescript gets as comprehensive as you want it to be. It's set of checks is an onion design to allow for various control needs, especially because projects may need to opt-in to only some of the checks in order to ease migration. If you want all the checks the flag to pass isn't `--noImplicitAny` it is `--strict` (or in tsconfig.json, "strict": true). I recommend that for all greenfield projects and most brownfield projects if they don't mind fixing lots of compile errors (for the betterment of their project).
Not all type information is from DefinitelyTyped anymore, and in many ways DT is smaller than it was at its peak. More and more libraries on npm themselves are written in Typescript and provide their own type information fresh out of the Typescript compiler itself. Even libraries that aren't written in Typescript are taking maintenance ownership of their Typescript types themselves and sometimes the JS authors are right there critiquing their own types.
There will always be a mismatch between untyped JS and what Typescript types represent of that world, but it is better than it used to be, and better all the time.
That's not the case: http://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABFAp...
I stand corrected. Must have been thinking of something else.
I don't really like Dart, but I put up with it in order to use Flutter, which is awesome.
Dart is basically ES6&(TypeScript|Flow), but randomly slightly different, and usually in a way that makes it slightly weaker or more Java-eque, neither of which I prefer.
Basically it's not different enough from ES6 (plus a typing system) to be useful, just different enough to be annoying.
Also different enough to make none of the libraries in the huge js ecosystem readily accessible.
To be fair they're not always that easily accessible on React Native either. A lot of the times they seem to break stuff in weird ways, if they work at all.
They're inherently similar. Both highly verbose and quite object oriented. Dart is less flexible and arguably less advanced, but unlike Typescript, it's sound (as in type soundness). For a very specific target (mobile) being a bit less advanced is completely fine, it has all the abstractions needed for mobile development.
Immutability is leveraged extensively in Flutter. That said, functional programming is a struggle with Dart. Although it's not particularly well suited to Typescript either. Some specific things like async stuff are better in Dart/Flutter. As Dart adheres more strongly to classes/inheritance its facilities for that are more extensive.
Dart is perhaps more Java-ish while Typescript is more C#-ish, if that makes sense.
Flutter's strength is certainly not the language, it's the SDK/platform. It's miles ahead React Native in my experience.
Take a look at some samples to get a grasp on how it looks like: https://dart.dev/guides/language/language-tour
I think it is really comparable to TypeScript. I do miss (sometimes) Union operators (I know there are some ways to add that to Dart). And as a JS/TS dev first, some things about Dart drive me a bit bonkers - like their array methods and how some of them return void and some of them return a new array. Like forEach vs. map, but at least those two make sense. Some of the ones in Dart don't feel like they make sense, at least to me.
It's been ok for me, feels a bit half-baked in many places (i.e. enums, serialization, constructors, collection manipulation), especially coming from a well thought-out language like Swift or Kotlin. Apparently null safety and extensions are coming which is good. On the other hand it's surprisingly straightforward and simple, more so then Typescript. It has basic OOP, type system, generics, closures & co, all the things you know and need, nothing too fancy, just a good subset for productivity.
The real magic is Flutter though, and outside of that, not sure if Dart has many applications. Dart on Node could be a thing, but seems like more of a hassle right now.
Any language/toolchain that compiles to both native Android and native iOS is going to be a blessing, regardless of the features at the language-level.
C can do that and few would argue it is a blessing. ;)
(Also, Xamarin and C# wave hello from the other room.)
Less than Java, while doing the @Override mistake instead of doing a proper keyword.
Dart always seems to lag behind TypeScript, for example a lot of the built-in functions return dynamic type because they don't have utility types yet.
Personally I'm frustrated Google is investing so much in Dart/Java platform while Rust is far more promising but has a small fraction of manpower dedicated to it.
Cough, Dart/Kotlin.