
A core Python committer's (very shallow) thoughts on Dart - vgnet
http://sayspy.blogspot.com/2012/05/my-very-shallow-thoughts-on-dart.html
======
damncabbage
_Dart views types as helpful documentation and a way to help tools assist with
things, period. I actually find it rather refreshing to have a language that
treats types as just documentation since that is really what they are for the
programmer_

But, just like documentation, if it gets out of date you're really wonked.

I'd prefer something that is both useful as documentation _and_ is used by the
compiler (a la Haskell's type classes).

~~~
kkowalczyk
It already is - you just have to run in checked mode.

~~~
numbsafari
I have to admit, there's some part of me that wants to think that "types as
documentation" is a good idea. But I have to go with the OP on this one... I
watched the Dart presentation from Lang.NEXT and laughed a bit to myself at
one point because even in the presenter's example, the "type documentation"
was already outdated. During his presentation it doesn't matter, because
everyone watching is in the context of the code as part of his discussion. But
if you put that code in front of somebody a year from now, out of context,
would they immediately pick up on it? Or will they be frustrated by the fact
that they expect the types to be what they say they are, but they aren't?

Are people really going to run in checked mode to verify their code? Or they
going to do what they do with compiler warnings and turn them off as soon as
they see one? I'm sure there will be a million blog posts titled "Dart Best
Practices" that will say "do not use checked mode, it slows down execution and
prints confusing messages". Of course, any bugs in checked mode will mean
people will need to get their production systems working by ignoring checked
mode.

I guess... my gut tells me that you should either have types, or not have
types. Being in the middle creates too many opportunities for cognitive
dissonance, too many opportunities for sneaky bugs, and too many opportunities
to keep having this debate. It's one of those things that seems really smart
and cool that, on a practical level, will probably turn out to be a complete
waste of time and a total distraction.

~~~
nl
_I guess... my gut tells me that you should either have types, or not have
types. Being in the middle creates too many opportunities for cognitive
dissonance, too many opportunities for sneaky bugs, and too many opportunities
to keep having this debate. It's one of those things that seems really smart
and cool that, on a practical level, will probably turn out to be a complete
waste of time and a total distraction._

The worlds collective programming experience doesn't really back that up.
Almost every language drops (or makes optional) type support when constructs
become too complicated, or they become so complicated no one can understand
them.

Languages with the best type systems (OCaml) aren't particularly popular,
while languages we think of as strongly typed (eg Java) have big backdoors to
allow people to bypass the type system.

On the other side, weakly typed languages are adding typing-like features by
integrating unit test facilities into the environment (which - optionally -
catch many of the bugs typing can help with).

Like so many things, optional typing might seem impure, but often messy
systems are the most robust.

~~~
pcwalton
Dart's optional typing is not common in languages at all. What you're
referring to is a combination of dynamic and static typing, which is not Dart-
style optional typing. In statically-typed languages, the dynamically-typed
values are clearly delimited in the source text and are not a compiler switch.

------
nl
Interesting, and very positive review.

Maybe it's my Java background coming through, but I _like_ the idea of Factory
constructors.

~~~
arethuza
Every time I read about Java developers and their love of Factories (and
Factory Factories) I think of this wonderful comment on Joel on Software:

<http://discuss.joelonsoftware.com/default.asp?joel.3.219431>

NB Factories are one of these things that _seem_ like a good idea in theory,
but often seem to end up with crazy levels of abstraction in practice.

~~~
fraserharris
A message I received from a friend working at Google:

"New layers, more layers, bigger layers, better layers, abstract layers,
injected layers, factory layers, module layers,
AbstractFactoryFactoryModuleBuilderInjector layers, layers upon layers within
layers wrapped in layers, a glorious spire of layers to reach the heavens and
bring renown to Babylon! Hellelujah!"

------
sp332
Single-inheritance, but interfaces can have default implementations? Isn't
that... multiple inheritance?

~~~
numbsafari
You can implement multiple interfaces on a single class, but only "inherit"
from a single implementation.

Or, perhaps more specifically, you can implement an interface without
extending its default implementation.

As the article states, the default implementations are there more so that you
can say "m = new Map()", instead of having to remember about this other thing
called "HashMap".

------
stcredzero
_they still went a little overboard in my opinion on some things (e.g. the
list interface has a last() method instead of supporting negative indexes)._

A last method is much more intention revealing and easier to scan for me than
negative indexes.

~~~
nevernude
Are you also a fan of list.first() over list[0]? I think it's just a
convention that takes getting used to and ends up being quite handy.

~~~
stcredzero
Have you seen some of the early Bittorrent code? Code with lots and lots of
this[n:-3] or this[1,:,:] sprinkled around in the same piece of code starts to
get like regexp or Perl. It's a cool operator to have to get stuff specified
in a few keystrokes, but that makes it quite terse, so high density use of it
is hard to read.

------
stcredzero
_...have done toy examples now in 18 languages...this is actually usually
enough for me to grasp the inspirations for a language and thus understand its
essence._

 _Usually_ is the dangerous word here. (Dangerous as in, "a little
knowledge.")

~~~
madhadron
Actually, that's the point when I stopped taking him seriously (though why
anyone in core Python should be taken seriously as a language designer I don't
know). 18? Come on. I've deployed projects in that many languages.

~~~
stcredzero
My point is more that in-depth knowledge in a number of languages is also
vital. The 18 toy examples is completely unimportant. Competency in core
Python is. I would look for such depth in one or two other languages.

------
vgnet
Some responses from the Dart team:
[https://plus.google.com/115362263245161504841/posts/82jKeP4Y...](https://plus.google.com/115362263245161504841/posts/82jKeP4YjbG)

