Discussion:
[dart-misc] Flutter style guide vs dart style guide
Don Olmstead
2015-11-30 18:59:05 UTC
Permalink
I've been enabling lints, http://dart-lang.github.io/linter/lints/, through
.analysis_options and seeing how my codebase does. I ran the flutter
specific ones and they seem to be in opposition to the standard practices
that have been pushed by the Dart team. I actually got out of the habit of
typing everything and moving to var but that seems to be something the
flutter team does not want to do. Is there a particular benefit to this if
I have a library that I would want to run in flutter?

Basically with this and strong mode I'm really not sure how my code should
look.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-11-30 20:51:40 UTC
Permalink
Post by Don Olmstead
I've been enabling lints, http://dart-lang.github.io/linter/lints/,
through .analysis_options and seeing how my codebase does. I ran the
flutter specific ones and they seem to be in opposition to the standard
practices that have been pushed by the Dart team. I actually got out of the
habit of typing everything and moving to var but that seems to be something
the flutter team does not want to do. Is there a particular benefit to this
if I have a library that I would want to run in flutter?
Basically with this and strong mode I'm really not sure how my code should
look.
Our story around inference, type annotating locals, and strong mode is
still kind of in flux. I see teams adopt a variety of styles and the style
guide is kind of flexible right now to accommodate that.

We are seeing a lot of teams adopting strong mode, and even more people
pushing for better, more reliable type inference. So, my hope is that
before long we can get to a point where users can use "var" and confidently
rely on rock solid inference to get a high quality static analysis story.

I think we're (finally!) making fast progress in that direction, but it
will take a while for all of the pieces to settle.

Cheers!

– 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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2015-11-30 20:56:20 UTC
Permalink
Sounds great!
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Don Olmstead
2015-11-30 21:40:10 UTC
Permalink
I think the bigger surprise was that "as" was enough of an overhead that
they were avoiding it. Is it that dramatic a slowdown? I ask because I tend
to use it quite a bit especially when coding Polymer.dart.
Post by Günter Zöchbauer
Sounds great!
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-11-30 21:48:32 UTC
Permalink
Post by Don Olmstead
I think the bigger surprise was that "as" was enough of an overhead that
they were avoiding it. Is it that dramatic a slowdown? I ask because I tend
to use it quite a bit especially when coding Polymer.dart.
I don't know where their belief that there is a slowdown comes from. I've
never personally run into any noticeable performance impact using "as" in
the VM, nor have I heard anyone else mention it.

– 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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'John Messerly' via Dart Misc
2015-11-30 22:33:13 UTC
Permalink
On Mon, Nov 30, 2015 at 1:48 PM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
Post by Don Olmstead
I think the bigger surprise was that "as" was enough of an overhead that
they were avoiding it. Is it that dramatic a slowdown? I ask because I tend
to use it quite a bit especially when coding Polymer.dart.
I don't know where their belief that there is a slowdown comes from. I've
never personally run into any noticeable performance impact using "as" in
the VM, nor have I heard anyone else mention it.
FWIW, I heard it from the folks working on Dart Analyzer as well.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Srdjan Mitrovic' via Dart Misc
2015-11-30 23:37:41 UTC
Permalink
On Mon, Nov 30, 2015 at 5:33 PM, 'John Messerly' via Dart Misc <
Post by 'John Messerly' via Dart Misc
On Mon, Nov 30, 2015 at 1:48 PM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
Post by Don Olmstead
I think the bigger surprise was that "as" was enough of an overhead that
they were avoiding it. Is it that dramatic a slowdown? I ask because I tend
to use it quite a bit especially when coding Polymer.dart.
I don't know where their belief that there is a slowdown comes from. I've
never personally run into any noticeable performance impact using "as" in
the VM, nor have I heard anyone else mention it.
FWIW, I heard it from the folks working on Dart Analyzer as well.
'as' is not free, as it involves a type test at runtime. In some cases the
test can be eliminated by the optimizing compiler, in some cases (testing
against a leaf class) the test can be quite fast. But sometimes it can be
quite costly (polymorphic tests, generics involved, ...). My recommendation
is to assume that 'as' has a runtime performance impact.

