new pharo cheatsheet

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

new pharo cheatsheet

stepharo
new cheatsheet for Pharo syntax.
Any feedback is welcome

Stef

pharoCheatSheet.pdf (414K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

CyrilFerlicot


On 08/04/2016 21:56, stepharo wrote:
> new cheatsheet for Pharo syntax.
> Any feedback is welcome

Hi,

The screen seems to be from Pharo 1 no?

>
> Stef

--
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

jrick
In reply to this post by stepharo
It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.

On Fri, Apr 8, 2016 at 3:58 PM stepharo <[hidden email]> wrote:
new cheatsheet for Pharo syntax.
Any feedback is welcome

Stef
Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

HilaireFernandes
In reply to this post by stepharo
Thanks great.

As we are looking language cheatsheet, a few minutes ago, I was reading
an old news[1] about OCaml[2], here its cheatsheet[3]. It is said to be
a great language, supported by INRIA as well, with strong type. But
Pharo makes me fell more comfortable when complexity need to be handled.

Hilaire

[1] http://linuxfr.org/redaction/news/ocaml-4-03
[2] http://ocaml.org/
[3] http://www.ocamlpro.com/files/ocaml-lang.pdf

Le 08/04/2016 21:56, stepharo a écrit :
> new cheatsheet for Pharo syntax.

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Sven Van Caekenberghe-2
In reply to this post by jrick

> On 08 Apr 2016, at 22:08, J.F. Rick <[hidden email]> wrote:
>
> It looks good. I might mention that most data structures are 1 indexed as most other languages tend to be 0 indexed and that throws people new to the language.

Actually the others are wrong ;-)

Seriously, in Mathematics 1 based indexing is normal, remember vectors, matrices, series, ...

Normal people (non computer nerds, the 99%) talk about the first element with number 1.

Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.

> On Fri, Apr 8, 2016 at 3:58 PM stepharo <[hidden email]> wrote:
> new cheatsheet for Pharo syntax.
> Any feedback is welcome
>
> Stef


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Damien Pollet
On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
Since we are simpler and more logical, a cheat sheet should not confuse people by describing what we are not.

I beg to disagree. "Simpler and more logical" is just your biased point of view; fact is, zero-based indexing is just more widespread in programming languages.

I would be happy to be proven wrong about that, but I seriously doubt most people that come to Smalltalk have never been exposed to programming before. It's not unreasonable to assume that they've started programming in any one of the most popular languages these days, and that that language is zero-indexed. So mentioning that in Smalltalk the first element is indeed at index 1 is pretty essential, if just to lift the ambiguity.

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Ben Coman
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <[hidden email]> wrote:

> On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>> Since we are simpler and more logical, a cheat sheet should not confuse
>> people by describing what we are not.
>
>
> I beg to disagree. "Simpler and more logical" is just your biased point of
> view; fact is, zero-based indexing is just more widespread in programming
> languages.
>
> I would be happy to be proven wrong about that, but I seriously doubt most
> people that come to Smalltalk have never been exposed to programming before.
> It's not unreasonable to assume that they've started programming in any one
> of the most popular languages these days, and that that language is
> zero-indexed. So mentioning that in Smalltalk the first element is indeed at
> index 1 is pretty essential, if just to lift the ambiguity.

+1.  But to follow Sven's point exactly.  We don't need to say we are
"not 0 based", just that we are "1  based".

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

philippe.back@highoctane.be


On Apr 9, 2016 8:11 AM, "Ben Coman" <[hidden email]> wrote:
>
> On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <[hidden email]> wrote:
> > On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
> >>
> >> Since we are simpler and more logical, a cheat sheet should not confuse
> >> people by describing what we are not.
> >
> >
> > I beg to disagree. "Simpler and more logical" is just your biased point of
> > view; fact is, zero-based indexing is just more widespread in programming
> > languages.
> >
> > I would be happy to be proven wrong about that, but I seriously doubt most
> > people that come to Smalltalk have never been exposed to programming before.
> > It's not unreasonable to assume that they've started programming in any one
> > of the most popular languages these days, and that that language is
> > zero-indexed. So mentioning that in Smalltalk the first element is indeed at
> > index 1 is pretty essential, if just to lift the ambiguity.
>
> +1.  But to follow Sven's point exactly.  We don't need to say we are
> "not 0 based", just that we are "1  based".

And we do not need to know most of the time since we have a pretty decent collection API. Or for matrixes for that matter.

Phil
>
> cheers -ben
>

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Olivier Auverlot
In reply to this post by Ben Coman
I think that it could be interesting to use it also  on a simple HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".

It's really cool to have a synthesis document for the newcomers.

