Why I Use Elm in 2023
taylor.town
taylor.town
I hate this mindset. "<my favorite language> is used to solve REAL problems, other languages are not as good for creating VALUE. Any powerful language features, ergonomic syntactical sugar or tooling that does not exist in <my favorite language> is useless". So strange
Ultimately it comes down to trying to do a cost/benefit analysis of the complexity at hand and deciding if the additional layers add enough value and how far your problem deviates from the supporting structures. The issue is, it's often quite difficult to know a priori what is helpful and what just adds complexity because goals are often moving targets and you have to try and assess the range of potential goals with the flexibility of all the middle layers you introduce.
Maybe this makes more sense:
Coming from more expressive languages, one of the good things I could say about Go's developer UX is that you are so helpless to circlejerk over abstractions that there is simply nothing else to do than to write concrete code to solve the problem.
Elm is similar versus the huge type expressive power of Haskell. Elm's type system is so minimal compared to similar languages that you can't spend hours perfecting your higher kinded advanced type abstraction that perfectly annotates and cordons off the problem domain because there isn't enough typing power to do that. You have to go "welp, good enough" and move on.
And by that you mean "invent ad-hoc code generators instead of using built-in language features from the 21st century", right?
Yes, sometimes the simplicity of the language leaves you wanting a bit more power (typeclasses, macros) but the code quality seems (to me) better with the constrained language than with the unconstrained one.
Also, doing only GUIs is quite a bit more restrictive than general purpose programming and not every fancy feature may make sense there.
One example of code generators is enums, I'd love for Go to add that as a feature, I frequently use them in other languages. Go's equivalent is a list of consts with a shared prefix, e.g. StatusOK, StatusBadRequest etc for HTTP error codes [0], then functions to do anything with them (like getting a status text for the aforementioned HTTP status codes; see [0] and scroll down a bit).
I mean it's not difficult code; nobody has to learn any new syntax or methodologies to understand enums if they already know consts / variables, functions and switch/case statements. It's just inelegant and it feels unsafe - you need a linter [1] to check for exhaustiveness of the aforementioned switch/case, on top of a ton of other linters [2] that IMO should be language features or compiler checks.
My personal gripe is struct tags that are just strings that no tooling or compile-time checks will check, they're left up to a library (or the standard library) to interpret at runtime. In other languages like e.g. Java they introduced annotations to add metadata to properties.
[0] https://go.dev/src/net/http/status.go
edit: gp, not p
And partly because it needed more thought. I'm all for more well thought out features, but there's also value in a language that doesn't move fast and doesn't break things. And I say that while Python is my main work horse, so I understand what breaking things mean.
https://news.ycombinator.com/item?id=9622417
> We have spoken to a few true experts in Java generics and each of them has said roughly the same thing: be very careful, it's not as easy as it looks, and you're stuck with all the mistakes you make.
The Go team does their homework, and they do it thoroughly. I respect that more than anything about the language. Compare with Java, that had been stagnant in committees for nearly a decade, or with Javascript, that has been bolting on features left and right; I'm mainly thinking of the half-baked OOP addition.
To their credit, they don't just throw things into the language because it's trendy or "cool" at the moment. Even if people disagree with their decisions, they are well considered and thought about decisions.
Also, languages don’t start in a vacuum, they shouldn’t have to go through the whole process from zero each time — Go absolutely failed by not incorporating it from the first version.
I definitely don't think ergonomics and features from other languages are useless! I just feel a bit overwhelmed and distracted by variety sometimes, especially when working on teams.
For example, about 50% of the JS teams I've worked with collectively agreed not to create new classes. I think I'd prefer working with JS if there were only one way to do things, but it doesn't mean that classes are bad or useless.
{ Module.record | field = value }
is not allowed. So either, you need to import record unqualified, or you need a let construction.I somewhat get the restriction on nested updates (though I don’t agree with it), but I absolutely do not understand this.
I like golang a lot and use it professionally and there are plenty of errors and issues that can require syntax and code that to people who aren't super proficient in it would think is over-complicated and end up fighting the compiler (channel can be awkwardly implemented and related issues and what not can be.... non-obvious..).
I've been writing a ton of rust recently and until I became proficient I felt it was really complicated and led me to fight with a compiler (borrow checker I suppose) and honestly it took me coming back to it a second time almost a year later to break through it and now i'm as productive in rust as I am in golang... but it was my familiarity, I found tools I wasn't aware of, my SQL query strings & templates are now checked statically and so I feel more productive in rust in some ways.
Obsession with language features or syntax tends to move people towards building castles in the sky and being too obsessed with code rather than the software that actually runs on a physical machine. A lot of fancy features usually come at quite high runtime or compile time costs with not really meaningful benefits in a large software system.
Unless you're writing software explicitly for the sake of staring at code, unopinionated and simple, fast and pragmatic languages that get out of the way are the tool of choice for good reason.
There, I made it point-free. Isn't it much simpler?
Personally, I tend to prefer using and abusing all the sugar and tools that a compiler gives me. I find that I'm not a terribly smart person most of the time, and if a compiler engineer has a figured out a good bit of abstraction to make the code safer or more readable or faster, I'm inclined to use it.
There are plenty of success stories with this approach. Love it or hate it, I think SQL is overall a reasonably pleasant language, and almost completely removed from the underlying hardware. You think relationally with SQL, not really in terms of for loops or memory allocation.
All that being said, I will admit that sometimes I don't want to spend the entire day trying to decipher whatever the hell GHC is trying to tell me with its weird errors. Go makes you do a lot more manually, but at the same time you also don't need to understand the intricacies of a sort of approximation of type theory or linear logic.
IMO, I genuinely think that right now the two best languages in terms of abstraction usability are Clojure and F#. They both allow for lots of great abstract stuff, but they also do allow you to cheat when necessary, and being on the JVM and .NET Framework respectively, there's no shortage of libraries available.
IMO the biggest problems with almost all popular programming languages are
1) null
2) exception based error handling
such that, when you call foo() where foo is
String foo(){ blabla }
you can get a String, null OR an exception (!!!) and most compilers happily let you treat it as if it only ever returns a String.
I hope some day null is no longer a thing, and that Functional Programming types like Option, Either, Try etc in the native libraries is the new default.
incredibly, there's still no consensus as to which exceptions should be used for what and when, though these days the most common approach is to simply stick only to RuntimeExceptions, which is terrible.
Functional error handling using Option, Either, Try etc are arguably much simpler, safer and more powerful than exceptions.
Simpler because they don't rely on dedicated syntax- they're just regular objects no different to any other object.
Safer because unlike exceptions, they force callers to handle all potential outcomes, but no more. (no risk of ignoring errors and no risk of catching a higher level of error than desired, ubiquitous bugs in exception based error handling)
Powerful because they support map, flatmap, applicative etc, making it easy to eg chain multiple computations together in desired ways, which is unwieldy and bug prone when using exceptions.
It could be that, when learning Java, Python and any other language, we learn that methods return objects... and that's that. No weird dedicated syntax and magic, special treatment for returning anything other than the happy path, and the HUGE complexity that comes with it, eg the dedicated syntax itself and how it behaves, differences between checked and unchecked exceptions, hierarchies of exceptions etc etc.
In addition to that, when lists and booleans implement map, flatMap etc, you can actually reduce syntax of languages even further- there's no need for looping syntax like for, while etc, and no need for if else either. This is probably too extreme for most people, but think about it. There's literally no reason to have this syntax in the language if the types in the library give you the same functionality.
So my dream languages would be something like Kotlin ie with inferred type safety, immutability by default etc but without support for null at all, no exceptions at all, no looping or conditional syntax, and a better, smaller, simpler library.
Rust has no exceptions in any sense of the word. Exceptions are ways to crash the program in a controlled manner with the ability for these crashes to be caught midway before the program crashes and handled correctly.
In rust you can only crash it explicitly using the panic! Macro. No handling.
The different name you are looking for is "errors". Rust has errors as do all programs. Some programs have exceptions to handle those errors. Rust does not.
If you mean "runtime crashes" then elm is the only language that is popular that uses has no runtime crashes.
> In rust you can only crash it explicitly using the panic! Macro. No handling.
You can catch Rust panics with `catch_unwind()` if you compiled your program with `-Cpanic=unwind` (default on most platforms). Under the hood it uses stack unwinding, just like C++ and co's exceptions. But Rust doesn't consider this idiomatic error handling, it's only used in a few special situations (test frameworks, web servers where one buggy session shouldn't take down the process...).
[0] Example of catching, handling, and "swallowing" a panic in Rust (GTP4 wrote this): https://play.rust-lang.org/?version=stable&mode=debug&editio...
Trying to do magic and patch something on a panic and retry is cursed indeed. If it's about cleaning up resources of a thread and logging this somewhere, then there's nothing cursed about this.
fun findUser(userId: String) : Either<Error, User>
is MUCH simpler and more powerful than
fun findUser(userId: String) //haha, I can actually throw exceptions that aren't in this signature, or return null (wat)
I hope you never program any safety critical machinery. I don't mean exceptions cannot be useful, just that there are circumstances where they are useful and circumstances where they are not.
That is really not the point being made. The point is rather "the language helps me keep focused on what I do, because many subtleties in other languages don't exist, and those have me overthinking things". Whether what you do is REAL work or a friday night game jam is irrelevant.
Also I wouldn't say that Elm lacks ergonomics or powerful expression features. It does lack browser API features, but I don't believe that's what the author enjoys.
The full context helps
Most languages are too powerful for my palate.
Don’t get me wrong – I love Rust and many other languages! But sometimes they’re just too much for me.
When writing Rust or JS or Haskell or Python or Lisp, I’m overwhelmed by opportunity. Should I make this generic? Should I use classes or structs? Immutable or mutable? Macros? Functional or imperative array manipulation?
I try to please compilers and coworkers and customers, but all are disappointed. Give me a woodshop and I’m lost, but give me a simple chisel and I intuitively know what to do. There’s a certain freedom in restricted toolsets.
Languages like Go and Elm spurn extravagance. They resist overcomplication. They force me to solve real problems instead of fighting compiler errors and stylistic differences.
Furthermore, consistent code makes portable mental-models. Go and Elm codebases tend to be extremely readable.
However, I don't like the way the project is run. It's one Benevolent Dictator that has a particular vision for Elm and he's not really sharing with the community. For context, the latest Elm version (0.19.1) was released in October 2019. It kind of feels like a nice tree house left to the elements because the person grew out of interest, but kept a lock on the door.
https://gotoaarhus.com/2023/sessions/2529/elm-on-the-backend
This feels a lot like Patrick Rothfuss on his Kingkiller Chronicles. The creator has a fan base he doesn't want to disappoint and who will defend his honor as long as he can give them any evidence he's actually making progress, but all the evidence suggests he's actually lost interest or doesn't know where to go from here.
Not that there's anything wrong with losing interest in a hobby project. The problem with Elm is that it was pitched as more than a hobby project but then held so close to Evan's chest that no one else has been able to take over now that he's not maintaining it.
These comments are always the same: "Elm is great, but..." Then they dig up some drama about its creator with a years-old post. If the language is great, then maybe they should use it and stop fretting about the person who made it.
I couldn't care less about the creator or his drama, but I am a bit sad that a language with so much potential has been dropped instead of being handed over to the community.
>The creator has a fan base he doesn't want to disappoint and who will defend his honor as long as he can give them any evidence he's actually making progress
So yes, it's fair to say that you do care about the creator and his drama.
0.19 also prohibited interaction with non-Elm code which I recall a controversy about. But can't seem to find out if anyone forked 0.18 because of that.
> Gren started as a fork of Elm. This is mostly considered to be an implementation detail, a way to speed up initial development.
> It's not a goal of Gren to replace, or stay compatible in any way with, Elm.
A little vague but I read it as they're planning on diverging strongly and immediately with a clean break. Which doesn't make it not a fork I guess, but isn't what I normally think of when someone says a project is a fork of another.
So Gren is a fork.
There's a third inspired-by-elm language Derw (after Gren and Roc that are mentioned elsefork) but I don't know much about it.
What is the maintenance burden of the average React app? When I have written an Elm app, I feel confident that I could come back to it in a few years time with no issues.
To me, this stability is a testament to the language's thoughtful design and rejection of the constant churn of contemporary web development. At the risk of sounding like a Game of Thrones fan waiting for Winds of Winter, I look forward to the next version coming out with modest changes and bug fixes whenever it is ready.
They never made it to 1.0, so it's not surprising, but major compiler bugs coupled with no chance of a patch (2.5 years since the last bug fix update) definitely suggests the language shouldn't be used in large projects.
There was a commonly encountered compiler bug in 0.19.0 (Map.! crash) and the 0.19.1 version was the result of fixing that. During 4 years of writing Elm full-time (close to 500kloc total) I have encountered only a "rank 2 typevar" typechecking bug _once_ and it was easy enough to work around. The Elm code that large projects need doesn't really trigger compiler bugs and crashes of the kind you'd see in the GitHub Issues.
If GCC has some bug reports open about crashes, but your code doesn't really trigger those in practice, would you call GCC unsuited for large projects?
It is clear that Elm is understaffed, to say the least.
The core team treat bug reports as insults: https://github.com/elm/compiler/issues/1773
Edit: And finishing reading that thread now, Evan didn't even return once his question of "why" was answered. That's something else. I have no skin in this game, and people can run their projects as they see fit of course. But this behaviour doesn't make for a great community/ecosystem.
It is bad that the bug has remained for so long.
I don't think people would be saying Elm is dead if there were regular bug fix patches coming out and we were on v0.19.21. The reason why people are declaring Elm dead isn't because new features haven't been added in two and a half years, it's because there hasn't been a bug fix update in two and a half years.
Sure, the language is stable in that it doesn't change, but stable can also mean bug-free, and Elm is certainly not stable enough to justify going that long without a single bug fix.
I will admit that the bug list is extremely disheartening. I have personally never come across them in the wild, but I don't doubt that when they do come up they are a horrible roadblock and the burgeoning set of community tools to work around this is telling.
Which is more or less true, given that Evan never let anyone else fully participate.
I'm fine with Elm-the-language as it is, but I would definitely have preferred for a stdlib not to expose a function that are just a TODO.
I still use and enjoy the language, mostly because everything else in browserland is a pit of despair for me, but I could see some quality pull requests being merged once in a while.
The authors refused to fix a parser error related to negative literals: https://github.com/elm/compiler/issues/1773
I don't think the language is complete, but that we should aspire towards completeness over churn.
https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
For example, all Elm apps having the same architecture ("TEA") is one of the biggest wins over alternative apps where every project, even those you make yourself, will do things differently.
Elm Janitor (https://github.com/elm-janitor/apply-patches) is a curation and applicator of community patches to Elm proper. Haven't used it, but it seems like a promising way forward.
Elm uses a different name for the “not equal” operator:
5| text "Hello!" != "balbla"
^^
Switch to (/=) instead.
Note: Our (/=) operator is supposed to look like a real “not equal” sign (≠). I
hope that history will remember (!=) as a weird and temporary choice.
Wondering if it is just me, or it really is passive-aggressive? It was the first red flag for me.upd: formatting
Passive aggressive might be like this
"there are some languages that feel the need to use !=. They have the 'opinion' that this was a good idea, look at them. They are so cute trying to be a real language with such *interesting* design choices"
Rescript does piggyback on normal JS ecosystem and build systems so comes out worse there. But it's easier to integrate with existing js codebases and npm packages for the same reason, and its output can be used from js in any framework if you plan for it.
I was really missing the elm command/update model for a while but at some point I realized adding that semantics to a react reducer with a custom hook was completely reasonable, and there are a couple existing projects doing exactly that. I wrote my own in an afternoon and have been copying it around to new projects since.
I'm like 90% happy with this transition now. It doesn't always feel quite as safe & magical as elm did, but it's also a lot easier to integrate with other systems.
I defined the actions a little differently and followed the rescript-react pattern of having effects return an Option of a cleanup fn but most of the idea is there.
Looking around just now I also found this PoC of someone doing a very similar thing but all inline with react. https://github.com/mishaszu/rescript-model-view-poc/tree/mai...
Really the only jump you need from react to the elm architecture is having the reducer be (State, Action) -> ('State, Effects) instead of simply returning the new state alone. The then you have a useEffect that invokes the side effect fns, passing in dispatch so they can send updates back to the reducer & so reducer stays pure. There are a bunch of different ways to set that up, and honestly a lot of react apps blunder into an accidental and incomplete version of this anyway it's such a natural model.
The only time I've really seen them is when interacting with js/ts code. The rescript externals system is easier and more flexible than elm ports, but for that reason less safe.
If you don't model the types of incoming data exactly it can cause runtime errors. For some packages it's very difficult to do that with high confidence so I've seen a few leak in. Similarly if you use gentype to map typescript types to rescript, it assumes the types are both correct and sound. Which are not actually guarantees typescript makes I don't think. So I've seen some from that as well.
Rescript doesn't really do a great job at displaying these types of errors either. It's usually pretty obvious where they came from but not always why unless you have good knowledge of the API you're hooking to. So, rare but anomalously frustrating in an otherwise very pleasant language.
I think for this reason it's pretty standard to avoid writing or consuming package-wide bindings to npm modules. It seems like everyone is just writing tuned limited externals only for the parts they actually use, except for a handful of very popular libraries.
432 comments | 3-years ago
Only contacts I've had about Elm positions have been about rewriting existing Elm apps to something else.
Impossible to justify for serious projects at this point.
I think it's a great language that people should explore for fun and learning. I think it was horribly mismanaged from a public relations perspective and at one point in time had a real shot at becoming a lot larger than where it will stay from now on.
Edit: moved the position of the citation.
Live projects appear to be alive. There is activity, developers to talk to, support to purchase, release notes to read, even if those release notes are just maintenance notes for mature software. If your evidence of life is pointing to a two year old forum comment, I hate to break it to you, it's dead.
It's impossible to evangelise something when the creator has seemingly taken his ball and gone home.
The idea that enterprise should use Elm is laughable.
https://discourse.elm-lang.org/t/is-elm-browser-still-mainta...
https://discourse.elm-lang.org/t/request-elm-0-19-2-any-upda...
It's pretty sad. I personally believe the ecosystem would be in a much more vibrant state today, if the creator had formally abandoned the language at any point in the past, as there are many who would pick up the torch.
It is telling that several people who could once have been considered 'core team' are now building their own languages:
I think a lot of programmers get warped views of PL development from over-exposure to the badlands of Javascript. There are languages (like Prolog) that grow like trees, eh?
Personally I do believe that the core team are working on things away from the public eye, and that's fair enough in order to keep focus without having to deal with everyone giving their own opinion or criticism. I just wish there was significantly more transparency in the process, and a few bones thrown to the community in the form of fixes.
I personally wouldn't use the word until Evan throws in the towel, but he's clearly still onboard. For example, https://gotoaarhus.com/2023/sessions/2529/elm-on-the-backend (yesterday).
I don't think we handle these kinds of oddball cases very gracefully which is evident in basically every HN discussion about Elm. If a language gains traction, then we demand a certain shape of expectations from it, and we're not very good at walking away with just "well, it ain't for me". It's not enough for us to just say that. It's like we have to linger around and ensure everybody else washes their hands of the tool, too.
I'm pretty sure Elm is past the point where anyone who doesn't like the glacial BDFL approach doesn't use it, and those who choose to use it don't care.
What's funny, rtfeldman uses case expression with numbers in his (in OP's blogpost) praised library elm-hex, so it's not the problem of numbers vs variants. Only negative numbers are the problem.
Sounds like a case of the halting problem.
We only use it when there is complexity: when there is just a little progressive enhancement needed on a SSR HTML page we happily use vanilla JS or jQuery (we're looking for a good TS-based jQuery-like solution the fits that bill).
What we like about Elm:
* makes us think about tech design issues early on (you cannot just ignore them)
* its a transformative experience: devs become better at writing any language after having solid Elm experience
* its fast to compile compared to TS+React+Redux+Babel+WebPack+...
* no unhandled runtime errors! (yes it is true, no more errors with Elm)
Just like I find Ruby a very nice language that was hidden in Perl, I see Elm as a very nice language that was hidden in Haskell. Thanks Evan for creating it.
And yes I truly believe Elm is not dead but merely finished to a great extend.
Oh, as a bonus, want to have your mind blown, check out this:
https://www.youtube.com/watch?v=nSrucNcwlA8&t=275s
(when I watch that video I cannot unhear "look at all the boiler plate im not writing" in David Heinemeier Hanson's high pitch voice; referring to the original Ruby on Rails demo)
I used to work with elm some years ago and my coworkers claimed this as part of their reasoning for choosing elm. Shockingly, we still had runtime errors! Elm helps reduce some type system based runtime errors. But that’s only a subset of exceptions, and it’s not perfect at even catching those. Try this in elm:
div [ attribute "@style" "color: green" ]
It’ll compile just fine. And crash completely at runtime.
There are some fully type safe CSS systems in Elm, but they are 3rd party libs.
> They are too uptight to do open source properly.
It's not an "open access innovation project", so they did not get that bit of open source "right".
Comparing Lamdera with Rails is near impossible. But one is certainly resulting in less runtime errors!
In the 5 or so projects which uses Lamdera.
No less a CS personage than goddamned Donald Knuth uses the decimal expansions of irrational constants to denote that his programs approach "finished" with smaller and smaller changes. Somehow this is fine when he does it but "the language is basically cooked as far as syntax goes" is an unacceptable answer to the Elm decriers. Dogs bark; the caravan goes on. Mazel Tov on launching your thing in production. I wish you a thousand years of success.
Also: many do not like anything they are not accustomed to.
Elm is fine for learning, but that's all for me. Serious products for serious customers require more than "beautiful typings"
Elm has some super annoying problems, like their disdain for nested structures or components, but I just don't know of anything better...
Is that within Evan's ambition? I personally do not mind to use software that does not cater for enterprise in production at our small "enterprise" :)
I have seen similar titles for old software bouncing around, one example is ical, the tck/tk calendar application I use to use. I keep running across ical and my first thought is always "is ical still under development ?". At the time that was a very nice application and had potential.
I stopped using elm (email) when I found mutt(1).
Gads, that and procmail(1) were heaven. And when I finally intersected procmail with eliza, I was full of bliss... I was at AT&T (yes, THE AT&T) and it was hyper-satisfying that my co-workers recognized it and the marketing dept usually did not.
"Wow. I had no idea that email reader I used thirty years ago had such depth!"
https://www.youtube.com/watch?v=IcgmSRJHu_8
https://www.youtube.com/watch?v=x1FU3e0sT1I
the talks are geared towards elm but I think they offer some great advice applicable to programming in general.
But that would take a lot of effort, so I just use Elm instead.
[1]: https://gist.github.com/JoelQ/6b303d9ad450537163b6f8f6cf8a4e... [2]: https://ellie-app.com/mQ52TY6k3zZa1
type Item = { name: String, year: Int, kind: Kind }
type Kind
= Cd { artist: String }
| Book { author: String }
| Shoes { size: Float }
https://ellie-app.com/mSVCN8dQqX8a1Consider joining the Slack community: https://elmlang.slack.com -- The #beginners channel is a great place to ask these kinds of questions.
I don't think I'd ever use "elegant" to describe Go
it's a workhorse language that's readable and full of utility.
When I think elegant, I think Clojure. Not that I'd want to use it day to day (I have)
You are not alone. I do kernel programming in C. I've seen so many languages come and go since the 90s that I can't keep track of them all. I never used elm the email client (I was more of an emacs rmail person at the time).
the architectural model is good, and there are many projects mimicking it in a more open way.