- Srdjan
Post by 'John Messerly' via Dart Misc
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Don Olmstead
2015-11-30 23:46:49 UTC
Permalink
@Srdjan is there a way to avoid that? In Polymer its pretty common to do
something like

factory FooElement() =>
new Element.tag('foo-element') as FooElement;
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Gilad Bracha' via Dart Misc
2015-11-30 23:50:08 UTC
Permalink
While "as" does entail a runtime cost, the real question is whether that
cost is significant for your application. I am not aware of any evidence
that would indicate that using "as" in moderation matters to overall
application performance.
Post by Don Olmstead
@Srdjan is there a way to avoid that? In Polymer its pretty common to do
something like
factory FooElement() =>
new Element.tag('foo-element') as FooElement;
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Don Olmstead
2015-11-30 23:59:20 UTC
Permalink
The Polymer example is pretty unlikely to become hot but I have other cases
where I use "as" to quiet the strong mode analysis, like when working with
a Map from JSON, that could potentially be hot. I don't think there's a
case where I use "as" where I'm not certain that it is the thing. There's
also the using "as" after an "is" check that I use quite a bit.

On Mon, Nov 30, 2015 at 3:50 PM, 'Gilad Bracha' via Dart Misc <
Post by 'Gilad Bracha' via Dart Misc
While "as" does entail a runtime cost, the real question is whether that
cost is significant for your application. I am not aware of any evidence
that would indicate that using "as" in moderation matters to overall
application performance.
Post by Don Olmstead
@Srdjan is there a way to avoid that? In Polymer its pretty common to do
something like
factory FooElement() =>
new Element.tag('foo-element') as FooElement;
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2015-12-01 00:48:35 UTC
Permalink
With respect to perf, you might benchmark if you're worried. The "as" may
have a noticeable runtime cost, but it may also let a compiler better
optimize the subsequent code.

The Flutter team has asked us for a more general static cast (e.g., C++'s
with no runtime cost) to quiet strong mode - we're looking into how to best
do that.

Cheers,

Vijay
Post by Don Olmstead
The Polymer example is pretty unlikely to become hot but I have other
cases where I use "as" to quiet the strong mode analysis, like when working
with a Map from JSON, that could potentially be hot. I don't think there's
a case where I use "as" where I'm not certain that it is the thing. There's
also the using "as" after an "is" check that I use quite a bit.
On Mon, Nov 30, 2015 at 3:50 PM, 'Gilad Bracha' via Dart Misc <
Post by 'Gilad Bracha' via Dart Misc
While "as" does entail a runtime cost, the real question is whether that
cost is significant for your application. I am not aware of any evidence
that would indicate that using "as" in moderation matters to overall
application performance.
Post by Don Olmstead
@Srdjan is there a way to avoid that? In Polymer its pretty common to do
something like
factory FooElement() =>
new Element.tag('foo-element') as FooElement;
--
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
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-12-01 17:07:33 UTC
Permalink
On Mon, Nov 30, 2015 at 4:48 PM, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
The Flutter team has asked us for a more general static cast (e.g., C++'s
with no runtime cost) to quiet strong mode
assert(foo is Foo);

?

Though I guess that does require flow-sensitive analysis.

– 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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Don Olmstead
2015-12-01 18:30:49 UTC
Permalink
@Vijay I wasn't suggesting not profiling it it seemed as though the flutter
team did profile it since they have a rule against using "as". Having a
static cast equivalent would be great to have in the language.

