I’m teaching Elm to a computer science tutee of mine (He’s learning a lot of CS outside academics, especially in the summer.) And I’m actually pretty new to Elm myself.
I wanted to teach him a number guessing game. You know, you try to guess the computer’s number and it tells you “high” or “low”. I started writing this myself and quickly realized it’s pretty complicated.
Compared to a Python version of this game, this is rather complicated. (Like 10 times more code.) Is this complexity something we need to accept about Elm, or is there a better way?
Hi Mike! I can see how this kind of example feels complex compared to Python but I wonder if you’d agree that perhaps it’s just more verbose? With strong types and managed side-effects such as randomness trivial examples tend to be a little more verbose while large applications tend to be simpler at scale.
Something like the latter example might be a better entry point as it’ll allow anyone to get to know the language better prior to the introduction of the concept of a Cmd which is something that randomness requires.
One thought about the complexity of Elm vs. Python. Maybe it’s GUI vs. command line.
In Python, the state of the game is implied by the current execution point and current variable values, so it doesn’t have to be explicitly modeled. In any GUI, including JS you have to define “widgets”, respond to their events and model the state more explicitly.
On the other hand, it might be slightly more difficult with Python and a CLI to get a “real-time” evaluation like in this even more basic example: https://ellie-app.com/5WWbZfXbB7da1
So this might be showcased to illustrate the strengths of Elm.
Thanks for the examples. Can I download or save things from Ellie? I tried “share” and “download zip” but it was non-responsive (no download initiated).