2016-04-09 8:09 GMT+02:00 Ben Coman <[hidden email]>:
On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <[hidden email]> wrote:
> On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>> Since we are simpler and more logical, a cheat sheet should not confuse
>> people by describing what we are not.
>
>
> I beg to disagree. "Simpler and more logical" is just your biased point of
> view; fact is, zero-based indexing is just more widespread in programming
> languages.
>
> I would be happy to be proven wrong about that, but I seriously doubt most
> people that come to Smalltalk have never been exposed to programming before.
> It's not unreasonable to assume that they've started programming in any one
> of the most popular languages these days, and that that language is
> zero-indexed. So mentioning that in Smalltalk the first element is indeed at
> index 1 is pretty essential, if just to lift the ambiguity.

+1.  But to follow Sven's point exactly.  We don't need to say we are
"not 0 based", just that we are "1  based".

cheers -ben


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

philippe.back@highoctane.be


On Apr 9, 2016 9:54 AM, "olivier auverlot" <[hidden email]> wrote:
>
> I think that it could be interesting to use it also  on a simple HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".
>
> It's really cool to have a synthesis document for the newcomers.

I still have a little Squeak booklet that we could redo for Pharo. It was very useful when I was learning.

Phil
>
> 2016-04-09 8:09 GMT+02:00 Ben Coman <[hidden email]>:
>>
>> On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <[hidden email]> wrote:
>> > On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
>> >>
>> >> Since we are simpler and more logical, a cheat sheet should not confuse
>> >> people by describing what we are not.
>> >
>> >
>> > I beg to disagree. "Simpler and more logical" is just your biased point of
>> > view; fact is, zero-based indexing is just more widespread in programming
>> > languages.
>> >
>> > I would be happy to be proven wrong about that, but I seriously doubt most
>> > people that come to Smalltalk have never been exposed to programming before.
>> > It's not unreasonable to assume that they've started programming in any one
>> > of the most popular languages these days, and that that language is
>> > zero-indexed. So mentioning that in Smalltalk the first element is indeed at
>> > index 1 is pretty essential, if just to lift the ambiguity.
>>
>> +1.  But to follow Sven's point exactly.  We don't need to say we are
>> "not 0 based", just that we are "1  based".
>>
>> cheers -ben
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

CyrilFerlicot
In reply to this post by jrick
Le 08/04/2016 22:08, J.F. Rick a écrit :
> It looks good. I might mention that most data structures are 1 indexed
> as most other languages tend to be 0 indexed and that throws people new
> to the language.
>

I use Pharo since 1 year now and I had to use indexes only 3-4 times. I
think it is more important to say that Pharo have Collections with an
awesome API.

--
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Olivier Auverlot

@cyril +1

Le 9 avr. 2016 10:56 AM, "Cyril Ferlicot D." <[hidden email]> a écrit :
Le 08/04/2016 22:08, J.F. Rick a écrit :
> It looks good. I might mention that most data structures are 1 indexed
> as most other languages tend to be 0 indexed and that throws people new
> to the language.
>

I use Pharo since 1 year now and I had to use indexes only 3-4 times. I
think it is more important to say that Pharo have Collections with an
awesome API.

--
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Stephan Eggermont-3
In reply to this post by CyrilFerlicot
On 09-04-16 10:55, Cyril Ferlicot D. wrote:
> I use Pharo since 1 year now and I had to use indexes only 3-4 times.

Probably on day 1 and 2 :)
The problem is that people new to Smalltalk have a background.
If they have programming experience, it is likely with a language where
indexes are important. Finding out how and when to avoid using them
takes time to learn. And that is exactly when they need the cheatsheet
most.

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

SergeStinckwich
Yes you are right. We have 2 students (3rd Year at University) here that have been exposed only to C or Java and they are totally index-intoxicated ... They can't reason on collections. Difficult for them to change their habits.

Sent from my iPhone

> On 9 avr. 2016, at 11:51, Stephan Eggermont <[hidden email]> wrote:
>
>> On 09-04-16 10:55, Cyril Ferlicot D. wrote:
>> I use Pharo since 1 year now and I had to use indexes only 3-4 times.
>
> Probably on day 1 and 2 :)
> The problem is that people new to Smalltalk have a background.
> If they have programming experience, it is likely with a language where
> indexes are important. Finding out how and when to avoid using them
> takes time to learn. And that is exactly when they need the cheatsheet
> most.
>
> Stephan
>
>

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Ben Coman
In reply to this post by stepharo
On Sat, Apr 9, 2016 at 3:56 AM, stepharo <[hidden email]> wrote:
> new cheatsheet for Pharo syntax.
> Any feedback is welcome

So I really went to town and picked the eyes out of it...

> #(abc 123)
> literal array with the symbol #abc and the number 123

This one surprised me. I had to test it to check it was true.  It
doesn't seem very consistent.  Regardless of whether we *can* do it
like that, it would be more intuitive to be #(123 #abc).  But really,
should we even allow it?


