My Elm Experience
underjord.io
underjord.io
What slowed me down with Elm was JSON parsing, which needs to be done manually and can take hours or days whereas the same thing in JS takes about 2 seconds to type an import statement. And the other thing was using BabaylonJS and Phaser - you can certainly use them with Elm but you’ll need to commit to months of extra work to build port-based interfaces to them. And, games live in the world of side-effects, which is a chore in Elm. I needed to get finished games out in days - which I was able to hacking my way through with JS.
Having used Elm for such a long time, I’m baffled by the success of Typescript - it’s hardly more reliable than JS while adding another dependency and much more complexity. For anyone sincerely interested in writing reliable code, not just wanting another toy to play with (Typescript) I can’t image writing front end code in anything other than Elm.
It's maintainability.
ReasonML/ReScript or F#+Fable or Kotlin.js maybe more closer to what I consider the middel.
JS (which TS is a superset of) if just not a very well designed language.
There's a limitation of Elm hidden in there. If your code needs to interoperate with some JavaScript libraries, you need to define an Elm port for each action (i.e. define how Elm sends/receives "messages" to JS). If the Elm-JS messages are few, it's OK, but if not, the process is painful to code and slow to execute.
Once that is done you can stay mostly in "pure land", which is quite a blissful experience.
Elm prohibits glue code. You can't take well tested JS library, write FFI definitions (like Rescript/Purescript) or typings (like TypeScript) and publish it. You can only publish pure Elm packages. That also means that you can't use WebAPIs if they are not wrapped in packages whitelisted by Elm core team.
There are only two methods to interop with javascript and they both have massive downsides. WebComponents are WebComponents and even then Elm is very picky how you can write those. Ports are nice for heavy/async work but are unusable with small functional-ish APIs like Intl.
You're baffled, really? The core pitch is that JS developers don't have to learn a whole new language or paradigm such as in the case of other compile-to-JS languages. They can write JS, sprinkle on some TS, and gradually migrate to full TS while learning it along the way. The amount of developer friction is much lower, so that's why it succeeds to a much higher extent (in terms of usage) than other compile-to-JS languages like Elm, PureScript, ReasonML/ReScript, etc.
I do group it with clojure, another language I love and have used deeply but intermittently. If I spend a few months away from it when I see the code it's not even "who wrote this and what does it does it do" it's "is this even code what the fuck man."
LOL when 3 months is considered a long time for a library to not break users, you know something is messed up. I guess the author is referring to the JavaScript ecosystem.
As a Java/Lisp developer, I expect things to keep working essentially forever! Why the hell would they break users every 3 months?!
JavaScript is obviously the elephant in the room here.
I usually guard myself against this by implementing more niche features myself rather than importing them through third party libraries that might get abandoned.
It's not a really point in favour or against Elm, and the dep specification is good enough to tackle it.
And "having no new versions" is not considered a good thing in my book.
When react was immature (aka before hooks) I used elm a fair bit. Nowadays in the age of front-end copy-pasta I just use the framework of the day and sign when I see how slow and patchy TS is.
- You can use reflection to generate encoders and decoders. These can be mixed and matched with hand written encoders and decoders.
- You can just throw an exception when unpacking a result or maybe into a value
- You can use “?” and “!!” operators to tell the compiler that the type is correct when working with dynamic objects
For getting something live quick: yes.
But the learning experience of writing some pure-FP code is destroyed by "just throw an exception" and "use “?” and “!!” operators to tell the compiler that the type is correct"
Being able to write inline JavaScript is certainly not what I want. Perhaps I’m missing something, but inline JavaScript is the kind of thing that will inevitably result in uncaught runtime failure, which is exactly the kind of thing I am trying to avoid by using a language like Elm.
I've since put it in my little red box of "hot but you'll be better off staying away from", depsite the numerous podcasts praising the incredible effort and design that went into the language. Has anyone got any thoughts on this?
Wouldn't base my choice on that at all. Learn it to learn something new and expand your horizon if you want to. Or learn it if you think it's valuable to use in its current state (it is). What some people quab about is irrelevant.
Do I fear that the Linux kernel, which is used by pretty much all Fortune 500 companies and has a huge amount of paid devs, will die in a huge flamewar? No!
The same doesn't hold true for someones hobby project though.
And I am well aware, that Linux was a hobby project once, doesn't change a thing about current state though.
1. The language version starts with 0, i.e. it is being clearly communicated that there is no guarantee of stability
2. The language development is being run by an opinionated BDFL who likes to take his time to think through new features. There's more of novel, well-thought-out ways of doing things, but less support for "I need this for my production use case now"
Neither of those points is inherently bad, but if you plan to adopt Elm in your product or codebase be prepared to rely only on the feature set you get from current version. Expect breaking changes in the future when new version drops.
There's lot to like about the language and it can be a good introduction to functional programming if you are not yet familiar. IMO it is definitely worth spending time on to improve your skillset and to gain new perspectives on programming.
The biggest restriction on adoption is that the language is a gatekeeped brainchild of limited number of devs. They are inclined to build the language around use cases they want, instead of what people who use their language want.
They have effectively closed the gate to having other talented FOSS devs supercharge this language with features that allow it to run circles around other languages currently in production systems (mainly JS)
It's their right to do so if they wish, but it means that I can't consider this language in any serious capacity. It means the language lacks flexibility and reactivity to changing circumstances, and while it describes having a default library without extendible ecosystems as a "feature, not a bug", they've essentially put a ceiling on what is practical with their language in doing so.
I really wanted to like this language, but the more I learned about it, the more I felt disappointed over what could have been.
Conversely, though, the language owners also don't get to have it both ways: if they aren't interested in committing to stability and (some measure of) implementing these production use cases, then they should not act, or promote it, as if it is a production-ready project.
There are lots of great typed functional programming tools for the front end with varying levels of type features. All of them offer interoperation with JavaScript in various forms. I am sure there are more that I have not heard of.
Fable (F#)
GHCJS
js_of_ocaml
Purescript
Rescript (formerly ReasonML)
TypeScript
There's an open bug re: negative literals, and accusations of bad faith towards the reporter.
I'm keeping my anonymity on this HN account, but I've clashed with him before on a Github issue on what should have been a trivial routine update.
1. do other languages allow this? i.e. have other languages prioritized this for development?
2. what are practical situations where it has come up?
Which seem like pretty straightforward questions to ask if you’re trying to prioritize this issue. I get that Evan was a bit curt in asking (2), but I don’t see an accusation of bad faith…
[0]:https://www.urbandictionary.com/define.php?term=You%27re%20H...
Could you help me understand? What am I missing here?
I'd say forget about the drama and just build something with it. You will probably never notice anything from that drama while learning.
Biggest problem in enterprise context is you need a team that's on board on learning elm. If someone just needs to stop by and make some small changes, it's a bigger hurdle than doing it in a language "everyone" knows.
Strict compilers make sure my repo only contains code over a certain level of quality. Elm is strict. Code produced in Elm is usually of stellar quality, even by beginners; and if not it's very easy to shape it up later on.
And do you think understanding Elm requires advanced skills / more than senior level ?
Few things would make me happier than going back in time and picking a much stricter type system like Elm’s or rescript.
We don’t use elmish tho, but the React bindings. Elmish never worked fir us prior little demos.
Fabel (the F# to JS/Python) compiler is also ok speed wise.
I’m developing on a Mac but have team colleges using linux. Can’t complain. JetBrains Rider is years ahead of Visual Studio IMHO.
https://derw.substack.com/p/why-derw-an-elm-like-language-th...
my dream not-elm would start with a verbatim fork of elm, an RFC process for changing it, and a safe and powerful language extensions system inspired by Haskell
a) Very few features, just enough so you can get your work done and there's just one good way to do it. If you don't have a grumpy BDFL then feature creep is inevitable and your language won't be lean and beautiful like Elm (arguably) is.
b) Infrequent releases so that you don't have to reinvent the wheel every few weeks. Elm gets like one release every two years and I very much like it that way. With a big community all helping to develop it rather than (again) one grumpy BDFL who drags their feet all the time there's no way they would be able to have that level of restraint.
That’s a good thing. A very good thing. You can trust the code you write [to a reasonable extent]. You can trust the code your colleagues write [to a reasonable extent], even if they’re relatively junior. Not every change needs to be interrogated like you might have to in the foot-gun factory that is JavaScript.
This level of predictability is amazing for a business, and consequently amazing for a developer’s circadian rhythm if only they could see further than their nose.
Personally I think it wouldn't hurt if more strongly/statically typed languages took a note from the GHC compiler and had an option like -fdefer-type-errors[1]. That way one can write the sloppy/clever/prototype code, then disable the flag and make the program sturdy in the presence of failure.
[1] https://downloads.haskell.org/~ghc/7.8.1/docs/html/users_gui...
However I've recently switched to chicken scheme for that purpose, not because Haskell isn't good but because of type friction I encounter when trying to use new libraries.
It's not a rant at Haskell, as I assume were I to use it on a daily basis it would be a nice fit. But as I'm using it a couple of times a year, it doesn't work out.
What's your preferred gui library for Chicken for this sort of thing?
Last night I was playing with an OCaml Web framework called Dream [1]. The change-recompile-reload loops were fast enough that I never had to wait. (OCaml supports separate / incremental compilation, so the benefits tend to scale on larger projects.) It's not a silver bullet, but it might slightly change your mind about why you like dynamic languages. :)
But I find those two a little on the less featurefull side. I think by the time typeclasses are in things get slow really fast. It's features like that, that just add a lot of complexity at compile time.
Just had a look at Dream. Good to see httpaf AND mirage (microkernel) targets! And it allows coding in Reason/Melange, which I find a very nice syntax especially for server-side code. Thanks for mentioning.