On Tue, Dec 1, 2015 at 9:07 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
On Mon, Nov 30, 2015 at 4:48 PM, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
The Flutter team has asked us for a more general static cast (e.g., C++'s
with no runtime cost) to quiet strong mode
assert(foo is Foo);
?
Though I guess that does require flow-sensitive analysis.
– 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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2015-12-01 18:57:27 UTC
Permalink
Right. According to Srdjan, my comment about the compiler taking advantage
of an "as" to optimize, does not apply to the Dart VM.
Post by Don Olmstead
@Vijay I wasn't suggesting not profiling it it seemed as though the
flutter team did profile it since they have a rule against using "as".
Having a static cast equivalent would be great to have in the language.
On Tue, Dec 1, 2015 at 9:07 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
On Mon, Nov 30, 2015 at 4:48 PM, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
The Flutter team has asked us for a more general static cast (e.g.,
C++'s with no runtime cost) to quiet strong mode
assert(foo is Foo);
?
Though I guess that does require flow-sensitive analysis.
– 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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2015-12-01 18:57:49 UTC
Permalink
(Sent too soon :-))
Post by 'Vijay Menon' via Dart Misc
Right. According to Srdjan, my comment about the compiler taking
advantage of an "as" to optimize, does not apply to the Dart VM.
https://github.com/dart-lang/sdk/issues/25076
Post by 'Vijay Menon' via Dart Misc
Post by Don Olmstead
@Vijay I wasn't suggesting not profiling it it seemed as though the
flutter team did profile it since they have a rule against using "as".
Having a static cast equivalent would be great to have in the language.
On Tue, Dec 1, 2015 at 9:07 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
On Mon, Nov 30, 2015 at 4:48 PM, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
The Flutter team has asked us for a more general static cast (e.g.,
C++'s with no runtime cost) to quiet strong mode
assert(foo is Foo);
?
Though I guess that does require flow-sensitive analysis.
– 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
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Vijay Menon' via Dart Misc
2015-12-01 18:51:40 UTC
Permalink
On Tue, Dec 1, 2015 at 9:07 AM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
On Mon, Nov 30, 2015 at 4:48 PM, 'Vijay Menon' via Dart Misc <
Post by 'Vijay Menon' via Dart Misc
The Flutter team has asked us for a more general static cast (e.g., C++'s
with no runtime cost) to quiet strong mode
assert(foo is Foo);
?
Though I guess that does require flow-sensitive analysis.
That and, in cases like Don's example above, it's clunky to add a statement.
Post by 'Bob Nystrom' via Dart Misc
– 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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Kasper Peulen
2015-11-30 21:45:40 UTC
Permalink
That is good news Bob!

I've been thinking about your arguments about not using types, and with
strong mode not using types makes much more sense.

Only thing I really miss though, is more support of the editor, it should
quickly able to tell me what the type of a variable is.
Just by hovering some variable for example.

Maybe even some command, that could convert all untyped local variables to
typed local variables, and vice versa. Commit to git without types, but if
a dev prefers types, maybe for debugging or whatever, it can quickly get
all the types back.
Post by 'Bob Nystrom' via Dart Misc
Post by Don Olmstead
I've been enabling lints, http://dart-lang.github.io/linter/lints/,
through .analysis_options and seeing how my codebase does. I ran the
flutter specific ones and they seem to be in opposition to the standard
practices that have been pushed by the Dart team. I actually got out of the
habit of typing everything and moving to var but that seems to be something
the flutter team does not want to do. Is there a particular benefit to this
if I have a library that I would want to run in flutter?
Basically with this and strong mode I'm really not sure how my code
should look.
Our story around inference, type annotating locals, and strong mode is
still kind of in flux. I see teams adopt a variety of styles and the style
guide is kind of flexible right now to accommodate that.
We are seeing a lot of teams adopting strong mode, and even more people
pushing for better, more reliable type inference. So, my hope is that
before long we can get to a point where users can use "var" and confidently
rely on rock solid inference to get a high quality static analysis story.
I think we're (finally!) making fast progress in that direction, but it
will take a while for all of the pieces to settle.
Cheers!
– 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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-11-30 21:49:35 UTC
Permalink
Post by Kasper Peulen
That is good news Bob!
I've been thinking about your arguments about not using types, and with
strong mode not using types makes much more sense.
Only thing I really miss though, is more support of the editor, it should
quickly able to tell me what the type of a variable is.
Just by hovering some variable for example.
I totally agree. Adding Jamie and Devon to the thread for their thoughts on
IDE integration for this.

Cheers!

– 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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...