4 ms·
I've worked on Dart and Flutter last year on a startupish project. I can say flutter is amazing. It got good ideas from react architecture (eg: managing state a
by h8hawk 7y ago
I've worked on Dart and Flutter last year on a startupish project. I can say flutter is amazing. It got good ideas from react architecture (eg: managing state and declarative UI) and add many good things like very rich and well designed API. writing UI in language and without other markup language like XML is amazing. You also save a lot of cost to developing in parallel for multiple platform's.
Dart is also a pleasant language, here are some pros and cons about language.
pros:
1- Everything is object. (no more inconsistencies like Java primitives, null and generics)
2- It has very well designed generics and you can access generic type in run time.
3- Good Type inference.
4- Has powerful facilities for asynchronous programming.(eg: async await, coroutines ,...)
5- Not overall bad or complex type system. Compare to Golang or java dart's type system is vastly superior.
some cons:
1- Everything can be null (null is also object).
2- Lack of Union and algebraic data types.
3- Lack of python's like tuple.(eg: (1,'string'))
4- I personally dislike C-style type definition and mandatory semicolon (eg: int foo=23; rather than foo : int=23 )
- thosakwe 7y agoAs for nulls, non-nullability is currently in the works: https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md https://github.com/dart-lang/language/blob/master/accepted/f...
- slimsag 7y agoserious question: how effectively can things like non-nullability be bolted onto a language after it and a large part of its ecosystem has been created? I see the plan to allow libraries to opt-in and migrate that way.. but I wonder how long that migration will take and if it will ever actually be completed?
- kuprel 7y agoIsn't a tuple just a const List? Also there is a set union function: https://api.flutter.dev/flutter/dart-core/Set/union.html https://api.flutter.dev/flutter/dart-core/Set/union.html
- cuddlecake 7y agoA tuple usually has different properties compared to a Tuple. For example, you can have a List of type List<string>, which would be a list of any length containing any string. On the other hand, a good tuple implementation (especially a typed one) could allow tuples like (string, integer, boolean), i.e. only arrays of length 3, where the first positions holds a string, the second position holds an integer and the third position holds a boolean. So yes, usually they are represented as arrays, but on a higher level, they are fundamentally different. As for unions, the parent comment is not referring to the Set operation, he's referring to Union Types. With this concept, a variable can be one of many types. For example: var input: string | number And at Runtime you would have to find out whether it is a string or a number, to be able to use it. (Not here arguing whether Dart does or does not have these language features, just trying to clarify this misunderstanding)
- kuprel 7y agoAh, thanks for explaining that
- rapind 7y agoSmall correction. For union types you cover all cases at compile (build) time, not at runtime. This is pretty valuable in catching bugs.
- cuddlecake 7y agoYes, that is basically correct, but I think your assertions that "you cover all the cases" and "valuable in catching bugs" are not correct. For example, in C, you can define a Union type that can hold either a string or an integer, declare a variable of that type and initialize it with a string, and then simply assert that it is an integer. I think that with your assertion of "valuable in catching bugs" you are referring to Sum Types (often called tagged unions). For Sum Types, if a language supports this concept, it usually also forces you to cover all cases at compile time, whereas with plain unions, you can shoot yourself in the foot, if you're willing to do so.