> 12 2r1100 16rC
> twelve (decimal, binary, hexadecimal) floating-point numbers

The correspondence of the '2' of the '12 very close to the '2' of the
'2r' is a bit awkward.   Also I think we can take decimal numbers for
granted and its easier for people to immediately identify A=10 rather
than C=12, and lets not leave the meaning of 'r' implicit.  So perhaps
use....
    2r1010 16rA   binary and hexadecimal radix of 10


> {foo . 3 + 2}

Perhaps move the "declaration of two temporary variables" above this,
so foo it properly introduce foo as a variable rather than leaving it
implicit.  Otherwise from the literal array example it might be
inferred that foo is a symbol.

Also, the "expression separator" should be introduced before it is
used in the dynamic array.   So perhaps the dynamic array (or all
array) examples should be closer to the end.


> A method is invoked by sending a message to an object, the message receiver; the message returns an object.

A message is an identifier for which objects provide methods of
implementation.  A method is invoked by sending a message to an
object. The object is the /receiver/ of the message.  The message
returns an object.


> Messages syntax mimics natural language

Message syntax mimics natural language


> Pharo: aColor r: 0.2 g: 0.3 b: 0

This is not very natural language.  We only need one Java/Pharo
example. Delete this one.


> Array new

You would never(?) really use that line.  So lets not mislead a
newcomer who might try it and get frustrated why they can't add items
to it.  OrderedCollection new is described later, so here perhaps
instead use...
   2 squared
   The receiver of the squared message is the object 2, with the
object 4 returned.


> A keyword message can take one or more arguments that are
inserted in the message name.

