Learning Elm by porting a medium-sized web frontend from React (2019)
benhoyt.com
benhoyt.com
I would recommend to steer clear of a language that makes these sorts of decisions -- that certain features are off-limits to the regular developer because they can't be trusted to use them correctly -- because if you find yourself in a situation where you need that to solve your problem, you're trapped. I included Go in the set of languages I would recommend steering clear of for years, due to their decision to allow their own `map` type be a generic[2] type but no user-defined types could be[3], leading to ridiculously over-verbose codebases, but they have finally corrected course there.
If you're looking for something kinda like Elm but not likely to break your own work in the future, I'd recommend checking out ReasonML[4] instead.
[1]: https://lukeplant.me.uk/blog/posts/why-im-leaving-elm/ [2]: https://go.dev/blog/maps [3]: https://go.dev/doc/faq#beginning_generics [4]: https://reasonml.github.io/
This may not apply to Elm. But I imagine it can feel easier and more rewarding to manage a community that's more like a cult than a typical free-for-all open source project.
Elm was the most fun I ever had developing a browser app. Then they decided I shouldn't be allowed to develop a ShootMyFoot module, and it stopped being fun overnight.
If you want to divide into two camps how 0.19 was received I'd say it's people who were maintaining a substantial Elm project on the one side and people who weren't on the other. Maybe if you're carrying a torch don't drop it on the ecosystem.
Back then if I wanted to search a list of strings for entries that match a regex supplied at run-time, I'd have to pass the whole list through a port, filter it outside, then pass it back in. Rather than just using the filter function. Ports are asynchronous messaging which means I have to restructure the whole code and wait for a state change when the filtered list is returned.
Let me cite the Elm docs on ports[1]: "Definitely do not try to make a port for every JS function you need."
So! Where does that leave me? Unsupported, that's where. Because I need a JS function. In 0.18 unsupported was fine. They broke it for 0.19 and the project died. Maybe it was dying of other causes anyway, but that one action sure drove people away.
There are a bunch of other options/workarounds/hacks depending on the need. E.g. using getters or creating proxy objects https://github.com/anmolitor/intl-proxy, or event listeners, or postprocessing of the generated JS code, but those shouldn't be the first idea to reach for.
The last commit to the regex package was in May 2018, and Elm 0.19 was released later in August. https://github.com/elm/regex/commits/1.0.0/
So it seems like by the time of the official release you could have replaced your five lines with `Regex.fromString`.
But the missing Intl API is definitely a huge pain, and I understand that you were switching away if you needed it extensively. Or expected to want other sync APIs wrapped.
A common way to solve something like this is with proxy objects like in https://github.com/anmolitor/intl-proxy but it does not give access to every feature in a nice way.
I went the route of least resistance and built the Elm compiler without the Kernel code check. But in the past few years I hardly needed that anymore.
I just don’t understand the reasoning for this choice.
https://github.com/Zokka-Dev/zokka-compiler
edit: there's also Roc, https://www.roc-lang.org/, a language started by Richard Feldman who I believe was a former elm core team member. I think Roc aims to accomplish different things than elm, but definitely feels like a spiritual successor
Just FUD. I've been on a big team writing a webapp used by hundreds of thousands each day. While it's not necessarily my own first choice, it was great and the least error prone piece of software I've written in my career.
Elm's value proposition is mostly being a functional language with an opinionated MVU library baked in, so you can reproduce that value with a better functional language and selecting a similar MVU library in that other language, which means it should never actually cross the value bar above the risk it brings if you need a browser feature it doesn't support and actively prevents you from accessing.
Production is not some place you're supposed to cowboy code, but instead have a reasonable expectation that you will be able to continue supporting it for as many years as it operates, and it's impossible for anyone to responsibly use technology with known limitations that have bitten other real engineering teams that they can find zero workarounds for.
If you don't consider that an impossibility for a production environment, then I certainly wouldn't want to work with you on a team with production responsibilities.
If you want to rely on them for every possible future requirement or rather want to pick another tool is another question :D
Anyways, just building the compiler without that check was also not that hard.
To me it looks more like the elm-haters are out in force and the Elm users don't participate anymore on this site.
Many hateful comments here below a historic post prompted me to create a new account after a detox phase of >10 years.
So far I try to correct a false statement in the (as of writing this) top comment [1] or add a more neutral view [2]. And maybe I will add more of my personal opinion in the future - or participate in other interesting topics depending on my mood.
[1]: https://news.ycombinator.com/item?id=39555542 [2]: https://news.ycombinator.com/item?id=39556395
Here's a good (neutral!) write-up: https://ersin-akinci.medium.com/confused-about-rescript-resc...
I think this is very, very different. First because Go didn’t have a cultish purist aversion to generics, banning people, going after them even outside of community spaces. But on a technical side, maps (and slices and channels) were not gated to be used by std, they were publically available to anyone. Not having generalized a feature is not the same as banning it. There was not even Go syntax to express it. Same as arrays in C, no?
That said, I’m not challenging the recommendation to stay away or not - generics was (and still is, may I add!) quite a pain point with the language. I’m personally quite invested for other reasons (concurrency, networking, std lib), but people come to different conclusions naturally.
The recurring complain I hear about scala are the bad compile times. I haven't used the language much, so not sure if this only applies to libraries that heavily use compile time metaprogramming.
But I really love that with modern tooling we can get a sub-second editor->browser feedback loop even for a three year old medium-large project on modern hardware. This was primarily one of the reasons I avoided Kotlin+Gradle JS target because among other issues the feedback loop was 2-3x slower.
Absolutely false.
> The year in this link is very important. In the following year, the Elm team decided to [...]
The blog post was released a year after the official release of Elm 0.19 where the access to native code was further restricted in the official compiler.
It was not something that happened without ample prior notice, see for instance a post [1] by the Elm language creator in March 2018 in which he explains his reasoning for the upcoming change. Or another in March 2017 where he announced that intended change [2]. Even in 2015 he actively discouraged people to rely on these undocumented features and other hacks [3].
I also was not happy with that choice and felt the pain of something being taken away that was possible before, but that didn't stop me from using Elm at work nor from using it for fun.
So far I haven't found an alternative that I liked better, so I will stick to it.
[1]: https://discourse.elm-lang.org/t/native-code-in-0-19/826 [2]: https://groups.google.com/g/elm-dev/c/bAHD_8PbgKE/m/X-z67wTd... [3]: https://groups.google.com/g/elm-dev/c/1JW6wknkDIo/m/H9ZnS71B...
Essentially, the go developers saw a need for generics and then decided that only they get to create them, where most modern language developers either make them available for everyone to implement or don't add them at all.
It's the kind of thing that even if you don't end up using, you come out with lessons that make you a better programmer. Some that I remember:
- The compiler was fast, it made me aware that you could have an iterative workflow like most dynamic languages but driven by types
- The language/framework constructs (views, updates, etc) made it clear what kind of functionality had to live where so it makes me aware to define roles/arch in React apps that are 'just components'
- Error messages are just awesome, it was the clearest I had seen at that point and made me realize other languages just haven't paid enough attention to make them more usable
I still use it for personal projects where 8 can but Elm is showing its age. Newer JavaScript APIs are not well supported and ports, while I understand why they exist, can be painful to use.
But I'd still recommend it. Way more fun than any other fronted framework library I've used and the functional nature was a fun challenge for me.
Coming back to an old React app is usually a pain because everything changes between projects, even the state management architecture.
I've not seen anyone picking it for new dev in... a really long time.
Shame, really.
Sort of a modern front-end developer's version of reading SICP even if you're not going to end up coding in Lisp, but because it makes you a better programmer, as you say. Interesting take!
If you think a cult of personality is bad, you aren’t appreciating how much worse is, to the rest of us, the cult of anti-cheerleaders on every post that mentions Elm.
For years now any time someone wants to read about Elm, they have to hear from the same few HNers who don’t even use it yet refuse to let it go.
It’s like every time Dune plays in the movie theater, the same crowd comes in to explain how shit it is, how different it is from the book, in fact check out this ancient blog post about how bad it is, and there’s no way yall in the audience will enjoy it so don’t even try! The director sucks too, just look what he did! He fkin did that! It’s actually impossible to enjoy the movie once you know all the facts. And the guy who made the movie didn’t listen to my meticulous feedback and it hurt me cuz boy do I have opinions about how a Dune movie should be made, believe you me.
Meanwhile we just want to watch the dang movie.
Maybe a better question to be curious about is this: What can Elm do about the (self-evident in these comments, IMO) fact that a bunch of devs who really like it, feel like it's a bad choice? And, what SHOULD Elm do about that?
If a bunch of people think it's a tool foreboding enough to warn others off of it, and in the same thread some of those same people are saying they really liked that tool and wish they didn't have to do that, what benefit are you really getting from just dismissing their feedback?
Outspoken feedback is rare, just calling it negativity and paying it no mind rhymes a lot with the way Elm, writ large, has behaved. It's not indicative of a tool or ecosystem that wants to foster growth or continue development. That's part of the problem.
I'm curious about why the same few, a vocal minority, spams every thread about elm with the same blog post. If you think we're dismissive, it's more because we don't want the discussion to be derailed for the umpteenth time.
Elm's maintaners decided to break this. They created what amounts to a caste system for code. If your code was blessed, then it got all sorts of extra abilities not granted to un-blessed code. And the sole authority on blessing was the cadre of developers.
Now, as to why they did this is a different discussion. There are good and bad arguments on both side. But as to why it comes up all the time? Ego
It's like this meme. https://imgur.com/a/mjsMOGJ why do so many want to be the person to the left when it comes to elm? And so many years later?
I am not seeking out opportunities to badmouth Elm. But as I am someone who is interested in FP and frontend tech in general, when I see an Elm story on the frontpage I click on it to see what folks are saying. And when I see exclusively glowing and positive statements (which was the case when I first posted) then I feel like I have an obligation to point out that there are some big issues with how Elm is maintained, because this is the sort of thing that _I_ would want to know before I spent a bunch of time digging into it.
If you want to watch the dang movie go ahead. But anyone asserting that those of us posting negative things about Elm are acting cult-like (seriously?) is being disingenuous. Considering the audience, there are good reasons to highlight the--IMHO major--problems with how the Elm project is run, and not mentioning them is irresponsible.
And if you are thinking of starting now, you should not focus on what undocumented feature (or hack) was taken away in 2018 that allowed injecting arbitrary JavaScript code that easily broke all guarantees of the language https://discourse.elm-lang.org/t/native-code-in-0-19/826 but rather if Elm fits your current (and maybe future) needs. If it does not, keep looking for alternatives.
I have some five or so projects written in Elm and enjoy every time I don't have to upgrade them because no new version was released!
The only fear I have is that I won't be able to install packages that no longer exist when I switching machines.
But by running
ELM_HOME="$PWD/deps" elm make ...
I can get those downloaded into the directories and add them to the VCS.I am also keeping on eye on Gren as a replacement: https://gren-lang.org/
Gren is very open to contributions. This can radically change how this enforcement impacts users in practice. It's too early to say really.
PureScript (https://www.purescript.org) on the other hand is very nice.
On the other hand, I feel like PureScript's records that utilize row polymorphism are such a game changer that it's hard for me not to get frustrated with Haskell records when I go back. And while I love where Haskell is going with WASM and JS support, I think it'll be a little while before that is viable for real-world projects.
This has been an initiative for longer than PureScript has existed. I wouldn't expect it to replace PureScript any time soon to be honest.
It looks like redux has some inspiration from Elm, but I think the way effects are handled in Redux isn't as predictable as Elm.
here's the project for new eyes:
https://elm-lang.org/ © 2012-2021 Evan Czaplicki
React's would say 2022 - https://github.com/facebook/react/releases
There's engineering effort happening behind the scenes on both projects, the releases have slowed, and big changes are coming to both Elm and React.
Dead means it's super stable. Stable is good.
Basically, if you build on Elm, you're living inside Evan's personal project.
There are upsides (Evan did a great job designing the language) and downsides (Evan's goal isn't being a maintainer, and he locked the ecosystem in such a way that many things can't be done without him).