documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Getting Started Guide: use simpler example than Euler.

Open oldfartdeveloper opened this issue 5 years ago • 5 comments

Per my suggestion in #324:

In the getting-started-guide, I prefer using the "diagonal function" for the reason that I'm just trying to get the environment up and running; I don't care about interesting programs at that particular time. The explanation of the generated Javascript is more cumbersome for the Euler exercise and I don't think the extra effort is appropriate in that place.

This is the issue to manage the substitution of something simpler for the Euler code. @milesfrain suggested the diagonal exercise.

oldfartdeveloper avatar Jun 12 '20 19:06 oldfartdeveloper

The Euler example is still a nice demo, but could send users down some rabbit holes if they don't have a FP background. Maybe Euler could be featured as an examples-based "Next Step" versus going through the book.

milesfrain avatar Jun 12 '20 20:06 milesfrain

Also worth noting that the Euler example is the springboard for the book's Getting Started chapter. We then work through diagonal together. So implementing this suggestion would also require some rewriting of that chapter.

milesfrain avatar Jun 13 '20 04:06 milesfrain

Yes, I've been thinking about that; agreed about some amount of rewrite required. Having diagonal follow Euler seem backwards, so I think it's worth doing. When I get to it, I'd like to have a stab at solving these problems

oldfartdeveloper avatar Jun 15 '20 20:06 oldfartdeveloper

I don't think I agree that the Euler example is that complex; I wouldn't say it's really any more complex than the diagonal one, personally. I also like that the Euler example can be done bit by bit, with the intermediate results printed to the repl.

hdgarrood avatar Jun 25 '20 17:06 hdgarrood

@hdgarrood I beg to differ; here are the source codes for both:

diagonal:

import Math (sqrt)

diagonal w h = sqrt (w * w + h * h)

Euler:

module Euler where

import Prelude
import Data.List (range, filter)
import Data.Foldable (sum)

ns = range 0 999

multiples = filter (\n -> mod n 3 == 0 || mod n 5 == 0) ns

answer = sum multiples

Euler introduces new functional programming concepts such the newbie is unlikely to have heard of:

  • Foldable
  • Prelude
  • The lambda filter (\n -> mod n 3 == 0 || mod n 5 == 0)
  • Where does sum come from?

Plus Euler requires 3 lines of code instead of one.

Whereas diagonal will look straightforward to anyone who has had to deal with the Pythagorean theorem. Which is basically anyone who has graduated from high school.

Again, I think Euler is a fine exercise; just shouldn't be the first example in the Getting Started guide.

oldfartdeveloper avatar Jun 25 '20 19:06 oldfartdeveloper

Closing this issue as I want to ponder a completely different solution for the sample app.

oldfartdeveloper avatar Dec 29 '22 21:12 oldfartdeveloper