ponylang / pony-tutorial

:horse: Tutorial for the Pony programming language
http://tutorial.ponylang.io
BSD 2-Clause "Simplified" License
312 stars 111 forks source link

Add a Chapter on Collections #190

Open mfelsche opened 7 years ago

mfelsche commented 7 years ago

As a newcomer to pony (coming from java, scala, python, erlang) i would really really love to see a section about collections in the tutorial as this a pretty important building block of day to day programming (next to primitives, classes, actors ...).

Useful information would be:

Most of this is not directly uniquely related to pony but knowledge of how to powerful the language is in terms of solving day to day problems would really help getting a feeling about the language and help people get into it.

mfelsche commented 7 years ago

Please also include Array examples

mfelsche commented 7 years ago

I would have started to write up something but i don't feel confident enough with pony yet.

vak commented 7 years ago

I've spent half an hour to implement basic Map container member within a class and ...failed :-/ The type constraints are not clear. Could someone add into tutorial or into example section of repository a clear example on how could one work with Map, please?

mfelsche commented 7 years ago

We agreed on adding a section about collection on the precondition that the actual collection docstrings and package documentation will have some serious overhaul and this section will be more of a starting point for a guided tour of the standard library with pointing people into the right direction and refers to the stdlib docs.

marctrem commented 5 years ago

Ha, I also had a hard time figuring out how to create a HashMap. In case other people end up here as I did:

let m = HashMap[U64, String, HashIs[U64]].create() will do the trick!

As far as I understand (started to read the pony tutorial 2h ago):

Please let me know if my understanding is wrong!

[0] https://github.com/ponylang/ponyc/blob/1b72941baa38cb23cba6fc8f7fb8b4d73cc57b28/packages/collections/hashable.pony#L84

rhagenson commented 5 years ago

Personal opinion significantly in the future of when this issue was last discussed during sync, to add a chapter like this I would want to move Object Capabilities after Generics then put this chapter after Generics.

In brief, currently the order is:

  1. Getting Started
  2. Types
  3. Expressions
  4. Reference Capabilities
  5. Object Capabilities
  6. Generics
  7. ...

Changing to:

  1. Getting Started
  2. Types
  3. Expressions
  4. Reference Capabilities
  5. Generics
  6. Collections
  7. Object Capabilities
  8. ...
SeanTAllen commented 4 years ago

I'm not in favor of "chapter on collections". I'm in favor of adding at the end of the tutorial a "tour through the standard library" that highlights the most commonly used things that we want people to be aware of like net, collections, and what not.

rhagenson commented 4 years ago

@SeanTAllen A tour of the standard library sounds fair. I see that tour being placed after "Gotchas" and before "Where Next?" Any objection to that?

SeanTAllen commented 4 years ago

Sounds good to me @rhagenson.