On Tue, Oct 6, 2015 at 12:55 AM, 'Erik Ernst' via Dart Misc <
Post by 'Erik Ernst' via Dart MiscOn Tue, Oct 6, 2015 at 9:19 AM, 'Lasse R.H. Nielsen' via Dart Misc <
Post by 'Lasse R.H. Nielsen' via Dart MiscOn Mon, Oct 5, 2015 at 6:33 PM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart MiscOn Mon, Oct 5, 2015 at 9:26 AM, 'Erik Ernst' via Dart Misc <
Post by 'Erik Ernst' via Dart MiscSure, but that violates the spec which means that is a bug.
But a bug in the spec, or in DDC? ;)
Hi Bob,
it could have been a bug in the spec if nobody had noticed this and nobody
had implemented the specified semantics, but I think you will find it
difficult to support that interpretation.
Just because it's *deliberate*, that doesn't imply that it's necessarily
useful or the best thing for our users.
Post by 'Erik Ernst' via Dart MiscNeither. It's just DDC not implementing the Dart spec.
Post by 'Lasse R.H. Nielsen' via Dart MiscThe language of DDC is not Dart. It's close, but it's not Dart, and
that's not a bug, it's a feature.
Hi Lasse,
agreed, that's one way to explain the situation. But the point is that
programmers need the language to be well-defined, and the purpose of
specifying a language is exactly that.
Sure, being well-defined is a useful property. But *what* we have defined
has not gotten us piles of users so I think it's pretty clear we need to
change. Defining an unappealing language very precisely is not a strategy
that gets you millions of users. If it was, we'd all be writing SML or
Oberon all day.
If the spec is unwilling to move, I am fine with at least having the
*implementation* move towards something users want. At least *something* is
getting better then.
If the language has an only-approximately-determined semantics then nobody
Post by 'Erik Ernst' via Dart Misccan write a reusable library and expect it to work "in general", it will
have to be tested from scratch with each variant of the language (which
could then mean: each compiler, each analyzer, etc.).
We do that anyway. No bigints in dart2js. Various "dart:" libraries not
available on some implementations. Operating system differents in
"dart:io". Bugs in the different implementations. We've also had the need
to test libraries on a variety of configurations because it turns out
implementation do vary in reality whether the spec acknowledges that or not.
makes -> would make.
Post by 'Erik Ernst' via Dart MiscPost by 'Lasse R.H. Nielsen' via Dart MiscCurrently it does not, not in Dart. It wouldn't mind changing that, but
it's a breaking change, so we will ... need to fight for it.
That's the most serious problem, as I see it: It is a breaking change that
will potentially change the behavior of programs in hundreds of locations
per library. That's the reason why I'm advocating new syntax for the new
semantics. I want that semantics, too! ;)
Consider two sets:
1. The set of Dart "var" declarations where the variable is assigned a
different type from its initializer.
2. The set of "var" declarations in C#, Scala, TypeScript, Kotlin, Flow,
and Swift where inference happens and teaches users to expect it.
We have empirical data from DDC that the first set is smaller than you
might think. Many existing Dart libraries require no or very few changes to
be error-free in strong mode. For example, the markdown package, which uses
"var" heavily and is older than strong mode, DDC, and, hell, even dart2js,
only required one declaration change
<https://github.com/dart-lang/markdown/commit/2b8c4dbf18b5767aa9099b850bc634e57c5c2951#diff-301b527486e5d4e69a16a86fe03f6db2R141>
to be error free. (The other change in that commit is a place where type
inference pointed out a place where the code was straight up designed wrong
and exposed a potential nasty type error in its public API.)
Meanwhile, the second set is *dramatically* larger. As a rough
approximation, in 2014/Q4 <http://githut.info/> (almost a year ago), there
were 83,263 GitHub repos written in C#, Scala, TypeScript, or Swift. Dart
had 1,957. Dart had 2% of the number of repos in languages where "var"
means inference.
If you consider that most "var" declarations in Dart are actually fine if
you treat them as inferred, that number gets even smaller. The set of code
locations where "var" deliberately does *not* work with inference is so
vanishingly tiny, it's not worth introducing an additional unfamiliar
syntax to preserve them.
Let's work towards getting support for inferred type annotations, in a way
Post by 'Erik Ernst' via Dart Miscthat doesn't potentially break all existing programs! ;-)
+1 for minimizing breakage.
Fortunately, we have a very graceful migration path.
1. Run dartanalyzer --strong on your library.
2. Fix the errors where a "var" variable changes type.
3. Once enough libraries have gone through this transition, make strong
mode the default.
We are *already* doing this for a number of packages, and an increasingly
large set of internal teams at Google.
We have all the syntax we need, we just need to use it the way users expect.
â bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.