'Bob Nystrom' via Dart Misc
2015-09-04 16:51:14 UTC
That thread about the language meeting notes is huge, so I'm going to split
my responses into separate threads. If we could move discussions to these,
that would be swell.
Here's my personal thoughts about putting types on the right:
It is strictly more verbose than the current syntax... *when you use it.* In
practice, I think Dart 2.0 should come with a much better promise of type
inference and let users reliably omit type annotations on locals. When you
do that, most of your variable declarations will just be:
var a = someValue...
No type on the right *or* left. :)
When you do want a type annotation, for things like top-level variables,
fields, and parameters, I personally like it on the right and also like ":"
even though it's a bit more verbose. Maybe it's just me, but it helps me
separate out the variable name from the type. I'd also be fine with Go's
approach and eliminating the ":".
The biggest problem (aside from migration, which we would *absolutely*
provide automated tooling for) is unfamiliarity. That is a real issue. I'd
like to be believe it isn't insurmountable, though. TypeScript, Scala,
Haskell, Kotlin, and Swift all use "name : Type" syntax.
Optional type annotation systems for Python
<https://www.python.org/dev/peps/pep-0484/>, Ruby <http://www.mirah.org/>,
JavaScript <http://flowtype.org/>, PHP <http://hacklang.org/> all use this
syntax. As far as I can tell, it is the standard way to add optional type
annotations to a language.
Here's another tiny data point. The new UX for our API documentation
<https://api.dartlang.org/1.12.0/dart-async/Future-class.html> puts return
types of methods after the method name. In the original dartdoc, I got a
lot of feedback that it was hard to find member names when scanning a list
of members if the return type was on the left. Pushing them to the right
does help readability in this case.
So, personally, I feel doing this would lead to a simpler, easier to extend
grammar. And it would follow in the footsteps of almost every
dynamically-typed with optional annotations language that also use "name :
Type" syntax.
Cheers!
- bob
my responses into separate threads. If we could move discussions to these,
that would be swell.
Here's my personal thoughts about putting types on the right:
It is strictly more verbose than the current syntax... *when you use it.* In
practice, I think Dart 2.0 should come with a much better promise of type
inference and let users reliably omit type annotations on locals. When you
do that, most of your variable declarations will just be:
var a = someValue...
No type on the right *or* left. :)
When you do want a type annotation, for things like top-level variables,
fields, and parameters, I personally like it on the right and also like ":"
even though it's a bit more verbose. Maybe it's just me, but it helps me
separate out the variable name from the type. I'd also be fine with Go's
approach and eliminating the ":".
The biggest problem (aside from migration, which we would *absolutely*
provide automated tooling for) is unfamiliarity. That is a real issue. I'd
like to be believe it isn't insurmountable, though. TypeScript, Scala,
Haskell, Kotlin, and Swift all use "name : Type" syntax.
Optional type annotation systems for Python
<https://www.python.org/dev/peps/pep-0484/>, Ruby <http://www.mirah.org/>,
JavaScript <http://flowtype.org/>, PHP <http://hacklang.org/> all use this
syntax. As far as I can tell, it is the standard way to add optional type
annotations to a language.
Here's another tiny data point. The new UX for our API documentation
<https://api.dartlang.org/1.12.0/dart-async/Future-class.html> puts return
types of methods after the method name. In the original dartdoc, I got a
lot of feedback that it was hard to find member names when scanning a list
of members if the return type was on the left. Pushing them to the right
does help readability in this case.
So, personally, I feel doing this would lead to a simpler, easier to extend
grammar. And it would follow in the footsteps of almost every
dynamically-typed with optional annotations language that also use "name :
Type" syntax.
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
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
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.