A keyword message can take one or more arguments that are
interspersed through the message name. (Put the example of this first,
i.e. #to:by: before #allButFirst:


> Precedence

Message Precedence


> Parentheses > unary > binary > keyword,

Is too concise.  I know the answer but I still feel awkward decoding
that line. Better...
    Message sending order of precedence is: parentheses, unary,
binary, keyword, left to right.

> (10 between: 1 and: 2 + 4 * 3) not

Might be better to one more unary message...
    (10 between: 1 and: 2 + 4 * 3 negated) not
    The unary #negated message inside the parentheses is sent first,
then #+ as the left most binary message, followed by #*.   Then
keyword message #between:and: is sent, and finally #not.


> The rule suffers no exception: operators

The rule suffers no exception. Operators

> so 2 + 4 * 3 reads left-to-right and gives 18, not 14!

so 2 + 4 * 3 reads left-to-right and gives 18, not 14!

Note, comparison operators like equals = is just binary messages, so...
   1 * 3 = 3   produces boolean object true
but
    3 = 3 * 1 produces an error, since a boolean object does not
understand multiplication.

Hint, while beginning with Pharo, make liberal us of parentheses in
calculations to make precedence explicit and thus easy to observe.


> OrderedCollection new
>    add: #abc;
>    add: #def;
>    add: #ghi.

Rather than just mentioning needing to send #yourself in the text,
show the pattern more explicitly by putting it in the example...
  OrderedCollection new
    add: #abc;
    add: #def;
    add: #ghi;
    yourself.

The message new is sent to OrderedCollection which results in a new
collection to which three add: messages are sent. The value of the
whole message cascade is the value of the last
message sent, so without #yourself this would be the symbol #ghi.
With #yourself, the return value is {#abc.  #def.   #ghi}


> Blocks are objects containing code that is executed on demand,
> (anonymous functions). They are the basis for control structures
> like conditionals and loops.

Blocks are objects, that contain code to be executed on demand
(anonymous functions). They defined by square brackets and are
the basis for control structures like conditionals and loops.


> 2 = 2
>    ifTrue: [Error signal: ’Help’].

Lets not mix in additional concepts.  How about...
  2 = 2 ifTrue: [self inform: 'Equal']

> The first example sends the message ifTrue: to the boolean
> true (computed from 2 = 2 ) with a block as argument.


From 2 = 2 comes the boolean object true, to which the #ifTrue:
message is sent with the block as argument.  The object true always
evaluates #ifTrue: arguments, thus the text "Equal' displays on the
screen.


> As a result, Hello World! is printed.

As a result, Hello World! is printed. in the Transcript window (which
you from the World > Tools menu)


> Pharo is a live programming environment: you can modify your
> objects and your code while your program is executing.


> • and much, much more!

There doesn't seem much use in that line hanging on its lonesome at
the top of a column


> When a protocol name starts with a *, methods of this protocol belong to a different package

A protocol name starting with a * indicates methods belonging to a
different package.


> To add a package: first column + menu add package

To add a package, right-click lower down in the Packages pane.
(If they right-click near the top they wont get that option -
something I find annoying)


> To add a class, edit the proposed template!

To add a class, select a package and edit the proposed template.  (its
not that exciting to need an exclamation mark :)


> Counter new .
>  initialize
>     super initialize
>     count := 0

It looks like the first line is part of the rest of the code sample.
Also this should be moved beneath the Methods subheading.


> Methods are public and virtual. There are always looked up in

Methods are public and virtual. They are always looked up in


> Class methods follow the same dynamic lookup than instance

Class methods follow the same dynamic lookup as instance


cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

Ben Coman
In reply to this post by Olivier Auverlot
On Sat, Apr 9, 2016 at 3:52 PM, olivier auverlot
<[hidden email]> wrote:
> I think that it could be interesting to use it also  on a simple HTML page
> for the Pharo web site. This document can be put in the main menu
> ("Beginners" ?) just before "Documentation".
>
> It's really cool to have a synthesis document for the newcomers.

I came across this a while ago and found it quite interesting...

   http://www2.ing.unipi.it/~a009435/issw/extra/readingSmalltalk.pdf

Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

stepharo
In reply to this post by CyrilFerlicot
Yes I should/may update it

Le 8/4/16 22:03, Cyril Ferlicot Delbecque a écrit :
>
> On 08/04/2016 21:56, stepharo wrote:
>> new cheatsheet for Pharo syntax.
>> Any feedback is welcome
> Hi,
>
> The screen seems to be from Pharo 1 no?
>
>> Stef


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

stepharo
In reply to this post by philippe.back@highoctane.be


Le 9/4/16 10:04, [hidden email] a écrit :


On Apr 9, 2016 9:54 AM, "olivier auverlot" <[hidden email]> wrote:
>
> I think that it could be interesting to use it also  on a simple HTML page for the Pharo web site. This document can be put in the main menu ("Beginners" ?) just before "Documentation".
>
> It's really cool to have a synthesis document for the newcomers.

I still have a little Squeak booklet that we could redo for Pharo. It was very useful when I was learning.


I'm about to update the syntax squeak flyers we did a long ago.

Stef

Phil
>
> 2016-04-09 8:09 GMT+02:00 Ben Coman <[hidden email]>:
>>
>> On Sat, Apr 9, 2016 at 6:16 AM, Damien Pollet <[hidden email]> wrote:
>> > On 8 April 2016 at 22:57, Sven Van Caekenberghe <[hidden email]> wrote:
>> >>
>> >> Since we are simpler and more logical, a cheat sheet should not confuse
>> >> people by describing what we are not.
>> >
>> >
>> > I beg to disagree. "Simpler and more logical" is just your biased point of
>> > view; fact is, zero-based indexing is just more widespread in programming
>> > languages.
>> >
>> > I would be happy to be proven wrong about that, but I seriously doubt most
>> > people that come to Smalltalk have never been exposed to programming before.
>> > It's not unreasonable to assume that they've started programming in any one
>> > of the most popular languages these days, and that that language is
>> > zero-indexed. So mentioning that in Smalltalk the first element is indeed at
>> > index 1 is pretty essential, if just to lift the ambiguity.
>>
>> +1.  But to follow Sven's point exactly.  We don't need to say we are
>> "not 0 based", just that we are "1  based".
>>
>> cheers -ben
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

bestlem
In reply to this post by SergeStinckwich
On 09/04/2016 10:59,
[hidden email] wrote:
> Yes you are right. We have 2 students (3rd Year at University) here that have been exposed only to C or Java and they are totally index-intoxicated ... They can't reason on collections. Difficult for them to change their habits.
>
> Sent from my iPhone
>


Surely learning Java now should not be index based - the for loop is
enumerated and it has the filters maps etc. e.g.
<http://zeroturnaround.com/rebellabs/java-8-explained-applying-lambdas-to-java-collections/>

(so bad teaching?) and C as a first language I would have thought not a
good idea either.


--
Mark


Reply | Threaded
Open this post in threaded view
|

Re: new pharo cheatsheet

jrick
In reply to this post by CyrilFerlicot
I agree that enumeration is more useful but it wouldn't be bad to have something in there to indicate the 1-index nature, such as
  'abcd' at: 2 will result in $b
That's all I was suggesting.

Actually, having some cheat sheet on basic enumeration wouldn't be bad as that is a real strength of Smalltalk. Mention and illustrate what do: collect: and select: do. Then mention that there are other ones like count: and sum:.

Cheers,

Jeff

On Sat, Apr 9, 2016 at 4:57 AM Cyril Ferlicot D. <[hidden email]> wrote:
Le 08/04/2016 22:08, J.F. Rick a écrit :
> It looks good. I might mention that most data structures are 1 indexed
> as most other languages tend to be 0 indexed and that throws people new
> to the language.
>

I use Pharo since 1 year now and I had to use indexes only 3-4 times. I
think it is more important to say that Pharo have Collections with an
awesome API.

--
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France

12