top | item 19748982

(no title)

danite | 6 years 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.

discuss

order

markdog12|6 years ago

I 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

0x8BADF00D|6 years ago

It’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.

munificent|6 years ago

Hi, 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/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-...

mixedCase|6 years ago

> It makes some kinds of code nicer, but doesn't significantly affect the expressiveness or capability of the language.

Sum types and exhaustive pattern matching aren't about expressiveness, they're tools for aiding code comprehension by increasing the locality of code that has no business being distributed into completely different classes, and decreasing the cost of making changes by heavily reducing the amount of test code that needs to be written to make sure a closed set of options is handled appropiately; in OOP languages you can get this by using interfaces but to make use of it you'd have to use huge classes with methods pertaining to every usage of this closed set.

I would never willingly pick up another language that doesn't provide me with them after experiencing the productivity gains. I really like the direction Dart is moving towards and the steps taken demonstrate there's a team behind it that cares about correctness and productivity over being just a familiar Java-like, but this is the one hard blocker for me.

kitsunesoba|6 years ago

Indeed, Flutter would be much more compelling if I could use it with Rust or Swift instead. Dart really doesn’t interest me.

IshKebab|6 years ago

One 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