This seems reasonable. Maybe even boring. Obviously it should work this way! But imagine replicating this in JavaScript. With JS, the only way to know if the history is compatible is to try it out. If it is incompatible, it will throw a runtime exception. Not the runtime exception you are looking for, but a new one. One created by your debugging tools. Now maybe you are chasing after bugs that do not even exist!
Elm does not have this problem, not because of engineering, but because of the language itself. Elm is designed so that programs can be analyzed quickly and reliably, in ways that are impossible in JavaScript. So as tooling in Elm continues to improve in the next releases, I am excited to see what other unique advantages we get thanks to the design of Elm itself!
More than a Debugger
Debuggers often feel like tools for experts, but I think ours can help total beginners too! The Elm debugger visualizes the program itself. Your code is no longer a mysterious black box that spits out pixels in the browser. Instead of trying to figure it all out in your head, you can actually see the messages come in and watch the model evolve!
I am pretty certain the debugger will help beginners understand The Elm Architecture, but I am excited to see how far it can go as a learning tool. Whether you are a beginner or expert, seeing the program helps you understand the program!
What else is in Elm 0.18?
In addition to the debugger, there are some improvements to the error messages and core libraries. I will just be highlighting the most important stuff in this post, so check out the migration guide for more details!
Improved Error Messages
Elm has an error message catalog, full of messages that folks thought were confusing for some reason. This is great for constantly improving our error messages! Based on the feedback there, we have a couple nice improvements. Click the links to see examples!
These are definitely nice for experts, but I am most excited to see folks learning Elm with these additional hints! Recently, at the first ever ElmBridge event, I saw students running into problems that made me think “Oh, that is tricky, I’m gonna have to help.” But again and again, I was surprised to see that they just figured it out based on the error messages! My intuitions from my TA days and teaching older versions of Elm are not right anymore. Pretty exciting to see!
Less Syntax
Elm is already quite a small language, but there are a few oddities that seem to do more harm than good in practice. So rather than saying “Oh well!” and keeping them forever, we are just taking them out:
Primes — Names like x'
are no longer permitted. A younger me (one who was less concerned about nice variable names) certainly thought writing “x prime” was pretty neat! But in general, this syntax is too confusing to be worth it. Single quotes are generally associated with strings and characters. To see it unbalanced and part of a variable throws people off, and the benefit of having it is pretty small.
Interpolation — The [1..5]
syntax was removed in favor of List.range
. The syntax was kind of nice, but not very discoverable or commonly used. Whenever I used [1..5]
in a talk, someone quite experienced would comment that they wanted something like that but could not find it in the standard libraries!
Backticks — buyMilk `andThen` dipCookie
used to mean the same thing as andThen buyMilk dipCookie
. This was in Elm since the beginning, so problems like “backticks look like single quotes” were overlooked. More recently, we noticed that everything nice about backticks is nicer with the |>
operator. By flipping the arguments to andThen
, we can write buyMilk |> andThen dipCookie
. This reads nicely, it is easy to chain, it works well with onError
, and it does not require any special syntax. It just builds on existing knowledge!
Again, all these cases are covered in more detail in the migration guide, and elm-format
will handle most of these cases automatically. Folks using the 0.18 alpha reported that the upgrade was quite smooth, so feel free to ask for help on the Elm slack. The Elm community is friendly and happy to help!
Thank You
Huge thank you to Pete Vilter who worked on Elm Reactor with me last summer! It took a while, but the ideas of writing as much as possible in Elm and splitting out a debug window are finally in there.
Thank you to everyone submitting SSCCE’s to the error message catalog! It has been really exciting to see how direct feedback like this has improved things since we started this process in Elm 0.16.
Thank you to everyone who tried out the alpha and beta releases, reported bugs, and gave feedback on potential changes. Getting this kind of feedback is really important!
Finally, thank you to Richard Feldman for getting the npm
installer working, and thank you to Aaron VonderHaar for updating elm-format
to do a lot of this upgrade automatically!