Dart language tour is complete (check it out!)

35 views
Skip to first unread message

Kathy

unread,
Apr 18, 2012, 3:37:24 PM4/18/12
to General Dart Discussion
Seth and I have just finished the Dart language tour:

http://www.dartlang.org/language-tour/

We tried to keep it short, useful, and focused on language features,
although we couldn't help but touch on a bit of the dart:core library.

The tour should be useful both for learning about the language and as
a reference for Dart idioms.

Please try it out and let us know whether it helped you, how we can
make it better, and what other docs and improvements to dartlang.org
you'd like to see.

Thanks!

-k-

Christian Grobmeier

unread,
Apr 18, 2012, 3:40:45 PM4/18/12
to Kathy, General Dart Discussion
I already skimmed it and it looks amazing. Congratulations!
Now... off for a detailled look

--
http://www.grobmeier.de
https://www.timeandbill.de

Seth Ladd

unread,
Apr 18, 2012, 3:46:02 PM4/18/12
to Christian Grobmeier, Kathy, General Dart Discussion
Thanks Christian. We'll add new features as implementations come online (like method cascades). Let us know what we can clear up for you.

Ladislav Thon

unread,
Apr 18, 2012, 4:11:07 PM4/18/12
to Kathy, General Dart Discussion
 http://www.dartlang.org/language-tour/


Map<String> pages = <String>{ // specify value type: String
    'index.html':'Homepage',  // (the key type is implicitly String)
    'robots.txt':'Hints for web robots',
    'humans.txt':'We are people, not machines' };

Map takes 2 type arguments, so this should read Map<String, String> pages = ... (the rest is OK).

LT

Kathy Walrath

unread,
Apr 18, 2012, 4:20:11 PM4/18/12
to Ladislav Thon, General Dart Discussion
When I tested this example in Dart Editor a few days ago, it gave me an error if I used two types.

-k-

Kathy Walrath

unread,
Apr 18, 2012, 4:21:13 PM4/18/12
to Ladislav Thon, General Dart Discussion
Oh wait... you mean the type of the variable, not the type of the literal... Oops. I'll fix that.

Thanks!

-k-

Bob Nystrom

unread,
Apr 18, 2012, 4:48:25 PM4/18/12
to Kathy Walrath, Ladislav Thon, General Dart Discussion
Better solution: get rid of the type annotations for those local variables completely. :) Just use "var" or "final".


var pages = <String>{ // specify value type: String

    'index.html':'Homepage',  // (the key type is implicitly String)
    'robots.txt':'Hints for web robots',
    'humans.txt':'We are people, not machines' };



- bob

Seth Ladd

unread,
Apr 18, 2012, 4:55:59 PM4/18/12
to Bob Nystrom, Kathy Walrath, Ladislav Thon, General Dart Discussion
I knew this would come up. :)  Kathy and I bounced back and forth on this. We felt that because many of these code samples are not in the context of a function, and because type inference hasn't appear yet for the Editor,  it was better to use type annotations.

If people feel really strongly about this, we can of course take a pass through the doc.

Christian Grobmeier

unread,
Apr 18, 2012, 5:07:39 PM4/18/12
to Seth Ladd, Bob Nystrom, Kathy Walrath, Ladislav Thon, General Dart Discussion
My 2 cents: I think types are fine. Ppl probably look often from a js
perspective on it. They might find it useful to see types (a new
feature) here. For me as Java dev it is common, but others probably
would like to see a good couple of examples with types. Letting them
go is easier than having them.

--
http://www.grobmeier.de
https://www.timeandbill.de

Mark Bennett

unread,
Apr 18, 2012, 5:11:23 PM4/18/12
to General Dart Discussion
Awesome work and a worthwhile introduction to Dart. Thanks!

