exercism / pharo-smalltalk

Exercism exercises in Pharo.
https://exercism.org/tracks/pharo-smalltalk
MIT License
34 stars 28 forks source link

Implement the Core Exercises #30

Open macta opened 6 years ago

macta commented 6 years ago

When you complete hello-world, you are presented with a progress tracker for core exercises.

We need to implement these for Pharo.

However @kytrinyx, how do we know what are the core exercises? Is this specified somewhere - the exercism/problem-specifications repo just seems to list them all, but I can't see any tagging?

macta commented 6 years ago

We have completed two-fer is that a core exercise? Or Is leap (that’s what python offered to me next)

macta commented 6 years ago

@samWson apparently there is now official list of core exercises - we should look at Python/Ruby/Go/JS and come up with a list ourselves.

Python seems a bit mixed up - not sure why two-fer is core, yet hello-world seems to unlock some much more difficult follow on examples.

In my mind two-fer should be unlocked by hello-world as its a pretty trivial example.

Something like reverse-string feels like a follow on from hello-world as its a bit meatier. But then what should it unlock as bonus examples?

Then what is next in difficulty?

samWson commented 6 years ago

I saw something in exercism/discussions that said core exercise choice was really up to the maintainers of each individual track (I can't locate it right now). We should pick exercises with an eye toward showing off the great features of Pharo.

For now I think just dump ideas in this issue as we come up with them. We can give this issue more attention after our infrastructure is in place.

macta commented 6 years ago

See https://github.com/exercism/csharp/issues/611

samWson commented 6 years ago

That list is a great start. I like how they have organized by which feature each exercise is teaching.

Control flow is going to be important one since Pharo does everything through message passing and lacks familiar syntax constructs like if/else.

So far we have:

If we are designing exercises with an eye toward teaching features then I figure we need to cover things like this especially where Pharo differs from the norm:

macta commented 6 years ago

I like your thinking on this - I would also add some of our speciality features (in later stages)

For the closures - we should also enforce that they are just objects like any other

macta commented 6 years ago

Can we consider the ordering of the exercises that the others have - e.g

hello-world is obviously first, then I think two-fer is just a bonus from that as its pretty easy.

then I put reverse string (its got iteration), but I wonder if leap and its conditional and modding might go before it (instead of after?) - is iteration harder?

then there is the bob exercise - conditional stuff - is that harder than iteration - having not done it and thinking in my head we don't do case statements or nested if's maybe its harder?

bencoman commented 6 years ago

then there is the bob exercise - conditional stuff - is that harder than iteration - having not done it and thinking in my head we don't do case statements or nested if's maybe its harder?

Some Smalltalk developers consider #ifTrue:ifFalse a bad smell... (of course, its often pragmatic to live with it) ...and it occurs to me that the way Smalltalk does conditionals using polymorphism is one of its greatest distinctions. Actually this concept is maybe the one that will most help an experienced programmer to "grow", even if they never use Smalltalk "in-real-life" (and perhaps why Smalltalk experience is well regarded on resumes for non-Smalltalk jobs)

The concept is.... "Tell, Don't Ask!" i.e. Do not ask (object isSomething ifTrue:[ self doSomething ]) but tell (object doSomething) which results in much more concise and "naturally readable" code.

However this will be quite foreign to most students (which we should point out) and will stretch their thinking (pointing out this is beneficial to them, why else are they here if not to learn new paradigms?) So I think we need to hand-hold students to lead them to such a solution. This can be done by providing two Bob exercise: BobAsking and BobTelling.

In BobAsking students program using conditionals as they naturally will coming from other languages. They do this first so to get their logic sorted out using familiar constructs.

Then unlock BobTelling where we provide a templated solution (below) that they fill in the blanks (i.e. hand-holding).

Bob class >> hey: statement
   ^{ Question. Yelling. Silence }
        detect: [ :response | response caresAbout: statement ]
        ifFound: [ :response | response says ]
        ifNone: [ 'Whatever' ]

Question class >> caresAbout: aString
    ^ aString endsWith: '?'

Question class >>  says
    ^ 'Sure.'

and in Playground... Bob hey: 'Can you take the bin out?'.

And in this templated solution we can introduce #shouldBeImplemented...

Yelling  class >> caresAbout: aString
    self shouldBeImplemented.

Yelling class >>  says
    self shouldBeImplemented.

Silence class >> caresAbout: aString
    self shouldBeImplemented.

Silence class >>  says
    self shouldBeImplemented.

P.S. which is more concise than this example that "improves" on a simple conditional solution... http://programming.ianwhitney.com/blog/2014/05/28/exercism-the-bob-exercise/

macta commented 6 years ago

@bencoman do you want to nab bob and a bonus bob-telling (or do we make that core too? This is where we need a good list of exercises to figure out the correct path). For non-standard exercises there is some yaml that has to go in .meta to spec it (not done that yet).

You wanted an “in” if you have time. I’ll grab another one so we can try and build out a decent number of exercise.

I’ll grab another.

I like your reasoning on this one. Also good to use a question class and not an association of blocks which other languages seem to encourage (people are scared of small classes)

kytrinyx commented 6 years ago

how do we know what are the core exercises?

I saw something in exercism/discussions that said core exercise choice was really up to the maintainers of each individual track

Yes--the idea of core is that the maintainers pick the exercises that are the best path into the language, and the exercises they unlock would typically be ones that play with similar concepts or deepen those concepts. It's pretty loose, though.

macta commented 5 years ago

Would like to see this one get a bit more urgency - the Python and Ruby configs seem a bit mixed up

Go seems to have a decent handle and an old PR discussions list this:

core
----
├── hello-world [1]
|
├── two-fer [1]
|   ├── leap [1]
|   |   └── triangle [3]
|
├── hamming [1]
|   ├── rna-transcription [2]
|   └── nucleotide-count [2]
|
├── raindrops [1]
|   ├── accumulate [1]
|   |   └── strain [2]
|   └── roman-numerals [2]
|
├── scrabble-score [1]
|   ├── etl [1]
|   └── protein-translation [3]
|
├── isogram [2]
|   ├── pangram [2]
|   ├── anagram [3]
|   └── word-count [3]
|
├── difference-of-squares [2]
|   ├── largest-series-product [3]
|   ├── nth-prime [3]
|   ├── sum-of-multiples [5]
|   └── pythagorean-triplet [5]
|
├── luhn [2]
|   ├── crypto-square [3]
|   ├── atbash-cipher [3]
|   ├── simple-cipher [3]
|   └── diffie-hellman [5]
|
├── grains [2]
|   ├── sieve [3]
|   ├── all-your-base [3]
|   ├── allergies [4]
|   ├── secret-handshake [5]
|   └── variable-length-quantity [5]
|
├── clock [3]
|   ├── phone-number [3]
|   |   └── pig-latin [4]
|   ├── prime-factors [3]
|   └── meetup [3]
|
├── parallel-letter-frequency [3]
|   └── series [3]
|
├── tree-building [3]
|   ├── ledger [4]
|   ├── binary-search [5]
|   |   └── binary-search-tree [5]
|   ├── bracket-push [7]
|   └── pov [7]
|
├── robot-name [3]
|   └── wordy [3]
|
├── tournament [3]
|   ├── kindergarten-garden [3]
|   ├── pascals-triangle [4]
|   ├── diamond [4]
|   └── ocr-numbers [7]
|
├── twelve-days [4]
|   ├── beer-song [3]
|   ├── house [4]
|   └── food-chain [4]
|
├── bank-account [4]
|   ├── grade-school [5]
|   ├── change [5]
|   ├── robot-simulator [6]
|   └── react [9]
|
├── matrix [4]
|   ├── word-search [4]
|   ├── queen-attack [5]
|   ├── transpose [5]
|   ├── saddle-points [5]
|   └── minesweeper [5]
|
├── error-handling [5]
|   ├── circular-buffer [5]
|   |   └── custom-set [4]
|
└── paasio [5]

bonus
-----

├── gigasecond [1]
|
├── bob [2]
|
├── acronym [3]
|
├── palindrome-products [6]
|
├── perfect-numbers [4]
|
├── say [7]
|
├── connect [9]
|
├── poker [5]
|
├── forth [8]
|
└── bowling [5]

(source: https://github.com/exercism/go/pull/835)

macta commented 5 years ago

We are slowly working our way down the list. Other tracks seem to have very random ordering and categorisation and skill level (I can't find one where I really see the exercises getting harder and the concepts grouped in a logical consistent way). i still think the problem-definitions should give an indicative grouping and difficulty (and then tracks override where different).

kytrinyx commented 5 years ago

@macta the Ruby track and C# tracks have done a lot of work on ordering both in terms of difficulty and in terms of covering different concepts.

/FYI @F3PiX

macta commented 5 years ago

@kytrinyx I had heard that, but i'm scratching my head as I figured Ruby being a derivative of smalltalk would make it very similar (but it doesn't seem that way). e.g. just looked at BracketPush - its difficulty 7 (??) and based on raindrops which itself is core and comes after hamming (which again seems odd to me - as raindrops is pretty simple and seems more akin to something leap might unlock). In C# BracketPush is core (and 5 difficulty), but comes quite a ways down the list of core exercises. Again seems a strange. I then often look at Python, but it also does things very differently.

Its not for me to judge - but the classification and ordering just doesn't seem to compute - these languages are very similar in my mind...

Anyway, we will muddle through, and its more obvious when you have a larger set to compare against each other.

kytrinyx commented 5 years ago

@macta I believe @F3PiX is on vacation but once she's back, it could be worth pinging her in Slack (if you spend time there). She has a whole lot of context about the why for all of the above.

macta commented 5 years ago

@kytrinyx thanks, I’ll reach out as I haven’t spotted the pattern/model but I know lots of thinking has been going on. It’s possibly how to document it for those of us following behind. The exercise categories should help, but I struggle to tag them sometimes - I think it would be more helpful if there were some set categories that you slot exercises into for your language. I find my current thinking is something like - these are string processing, these are math/algorithmic (modulus), then Collections, then recursive, then more OO etc. But I don’t see/understand the pattern in the other tracks? To me the concepts I mention are reasonably language generic and could live at the problem definition , but you’ve resisted that. So I am curious.