8 ms·
To me Dart is pretty disappointing. Modern languages like Swift and Rust have shown the power of incorporating functional features like sum types and pattern ma
by danite 7y ago
To me Dart is pretty disappointing. Modern languages like Swift and Rust have shown the power of incorporating functional features like sum types and pattern matching. Dart just feels like the same sort of OO language we've been getting since Java became popular.
Edit: Also the continued existence of null in new programming languages is a baffling choice to me.
- markdog12 7y agoI don't blame you for being underwhelmed. The original goal was an easy to learn language. But since Dart 2.0 was completed, they are working on adding many other language features, including NNBD (Non-null by default). https://github.com/dart-lang/language/issues https://github.com/dart-lang/language/issues
- 0x8BADF00D 7y agoIt’s just hard to be productive in Dart. The Flutter IDE and simulators were so resource intensive, they literally locked up my laptop the last time I tried using them. Dart is objectively a terrible language to be productive in for app development. The abstractions provided by the language are clunky to use for window elements on a device screen. Don’t get me started on Material Design, either. Swift, Objective-C/C++, or even Java is way easier to start building apps with, in comparison. The tooling is mediocre for Dart as well.
- filleduchaos 7y agoI'm not sure what you mean by Flutter IDE and simulators, as the SDK has neither.
- Kiro 7y agoWhat's wrong with null?
- coldtea 7y agoA null is not a string or an integer or a MyClass instance, etc. So why does it pollute variables of all those types? https://medium.com/@hinchman_amanda/null-pointer-references-the-billion-dollar-mistake-1e616534d485 https://medium.com/@hinchman_amanda/null-pointer-references-... https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare https://www.infoq.com/presentations/Null-References-The-Bill... https://www.quora.com/Why-was-the-Null-Pointer-Exception-in-Java-called-a-billion-dollar-mistake https://www.quora.com/Why-was-the-Null-Pointer-Exception-in-... https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/ https://www.lucidchart.com/techblog/2015/08/31/the-worst-mis...
- Kiro 7y agoThanks. Stupid question but consider the following: entity = Entity.fetch(id) if (!entity) doSomething() Entity.fetch returns null if it doesn't find anything. How would this work without null?
- wtetzner 7y agoThe real problem isn't null itself, it's that in most languages that have it, null inhabits all types (or at least all reference types). Different languages solve this problem in different ways. Many languages get rid of null entirely, and use option types in its place. Other languages, like Kotlin, fix it in the type system, by differentiating between e.g. String and nullable String (spelled String? in Kotlin) .
- ptx 7y agoYou would still have null, but only when asked for and checked explicitly. In Kotlin, for example, you mark something with a question mark to say that it can be null, which forces you to check for null before using it: val entityOrPossiblyNull: Entity? = Entity.fetch(id) if (entityOrPossiblyNull == null) { doSomething() } else { // The compiler knows that the variable is not null in this branch, // so this assignment is OK. val entityForSure: Entity = entityOrPossiblyNull doSomethingWithEntity(entityForSure) }
- munificent 7y agoHi, I work on Dart. > functional features like sum types and pattern matching "Functional features" means different things to different people. Dart (like most modern languages) has a lot of the core functional features: first-class functions, closures, lambdas, higher-order functions. Our built-in collection libraries are heavily oriented around functional-style transformations. You don't need an external library to map() and filter() your lists to your heart's content. At the type system level, we also have function types, generic functions, and even first-class generic functions, which is a really unusual, powerful feature. Sum types are a slightly different beast. Sum types are basically a functional language's answer to subtyping and runtime polymorphism. But object-oriented languages already have full subtyping and polymorphism using classes. There's a sort of zen koan here where algebraic datatypes are a poor man's subclasses and subclasses are a poor man's algebraic datatypes. The way most multi-paradigm languages like Scala and Kotlin handle this is that sum types are just syntactic sugar for defining a little class hierarchy. Likewise, pattern-matching becomes syntax sugar for instanceof checks and field access. I like that sugar and hope we can add something similar to Dart, but I don't find it's omission to be a profound oversight. It makes some kinds of code nicer, but doesn't significantly affect the expressiveness or capability of the language. > Dart just feels like the same sort of OO language we've been getting since Java became popular. Yeah. The original designers of the language designed something very conservative. I think they wanted to make a VM with certain features (single dispatch, static class structure, no static initialization, etc.), and designed the safest language they could come up with to let them do that. There is a lot of benefit to familiarity. I like classes and C-family syntax, and we see very clearly that Dart is really easy for people to learn and become productive in. We've done user studies where participants have been able to write correct Dart code without knowing what language they were using. It's hard to underestimate the value of that. But there is also value in providing the modern tools people want in order to write clean, beautiful, correct, maintainable code. Dart has some catching up to do there. We're making a lot of progress. With Dart 2.0, we replaced the old unsound optional type system with a real, modern, expressive, sound static type system. It was a ton of work to do that while dealing with millions of lines of existing code. We didn't get all the type system features we wanted, but we have a foundation we can build on now. The optional type system had some nice properties, but was effectively a dead end. When your types are optional, you can't hang any language semantics off them. That takes lots of features off the table: implicit conversions, extension methods, etc. > Also the continued existence of null in new programming languages is a baffling choice to me. I have always believed [0] that not having non-nullable types was a mistake in Dart 1.0. We are fixing it now: https://github.com/dart-lang/language/blob/master/working/0110-incremental-sound-nnbd/roadmap.md https://github.com/dart-lang/language/blob/master/working/01... There's a lot of work to do, but I'm really excited with the design. Unlike many other languages, we have something that becomes fully sound with respect to null errors. This means that once a program is fully migrated, a compiler will be able to take advantage of non-nullable types for performance optimizations. It will be quite a while before we get to the point where we can do this, but it's cool that that's on the table. [0]: http://journal.stuffwithstuff.com/2011/10/29/a-proposal-for-null-safety-in-dart/ http://journal.stuffwithstuff.com/2011/10/29/a-proposal-for-...
- kitsunesoba 7y agoIndeed, Flutter would be much more compelling if I could use it with Rust or Swift instead. Dart really doesn’t interest me.
- IshKebab 7y agoOne nice think about Dart I've found is that compile times are very fast (faster than Go) and when editing in VSCode the code intelligence is instant and 100% accurate in my experience. Compare that to Rust where compilation speed is almost as bad as C++, RLS is slower than e.g. Qt Creator's clang lints, and has auto-completions so innaccurate that they are almost worse than nothing. Buuut.... I wanted to make a deep copy of an object (a map of maps) in Dart, and one of the suggestions on Stackoverflow is to serialise it to JSON and then deserialise it. Eek. In C++ you just do `auto a = b;`. In Rust `let a = b.clone();`. How do they leave out such basic functionality? https://stackoverflow.com/a/26616081/265521 https://stackoverflow.com/a/26616081/265521
- munificent 7y ago> In C++ you just do `auto a = b;`. Sure, but does it do what you want? :) If that map contains pointers or other types with "interesting" assignment semantics, then your idea of a deep copy and that author of that type's idea may not be the same. Cloning is a surprisingly hard problem. The two languages you compare to don't have GCs and prefer value semantics. But in most GC languages, everything is by reference and "copying the bits" isn't as meaningful of an operation. I looked up how to deep clone maps in some other GC languages: https://stackoverflow.com/questions/4157399/how-do-i-copy-a-hash-in-ruby https://stackoverflow.com/questions/4157399/how-do-i-copy-a-... Ruby: Top suggestion is to marhsall/unmarshall it. https://stackoverflow.com/questions/5105517/deep-copy-of-a-dict-in-python https://stackoverflow.com/questions/5105517/deep-copy-of-a-d... Python: Import a separate "copy" module. May have to implement some custom methods if you use user-defined objects in the map. The module isn't thread-safe. A comment recommends converting to JSON and back. https://stackoverflow.com/questions/28288546/how-to-copy-hashmap-not-shallow-copy-in-java/28288729 https://stackoverflow.com/questions/28288546/how-to-copy-has... Java: No built in solution. Have to traverse the map yourself and do element-wise copies.