On Apr 18, 3:07 pm, Christian Grobmeier <grobme...@gmail.com> wrote:
> My 2 cents: I think types are fine. Ppl probably look often from a js
> perspective on it. They might find it  useful to see types (a new
> feature) here. For me as Java dev it is common, but others probably
> would like to see a good couple of examples with types. Letting them
> go is easier than having them.
>
>
>
>
>
>
>
>
>
> On Wed, Apr 18, 2012 at 10:55 PM, Seth Ladd <sethl...@google.com> wrote:
> > I knew this would come up. :)  Kathy and I bounced back and forth on this.
> > We felt that because many of these code samples are not in the context of a
> > function, and because type inference hasn't appear yet for the Editor,  it
> > was better to use type annotations.
>
> > If people feel really strongly about this, we can of course take a pass
> > through the doc.
>
> > On Wed, Apr 18, 2012 at 1:48 PM, Bob Nystrom <rnyst...@google.com> wrote:
>
> >> Better solution: get rid of the type annotations for those local variables
> >> completely. :) Just use "var" or "final".
>
> >> var pages = <String>{ // specify value type: String
>
> >>     'index.html':'Homepage',  // (the key type is implicitly String)
> >>     'robots.txt':'Hints for web robots',
> >>     'humans.txt':'We are people, not machines' };
>
> >> - bob
>
> >> On Wed, Apr 18, 2012 at 1:21 PM, Kathy Walrath <kat...@google.com> wrote:
>
> >>> Oh wait... you mean the type of the variable, not the type of the
> >>> literal... Oops. I'll fix that.
>
> >>> Thanks!
>
> >>> -k-
>
> >>> On Wed, Apr 18, 2012 at 1:20 PM, Kathy Walrath <kat...@google.com> wrote:
>
> >>>> When I tested this example in Dart Editor a few days ago, it gave me an
> >>>> error if I used two types.
>
> >>>> -k-
>
> >>>> On Wed, Apr 18, 2012 at 1:11 PM, Ladislav Thon <ladi...@gmail.com>

Kathy

unread,
Apr 18, 2012, 5:20:43 PM4/18/12
to General Dart Discussion
The fixes are up. Thanks for all the feedback (and send more)!

-k-

Eric J. Smith

unread,
Apr 18, 2012, 5:35:09 PM4/18/12
to mi...@dartlang.org
The new tour looks great!  I learned a couple new things even after using Dart quite a bit already.  Thanks!

Ruudjah

unread,
Apr 18, 2012, 8:55:47 PM4/18/12
to General Dart Discussion
Nice, gettin' better every day, huh? :)

I miss generic collections.

var list = new List<AwesomeThing>();
var map = new Map<AwesomeThing>();

Also, a note indicating you need to implement Hashable for types to
use as keys in maps. Possibly with (a link|links) to another page
explaining the warts and boggles of implementing Hashable.

Seth Ladd

unread,
Apr 18, 2012, 9:29:37 PM4/18/12
to Ruudjah, General Dart Discussion
Hi,

Luckily we do have generic collections: http://www.dartlang.org/language-tour/#generics

(unless you mean, you miss then from JavaScript? :)

Good point regarding Hashable for Map literals. We'll probably want to do a "Dart Libraries Tour" once we clean up the libraries.

Thanks,
Seth

Ruudjah

unread,
Apr 18, 2012, 10:11:25 PM4/18/12
to General Dart Discussion
I mean in the language tour ;)

Ruud

Ruudjah

unread,
Apr 18, 2012, 10:25:58 PM4/18/12
to General Dart Discussion
Either it just wasn't there in the language tour, I need better
glasses, my browsercache needs invalidation, or I just need to drink
more coffee. Possibly all apply.

Ruud

Ladislav Thon

unread,
Apr 19, 2012, 2:02:59 AM4/19/12
to Ruudjah, General Dart Discussion
Also, a note indicating you need to implement Hashable for types to
use as keys in maps.

I think it's already there: If you use a Map constructor, then you have more options: the key can be a string, a number, or any other object that implements the Hashable interface.
 
Possibly with (a link|links) to another page
explaining the warts and boggles of implementing Hashable.

But that is a good idea!

LT

yutopp

unread,
Apr 19, 2012, 9:11:40 AM4/19/12
to General Dart Discussion
Hi! It seems great!
I'm just translating to Japanese in Dartrefjp.
Then, I found a tiny mistake.
I think Meaning in Other operators of Operators: "if expr is true,
executes expr; otherwise, executes expr" should be "if expr1 is true,
executes expr2; otherwise, executes expr3".

Thanks.

Kathy Walrath

unread,
Apr 19, 2012, 11:24:46 AM4/19/12
to yutopp, General Dart Discussion
I'll fix that. Thanks for the feedback and for translating!

-k-

Reply all
Reply to author
Forward
0 new messages