Not sure how to go about blogging about code, but I surely can try to write an actual play of my experience
So I have little to no coding experience. I attended a professional course about HTML and CSS and Javascript, but it was 20 years ago, and I never really put it into practice. Since then I periodically try to teach myself coding of some kind, but never got anywhere, and eventually let go.
I tried dipping my toes in Elm in the past two years, but never really sat down methodically going through the Guide.
Now I’m finally getting around to it
Pretty much everything up to the final part of the Form exercise felt well paced.
The Guide offers examples, and goes about explaining them bit by bit. It’s very clear and friendly.
In the Form exercise I remember how checking for length and digit/upper/lower characters was not too much of a problem.
I had to think on my own and go search the Elm Package pages.
The Guide points the reader towards the String package… which is ok for the length function.
But then I had to go looking for other functions in the Char package. A small pitfall here was that the any function uses isDigit as an example… and I thought it was a whole thing within the String package, not a separate function from another package.
This resulted in an error that told me to check how import works … but my “import String” syntax seemed correct!
There I first searched for some external solution, a way to check for upper/lower case, and Google returned me stuff that led me to the Char package. The world was right again.
Another (doable) challenge was to actually understand how to implement in my code the functions described in the Package pages. Here the compiler and some trial and error did the trick.
In the end I had a clunky bunch of separate function, each performing one of the required checks, all invoked en masse at the end of the example View function. Horrible, but it worked
And then the last bit came along: make a button that performs these checks, and do them only when the button is clicked.
This felt much more difficult to do.
I felt kind of lost.
I started by adding the new button to the View, and then got stumped.
It did not immediately occur to me that a new button meant “a new action” and thus a new entry in the Update function. And consequently it did not occur to me to modify the Model to handle this.
After peeking at someone else’s solution I felt possibly even more confused.
On the one hand I saw what I was supposed to do.
On the other hand the implementation looked alien, far more advanced than what I knew how to code, more abstract than I knew how to think.
Still, it was something I could try to understand and use.
I refused to just copy the code and tried to only peek at it as an example to type my own code. But I kept failing. The compiler helped a bit, but not enough for me to understand what was wrong or missing.
I don’t remember every detail now, but mainly I felt like I was not really understanding how to use/write the type annotations (thus what was supposed to go in a function and come out of it), and what actually a Type meant for the program (thus how and why to create new ones, add stuff into their definition, etc).
Eventually I stumbled upon THIS solution which was both well explained AND followed a logic that I felt more familiar to me. I was imagining a solution, and this implementation matched closely enough my own reasoning.
It still had foreign elements (the Let function, which is nicely described in the Syntax but not mentioned in the Guide up to this point) but it was understandable enough.
This led me to finally code what the exercise required. The whole process took me two afternoons
And then I went on the next step of the Guide, and it was a constant “ooooh that’s it!”.
Reading the Types chapter explained SO MANY THING that felt weird and obscure before, both regarding Types themselves, but also about Functions, their structure, refactoring, etc.
Maybe it’s just an impression post facto, but I think that if I had read this stuff before the submit-button exercise I would have had an easier time.
Another thing I’ve noticed, both about the Guide and other tutorials I’ve skimmed online… they ALL seem to follow a top-to-bottom train of thought.
Submit Button? Sure, first of all think about your Model, than use it to expand the Update, and finally plug that into your View.
I seem to struggle with this logic, and tend to proceed in a bottom-to-top direction.
Submit Button? Well it’s a button right? So I do my button in the view. But what does it do? I guess it does some action… which means something should happen in the Update. Let’s go expand it to accomodate. Mmm, to make this update action the way I imagine it I need to store a new value somewhere. Where do I do this? In the Model! (this was actually a not obvious realization for me) Time to change the Model too then!
Going the other way around I found myself lost. So… the Model first… what am I supposed to do with it? I don’t know. It’s unclear. The mind reels at the possibilities
Is there a cure for this? XD
Or can this way of thinking be correct too?